forked from mehdihadeli/food-delivery-microservices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.services.yaml
119 lines (114 loc) · 6.63 KB
/
docker-compose.services.yaml
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
# # https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
# https://docs.docker.com/compose/reference/#use--f-to-specify-name-and-path-of-one-or-more-compose-files
# https://docs.docker.com/compose/extends/
version: "3.8"
services:
gateway:
# https://nickjanetakis.com/blog/docker-tip-57-using-build-and-image-in-the-same-docker-compose-servicemage
# https://github.com/opencontainers/.github/blob/master/docs/docs/introduction/digests.md
image: ${REGISTRY:-ghcr.io}/${PROJECT_NAME:-mehdihadeli/ecommerce-microservices}/gateway-service:${TAG:-latest}
container_name: gateway-${TAG:-latest}
# https://docs.docker.com/compose/compose-file/compose-file-v3/#restart
restart: on-failure
ports:
- ${GATEWAY_HTTP_SVC_PORT:-3000}:80
- ${GATEWAY_HTTPs_SVC_PORT:-3001}:443
# https://docs.docker.com/compose/environment-variables/set-environment-variables/
# https://docs.docker.com/compose/environment-variables/env-file/
# https://learn.microsoft.com/en-us/aspnet/core/security/docker-compose-https?view=aspnetcore-7.0#windows-using-windows-containers
environment:
- ASPNETCORE_ENVIRONMENT=docker
- ASPNETCORE_URLS=https://+:443;http://+:80
- ASPNETCORE_Kestrel__Certificates__Default__Password=${DEV_CERT_PASSWORD:-your_password}
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
volumes:
- ~/.aspnet/https:/https:ro
networks:
- ecommerce
catalogs:
# https://nickjanetakis.com/blog/docker-tip-57-using-build-and-image-in-the-same-docker-compose-service
# https://github.com/opencontainers/.github/blob/master/docs/docs/introduction/digests.md
image: ${REGISTRY:-ghcr.io}/${PROJECT_NAME:-mehdihadeli/ecommerce-microservices}/catalogs-service:${TAG:-latest}
# https://docs.docker.com/compose/compose-file/compose-file-v3/#restart
restart: on-failure
container_name: catalogs-${TAG:-latest}
ports:
- ${CATALOGS_HTTP_SVC_PORT:-4000}:80
- ${CATALOGS_HTTPS_SVC_PORT:-4001}:443
# https://docs.docker.com/compose/environment-variables/set-environment-variables/
# https://docs.docker.com/compose/environment-variables/env-file/
# .env file will resolved implicitly
env_file:
- ./catalogs.env
# https://learn.microsoft.com/en-us/aspnet/core/security/docker-compose-https?view=aspnetcore-7.0#windows-using-windows-containers
environment:
- ASPNETCORE_ENVIRONMENT=docker
- ASPNETCORE_URLS=https://+:443;http://+:80
- ASPNETCORE_Kestrel__Certificates__Default__Password=${DEV_CERT_PASSWORD:-your_password}
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
volumes:
- ~/.aspnet/https:/https:ro
networks:
- ecommerce
identity:
# https://nickjanetakis.com/blog/docker-tip-57-using-build-and-image-in-the-same-docker-compose-service
# https://github.com/opencontainers/.github/blob/master/docs/docs/introduction/digests.md
image: ${REGISTRY:-ghcr.io}/${PROJECT_NAME:-mehdihadeli/ecommerce-microservices}/identity-service:${TAG:-latest}
container_name: identity-{TAG:-latest}
# https://docs.docker.com/compose/compose-file/compose-file-v3/#restart
restart: on-failure
ports:
- ${IDENTITY_HTTP_SVC_PORT:-7000}:80
- ${IDENTITY_HTTPS_SVC_PORT:-7001}:443
# https://docs.docker.com/compose/environment-variables/set-environment-variables/
# https://docs.docker.com/compose/environment-variables/env-file/
# .env file will resolved implicitly
env_file:
- ./identity.env
# https://learn.microsoft.com/en-us/aspnet/core/security/docker-compose-https?view=aspnetcore-7.0#windows-using-windows-containers
environment:
- ASPNETCORE_ENVIRONMENT=docker
- ASPNETCORE_URLS=https://+:443;http://+:80
- ASPNETCORE_Kestrel__Certificates__Default__Password=${DEV_CERT_PASSWORD:-your_password}
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
volumes:
- ~/.aspnet/https:/https:ro
networks:
- ecommerce
customers:
# https://nickjanetakis.com/blog/docker-tip-57-using-build-and-image-in-the-same-docker-compose-service
# https://github.com/opencontainers/.github/blob/master/docs/docs/introduction/digests.md
image: ${REGISTRY:-ghcr.io}/${PROJECT_NAME:-mehdihadeli/ecommerce-microservices}/customers-service:${TAG:-latest}
container_name: customers-{TAG:-latest}
# https://docs.docker.com/compose/compose-file/compose-file-v3/#restart
restart: on-failure
ports:
- ${CUSTOMERS_HTTP_SVC_PORT:-8000}:80
- ${CUSTOMERS_HTTPS_SVC_PORT:-8001}:443
# https://docs.docker.com/compose/environment-variables/set-environment-variables/
# https://docs.docker.com/compose/environment-variables/env-file/
# .env file will resolved implicitly
env_file:
- ./customers.env
# https://learn.microsoft.com/en-us/aspnet/core/security/docker-compose-https?view=aspnetcore-7.0#windows-using-windows-containers
environment:
- ASPNETCORE_ENVIRONMENT=docker
- ASPNETCORE_URLS=https://+:443;http://+:80
- ASPNETCORE_Kestrel__Certificates__Default__Password=${DEV_CERT_PASSWORD:-your_password}
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
volumes:
- ~/.aspnet/https:/https:ro
networks:
- ecommerce
# https://docs.docker.com/compose/networking/
# https://docs.docker.com/engine/reference/commandline/network_create/
# https://docs.docker.com/compose/compose-file/#networks-top-level-element
# https://stackoverflow.com/questions/38088279/communication-between-multiple-docker-compose-projects
# We could use also a predefined network and connect to that predefined network with specifying the 'name' of existing network and set 'external' attribute to true
# When we run docker-compose up, Docker Compose will check if the 'ecommerce' network already exists. If it does not exist, it will create the 'ecommerce' network. If it exists, it will use the existing 'ecommerce' network. problem is that if we do a docker-compose down this network will delete and other docker-compose that use same network will fail because network deleted so its better we use `external` keyword for using a predefined network
networks:
ecommerce:
name: ecommerce
driver: bridge
# we can use the network that will create by infrastructure docker-compose file and we use that network here by specifying existing network 'name' and set 'external' attribute to 'true' (because we want to use a network outside of our docker-compose) or we can create a `ecommerce` network manually by `docker network create -d bridge ecommerce` and use this network as external network for all docker-compose files
external: true