You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Use a static website hosting service in production
87
126
# See https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.mddeployment
88
127
image: ${CONTAINER_REGISTRY_BASE}/client
89
128
build:
90
129
context: ./client
130
+
cache_from:
131
+
- ${CONTAINER_REGISTRY_BASE}/client
91
132
env_file:
92
133
- ./client/.env
93
134
volumes:
@@ -96,8 +137,25 @@ services:
96
137
expose:
97
138
- 3000
98
139
labels:
99
-
- "traefik.port=3000"
100
-
- "traefik.frontend.rule=Host:localhost"
140
+
- traefik.port=3000
141
+
- traefik.frontend.rule=Host:localhost
142
+
143
+
admin:
144
+
# Use a static website hosting service in production
145
+
# See https://facebook.github.io/create-react-app/docs/deployment
146
+
image: ${CONTAINER_REGISTRY_BASE}/admin
147
+
build:
148
+
context: ./admin
149
+
cache_from:
150
+
- ${CONTAINER_REGISTRY_BASE}/admin
151
+
volumes:
152
+
- ./admin:/usr/src/admin:rw,cached
153
+
- /usr/src/admin/node_modules
154
+
expose:
155
+
- 3000
156
+
labels:
157
+
- traefik.port=3000
158
+
- traefik.frontend.rule=Host:admin.localhost
101
159
102
160
volumes:
103
161
db-data: {}
@@ -120,3 +178,195 @@ If you do that, you'll have to update the `CORS_ALLOW_ORIGIN` environment variab
120
178
## Known Issues
121
179
122
180
If your network is of type B, it may conflict with the Traefik sub-network.
181
+
182
+
## Going Further
183
+
184
+
As this Traefik configuration listens on 80 and 443 ports, you can run only 1 Traefik instance per server. However, you may want to run multiple API Platform projects on same server. To deal with it, you'll have to externalize the Traefik configuration to another `docker-compose.yml` file, anywhere on your server.
185
+
Here is a working example:
186
+
```yaml
187
+
# /somewhere/docker-compose.yml
188
+
version: '3.4'
189
+
190
+
services:
191
+
traefik:
192
+
image: traefik
193
+
command: --api --docker
194
+
ports:
195
+
- "80:80"
196
+
- "443:443"
197
+
- "8080:8080"
198
+
volumes:
199
+
- /var/run/docker.sock:/var/run/docker.sock
200
+
# load a TOML configuration file and to generate Let's Encrypt certificated as explained in https://docs.traefik.io/user-guide/docker-and-lets-encrypt/
201
+
# - ./traefik.toml:/traefik.toml
202
+
# - ./acme.json:/acme.json
203
+
networks:
204
+
- api_platform_network
205
+
# Add other networks here
206
+
207
+
networks:
208
+
api_platform_network:
209
+
external: true
210
+
# Add other networks here
211
+
```
212
+
213
+
Then update the `docker-compose.yaml` file belonging to your API Platform projects:
214
+
```patch
215
+
# docker-compose.yml
216
+
version: '3.4'
217
+
218
+
x-cache:
219
+
&cache
220
+
cache_from:
221
+
- ${CONTAINER_REGISTRY_BASE}/php
222
+
- ${CONTAINER_REGISTRY_BASE}/nginx
223
+
- ${CONTAINER_REGISTRY_BASE}/varnish
224
+
225
+
+x-network:
226
+
+ &network
227
+
+ networks:
228
+
+ - api_platform_network
229
+
230
+
services:
231
+
# Uncomment these lines only if you want to run one api-platform instance using traefik
232
+
- traefik:
233
+
- image: traefik:latest
234
+
- command: --api --docker
235
+
- ports:
236
+
- - "80:80"
237
+
- - "443:443"
238
+
- volumes:
239
+
- - /var/run/docker.sock:/var/run/docker.sock
240
+
- <<: *network
241
+
242
+
php:
243
+
image: ${CONTAINER_REGISTRY_BASE}/php
244
+
build:
245
+
context: ./api
246
+
target: api_platform_php
247
+
<<: *cache
248
+
depends_on:
249
+
- db
250
+
+ environment:
251
+
+ # You should remove these variables from .env into api folder
0 commit comments