forked from alisonbuss/quickstart-drone-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.traefik2.yml
More file actions
233 lines (217 loc) · 8.85 KB
/
Copy pathdocker-compose.traefik2.yml
File metadata and controls
233 lines (217 loc) · 8.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# @Description: Example of a Docker Compose that
# implements the services (Traefik, Gitea, Drone CI).
# @Fonts:
# - https://docs.docker.com/compose/compose-file/
# - https://docs.docker.com/network/
# - https://docs.docker.com/storage/volumes/
version: "3.7"
# Defining docker volumes with the DRIVER(local).
volumes:
vol_gitea_db:
driver: local # Path: /var/lib/docker/volumes/quickstart-drone-ci_vol_gitea_db/_data
vol_gitea_server:
driver: local # Path: /var/lib/docker/volumes/quickstart-drone-ci_vol_gitea_server/_data
vol_drone_server:
driver: local # Path: /var/lib/docker/volumes/quickstart-drone-ci_vol_drone_server/_data
# Defining a local network with the DRIVER(bridge).
networks:
network_local:
external: false
services:
# Defining a reverse proxy service using Traefik.
reverse_proxy:
image: traefik:v2.1.1 # Official image of the Docker Hub.
container_name: reverse_proxy
command:
- "--api.dashboard=true"
- "--providers.docker=true"
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=network_public"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.letsencryptresolver.acme.httpchallenge=true"
- "--certificatesresolvers.letsencryptresolver.acme.httpchallenge.entrypoint=web"
- "--certificatesresolvers.letsencryptresolver.acme.email=you-email@domain.com"
- "--certificatesresolvers.letsencryptresolver.acme.storage=/etc/traefik/letsencrypt/acme.json"
- "--log.level=DEBUG"
- "--log.format=common"
- "--log.filePath=/var/log/traefik/traefik.log"
- "--accesslog=true"
- "--accesslog.filepath=/var/log/traefik/access-log"
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=Host(`traefik.docker.localhost`)"
- "traefik.http.routers.api.service=api@internal"
- "traefik.http.routers.api.middlewares=auth"
- "traefik.http.routers.api.priority=1"
# Access with username and password: test
- "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/"
restart: on-failure
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
ports:
- "80:80" # The HTTP port.
- "443:443" # The HTTPS port.
- "8080:8080" # The Web UI (Enabled by --api).
networks:
network_local:
aliases:
- gitea.docker.localhost
- droneserver.docker.localhost
- drone.docker.localhost
# Defining a database service for Gitea Server.
gitea_db:
image: postgres:12.1 # Official image of the Docker Hub.
container_name: gitea_db
environment:
- POSTGRES_DB=gitea
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- PGDATA=/var/lib/postgresql/data
command:
- "--logging_collector=on"
- "--log_statement=all"
- "--log_filename=postgresql-%Y-%m-%d_%H%M%S.log"
- "--log_directory=/var/log/postgresql"
volumes:
- "vol_gitea_db:/var/lib/postgresql/data"
restart: always
ports:
- "5432:5432"
networks:
- network_local
# Defining a version control service using Gitea(Git with a cup of tea).
gitea_server:
image: gitea/gitea:1.10.2 # Official image of the Docker Hub.
container_name: gitea_server
environment:
- RUN_MODE=dev
- ROOT_URL=https://gitea.docker.localhost
- DB_TYPE=postgres
- DB_NAME=gitea
- DB_HOST=gitea_db:5432
- DB_USER=postgres
- DB_PASSWD=postgres
- USER_UID=1000
- USER_GID=1000
labels:
- "traefik.enable=true"
- "traefik.http.routers.gitea_server.rule=Host(`gitea.docker.localhost`)"
- "traefik.http.routers.gitea_server.entrypoints=websecure"
- "traefik.http.routers.gitea_server.tls.certresolver=letsencryptresolver"
- "traefik.http.services.gitea_server.loadbalancer.server.port=3000"
# Create an OAuth Application
#command: gitea admin auth add-oauth --name drone --auto-discover-url https://drone.docker.localhost --key secret --secret secret
depends_on:
- gitea_db
- reverse_proxy
volumes:
- "vol_gitea_server:/data"
restart: unless-stopped
ports:
- "22:22"
networks:
network_local:
aliases:
- gitea.docker.localhost
# Drone Server is a runner and a standalone daemon that
# polls the server for pending pipelines to execute.
drone_server:
image: drone/drone:1 # Official image of the Docker Hub.
container_name: drone_server
environment:
# Required string value configures the user-facing hostname.
- DRONE_SERVER_HOST=droneserver.docker.localhost
# Required string value configures the user-facing protocol.
- DRONE_SERVER_PROTO=http
# Automatically generates an SSL certificate using Lets Encrypt,
# and configures the server to accept HTTPS requests.
- DRONE_TLS_AUTOCERT=false
# Required literal value provides the Drone shared secret.
# This is used to authenticate the RPC connection to the server.
- DRONE_RPC_SECRET=secret
# Configures the database driver name.
- DRONE_DATABASE_DRIVER=sqlite3
# Configures the database connection string.
- DRONE_DATABASE_DATASOURCE=/var/lib/drone/drone.sqlite
# GITEA params:
# Require string value provides your Gitea server address.
- DRONE_GITEA_SERVER=https://gitea.docker.localhost
# Required string value provides your Gitea oauth Client ID.
- DRONE_GITEA_CLIENT_ID=4aaef1fa-d6e7-4705-8dbb-1403608b7101
# Required string value provides your Gitea oauth Client Secret.
- DRONE_GITEA_CLIENT_SECRET=PvSPzNY97YHNBlIzYC0Gd_zcH5PznhIWHrdvN6POQuE=
# Enables trace logging.
- DRONE_LOGS_TRACE=true
# Enables debug logging:
- DRONE_LOGS_DEBUG=true
- DRONE_LOGS_TEXT=true
- DRONE_LOGS_PRETTY=true
- DRONE_LOGS_COLOR=true
# TODO: CHECK PARAMETERS!
- DRONE_AGENTS_ENABLED=true
# Optional comma separated list. Provides a list of Docker networks
# that are attached to every pipeline step.
- DRONE_RUNNER_NETWORKS=network_local
labels:
- "traefik.enable=true"
- "traefik.http.routers.drone_server.rule=Host(`droneserver.docker.localhost`)"
- "traefik.http.routers.drone_server.entrypoints=web"
- "traefik.http.services.drone_server.loadbalancer.server.port=80"
depends_on:
- gitea_server
volumes:
- "vol_drone_server:/var/lib/drone"
restart: always
networks:
network_local:
aliases:
- droneserver.docker.localhost
# Drone Agents is a runners poll the server for workloads to execute.
drone_agent:
image: drone/drone-runner-docker:1 # Official image of the Docker Hub.
container_name: drone_agent
environment:
# Enable and setup the Dashboard:
# Disables the runner’s user interface.
- DRONE_UI_DISABLE=false # (Default is true)
# Access with username and password: root
# Sets the basic authentication username used to authenticate and access the web dashboard.
- DRONE_UI_USERNAME=root
# Sets the basic authentication password used to authenticate and access the web dashboard.
- DRONE_UI_PASSWORD=root
# Required string values. Defines the hostname (and optional port) used to connect to the Drone server.
- DRONE_RPC_HOST=droneserver.docker.localhost
# Required string value. Defines the protocol used to connect to the Drone server. The value must be either http or https.
- DRONE_RPC_PROTO=http
# Required string value. Provides the shared secret used by the Drone server to authenticate http requests.
- DRONE_RPC_SECRET=secret
# Limits the number of concurrent pipelines that a runner can execute.
- DRONE_RUNNER_CAPACITY=2
# Optional comma separated list. Provides a list of Docker networks
# that are attached to every pipeline step.
- DRONE_RUNNER_NETWORKS=network_local
# Setup Logging:
# Enables debug level logging.
- DRONE_DEBUG=true
# Enables trace level logging.
- DRONE_TRACE=true
# should only be enabled to troubleshoot communication issues.
- DRONE_RPC_DUMP_HTTP=true
- DRONE_RPC_DUMP_HTTP_BODY=true
# labels:
# - "traefik.enable=true"
# - "traefik.http.routers.drone_agent.rule=Host(`drone.docker.localhost`)"
# - "traefik.http.routers.drone_agent.entrypoints=websecure"
# - "traefik.http.routers.drone_agent.tls.certresolver=letsencryptresolver"
# - "traefik.http.services.drone_agent.loadbalancer.server.port=3000"
depends_on:
- drone_server
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
restart: always
networks:
network_local:
aliases:
- drone.docker.localhost