From 73b1b4e77e32690ccf1d0c2dfef2624ef90bb891 Mon Sep 17 00:00:00 2001 From: Ben Young Date: Tue, 16 Nov 2021 09:49:42 -0600 Subject: [PATCH] Extract swarm specific options to a swarm compose file --- docker-compose.swarm.yml | 49 ++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 45 ------------------------------------ 2 files changed, 49 insertions(+), 45 deletions(-) create mode 100644 docker-compose.swarm.yml diff --git a/docker-compose.swarm.yml b/docker-compose.swarm.yml new file mode 100644 index 0000000..64fe72d --- /dev/null +++ b/docker-compose.swarm.yml @@ -0,0 +1,49 @@ +version: "3.8" +services: + api: + networks: + - default + - traefik + + deploy: + labels: + - "traefik.enable=true" + - "traefik.docker.network=traefik" + - "traefik.http.routers.mlmodelscope-api.rule=Host(`${ENVIRONMENT}api.mlmodelscope.org`)" + - "traefik.http.routers.mlmodelscope-api.entrypoints=websecure" + - "traefik.http.routers.mlmodelscope-api.tls.certresolver=letsencrypt" + - "traefik.http.services.mlmodelscope-api.loadbalancer.server.port=80" + - "traefik.http.middlewares.add-cors.headers.accessControlAllowMethods=GET,OPTIONS,PUT" + - "traefik.http.middlewares.add-cors.headers.accesscontrolalloworiginlist=https://staging.mlmodelscope.org,http://localhost:3000" + - "traefik.http.middlewares.add-cors.headers.accessControlAllowCredentials=true" + - "traefik.http.middlewares.add-cors.headers.accessControlAllowHeaders=origin,x-requested-with,content-type,accept,x-request-id" + - "traefik.http.middlewares.add-cors.headers.accesscontrolmaxage=100" + - "traefik.http.middlewares.add-cors.headers.addvaryheader=true" + - "traefik.http.routers.mlmodelscope-api.middlewares=add-cors" + + uploader: + networks: + - default + - traefik + + deploy: + labels: + - "traefik.enable=true" + - "traefik.docker.network=traefik" + - "traefik.http.routers.mlmodelscope-uploader.rule=Host(`${ENVIRONMENT}uploader.mlmodelscope.org`)" + - "traefik.http.routers.mlmodelscope-uploader.entrypoints=websecure" + - "traefik.http.routers.mlmodelscope-uploader.tls.certresolver=letsencrypt" + - "traefik.http.services.mlmodelscope-uploader.loadbalancer.server.port=80" + - "traefik.http.middlewares.add-cors-uploader.headers.accessControlAllowMethods=GET,OPTIONS,PUT,PATCH" + - "traefik.http.middlewares.add-cors-uploader.headers.accesscontrolalloworiginlist=https://staging.mlmodelscope.org" + - "traefik.http.middlewares.add-cors-uploader.headers.accessControlAllowCredentials=true" + - "traefik.http.middlewares.add-cors-uploader.headers.accessControlAllowHeaders=origin,x-requested-with,content-type,accept,x-request-id,tus-resumable,upload-length,upload-metadata,upload-offset" + - "traefik.http.middlewares.add-cors-uploader.headers.accesscontrolmaxage=100" + - "traefik.http.middlewares.add-cors-uploader.headers.addvaryheader=true" + - "traefik.http.routers.mlmodelscope-uploader.middlewares=add-cors-uploader" + + +networks: + traefik: + external: + name: traefik diff --git a/docker-compose.yml b/docker-compose.yml index 5676520..8e83f5d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,26 +3,6 @@ services: api: image: "$DOCKER_REGISTRY/mlmodelscope-api:1.0" - networks: - - default - - traefik - - deploy: - labels: - - "traefik.enable=true" - - "traefik.docker.network=traefik" - - "traefik.http.routers.mlmodelscope-api.rule=Host(`staging.api.mlmodelscope.org`)" - - "traefik.http.routers.mlmodelscope-api.entrypoints=websecure" - - "traefik.http.routers.mlmodelscope-api.tls.certresolver=letsencrypt" - - "traefik.http.services.mlmodelscope-api.loadbalancer.server.port=80" - - "traefik.http.middlewares.add-cors.headers.accessControlAllowMethods=GET,OPTIONS,PUT" - - "traefik.http.middlewares.add-cors.headers.accesscontrolalloworiginlist=https://staging.mlmodelscope.org,http://localhost:3000" - - "traefik.http.middlewares.add-cors.headers.accessControlAllowCredentials=true" - - "traefik.http.middlewares.add-cors.headers.accessControlAllowHeaders=origin,x-requested-with,content-type,accept,x-request-id" - - "traefik.http.middlewares.add-cors.headers.accesscontrolmaxage=100" - - "traefik.http.middlewares.add-cors.headers.addvaryheader=true" - - "traefik.http.routers.mlmodelscope-api.middlewares=add-cors" - environment: - C3SR_REGISTRY_ENDPOINTS=registry:8500 - C3SR_REGISTRY_PROVIDER=consul @@ -54,30 +34,5 @@ services: uploader: image: "$DOCKER_REGISTRY/mlmodelscope-uploader:1.0" - networks: - - default - - traefik - - deploy: - labels: - - "traefik.enable=true" - - "traefik.docker.network=traefik" - - "traefik.http.routers.mlmodelscope-uploader.rule=Host(`staging.uploader.mlmodelscope.org`)" - - "traefik.http.routers.mlmodelscope-uploader.entrypoints=websecure" - - "traefik.http.routers.mlmodelscope-uploader.tls.certresolver=letsencrypt" - - "traefik.http.services.mlmodelscope-uploader.loadbalancer.server.port=80" - - "traefik.http.middlewares.add-cors-uploader.headers.accessControlAllowMethods=GET,OPTIONS,PUT,PATCH" - - "traefik.http.middlewares.add-cors-uploader.headers.accesscontrolalloworiginlist=https://staging.mlmodelscope.org" - - "traefik.http.middlewares.add-cors-uploader.headers.accessControlAllowCredentials=true" - - "traefik.http.middlewares.add-cors-uploader.headers.accessControlAllowHeaders=origin,x-requested-with,content-type,accept,x-request-id,tus-resumable,upload-length,upload-metadata,upload-offset" - - "traefik.http.middlewares.add-cors-uploader.headers.accesscontrolmaxage=100" - - "traefik.http.middlewares.add-cors-uploader.headers.addvaryheader=true" - - "traefik.http.routers.mlmodelscope-uploader.middlewares=add-cors-uploader" - ports: - "8089:80" - -networks: - traefik: - external: - name: traefik \ No newline at end of file