Skip to content

Commit 3a6db59

Browse files
authored
Merge pull request #43 from JustFiesta/docker-compose
Docker compose for local development and testing
2 parents a7dcef5 + 2912a77 commit 3a6db59

3 files changed

Lines changed: 244 additions & 3 deletions

File tree

docker-compose.yaml

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
version: '3.8'
2+
3+
services:
4+
# Redis for cart service
5+
redis-cart:
6+
image: redis:alpine
7+
container_name: redis-cart
8+
ports:
9+
- "6379:6379"
10+
networks:
11+
- microservices-network
12+
13+
# Ad Service
14+
adservice:
15+
build:
16+
context: ./microservices-demo/src/adservice
17+
dockerfile: Dockerfile
18+
container_name: adservice
19+
ports:
20+
- "9555:9555"
21+
environment:
22+
- PORT=9555
23+
- ENABLE_PROFILER=0
24+
- ENABLE_TRACING=0
25+
networks:
26+
- microservices-network
27+
28+
# Cart Service
29+
cartservice:
30+
build:
31+
context: ./microservices-demo/src/cartservice
32+
dockerfile: Dockerfile
33+
container_name: cartservice
34+
ports:
35+
- "7070:7070"
36+
environment:
37+
- REDIS_ADDR=redis-cart:6379
38+
- ENABLE_PROFILER=0
39+
- ENABLE_TRACING=0
40+
depends_on:
41+
- redis-cart
42+
networks:
43+
- microservices-network
44+
45+
# Product Catalog Service
46+
productcatalogservice:
47+
build:
48+
context: ./microservices-demo/src/productcatalogservice
49+
dockerfile: Dockerfile
50+
container_name: productcatalogservice
51+
ports:
52+
- "3550:3550"
53+
environment:
54+
- PORT=3550
55+
- ENABLE_PROFILER=0
56+
- ENABLE_TRACING=0
57+
networks:
58+
- microservices-network
59+
60+
# Currency Service
61+
currencyservice:
62+
build:
63+
context: ./microservices-demo/src/currencyservice
64+
dockerfile: Dockerfile
65+
container_name: currencyservice
66+
ports:
67+
- "7000:7000"
68+
environment:
69+
- PORT=7000
70+
- ENABLE_PROFILER=0
71+
- ENABLE_TRACING=0
72+
networks:
73+
- microservices-network
74+
75+
# Payment Service
76+
paymentservice:
77+
build:
78+
context: ./microservices-demo/src/paymentservice
79+
dockerfile: Dockerfile
80+
container_name: paymentservice
81+
ports:
82+
- "50051:50051"
83+
environment:
84+
- PORT=50051
85+
- DISABLE_PROFILER=1
86+
- DISABLE_TRACING=1
87+
networks:
88+
- microservices-network
89+
90+
# Shipping Service
91+
shippingservice:
92+
build:
93+
context: ./microservices-demo/src/shippingservice
94+
dockerfile: Dockerfile
95+
container_name: shippingservice
96+
ports:
97+
- "50052:50051"
98+
environment:
99+
- PORT=50051
100+
- ENABLE_PROFILER=0
101+
- ENABLE_TRACING=0
102+
networks:
103+
- microservices-network
104+
105+
# Email Service
106+
emailservice:
107+
build:
108+
context: ./microservices-demo/src/emailservice
109+
dockerfile: Dockerfile
110+
container_name: emailservice
111+
ports:
112+
- "8081:8080"
113+
environment:
114+
- PORT=8080
115+
- ENABLE_PROFILER=0
116+
- ENABLE_TRACING=0
117+
networks:
118+
- microservices-network
119+
120+
# Recommendation Service
121+
recommendationservice:
122+
build:
123+
context: ./microservices-demo/src/recommendationservice
124+
dockerfile: Dockerfile
125+
container_name: recommendationservice
126+
ports:
127+
- "8082:8080"
128+
environment:
129+
- PORT=8080
130+
- PRODUCT_CATALOG_SERVICE_ADDR=productcatalogservice:3550
131+
- ENABLE_PROFILER=0
132+
- ENABLE_TRACING=0
133+
depends_on:
134+
- productcatalogservice
135+
networks:
136+
- microservices-network
137+
138+
# Shopping Assistant Service
139+
shoppingassistantservice:
140+
build:
141+
context: ./microservices-demo/src/shoppingassistantservice
142+
dockerfile: Dockerfile
143+
container_name: shoppingassistantservice
144+
ports:
145+
- "8083:8080"
146+
environment:
147+
- PORT=8080
148+
- PRODUCT_CATALOG_SERVICE_ADDR=productcatalogservice:3550
149+
- PROJECT_ID=local-dev
150+
- REGION=us-central1
151+
- ALLOYDB_DATABASE_NAME=local-db
152+
- ENABLE_PROFILER=0
153+
- ENABLE_TRACING=0
154+
depends_on:
155+
- productcatalogservice
156+
networks:
157+
- microservices-network
158+
159+
# Checkout Service
160+
checkoutservice:
161+
build:
162+
context: ./microservices-demo/src/checkoutservice
163+
dockerfile: Dockerfile
164+
container_name: checkoutservice
165+
ports:
166+
- "5050:5050"
167+
environment:
168+
- PORT=5050
169+
- PRODUCT_CATALOG_SERVICE_ADDR=productcatalogservice:3550
170+
- SHIPPING_SERVICE_ADDR=shippingservice:50051
171+
- PAYMENT_SERVICE_ADDR=paymentservice:50051
172+
- EMAIL_SERVICE_ADDR=emailservice:8080
173+
- CURRENCY_SERVICE_ADDR=currencyservice:7000
174+
- CART_SERVICE_ADDR=cartservice:7070
175+
- ENABLE_PROFILER=0
176+
- ENABLE_TRACING=0
177+
depends_on:
178+
- productcatalogservice
179+
- cartservice
180+
- currencyservice
181+
- shippingservice
182+
- emailservice
183+
- paymentservice
184+
networks:
185+
- microservices-network
186+
187+
# Frontend
188+
frontend:
189+
build:
190+
context: ./microservices-demo/src/frontend
191+
dockerfile: Dockerfile
192+
container_name: frontend
193+
ports:
194+
- "8080:8080"
195+
environment:
196+
- PORT=8080
197+
- PRODUCT_CATALOG_SERVICE_ADDR=productcatalogservice:3550
198+
- CURRENCY_SERVICE_ADDR=currencyservice:7000
199+
- CART_SERVICE_ADDR=cartservice:7070
200+
- RECOMMENDATION_SERVICE_ADDR=recommendationservice:8080
201+
- CHECKOUT_SERVICE_ADDR=checkoutservice:5050
202+
- SHIPPING_SERVICE_ADDR=shippingservice:50051
203+
- AD_SERVICE_ADDR=adservice:9555
204+
- SHOPPING_ASSISTANT_SERVICE_ADDR=shoppingassistantservice:8080
205+
- ENABLE_PROFILER=0
206+
- ENABLE_TRACING=0
207+
depends_on:
208+
- productcatalogservice
209+
- currencyservice
210+
- cartservice
211+
- recommendationservice
212+
- checkoutservice
213+
- shippingservice
214+
- adservice
215+
- shoppingassistantservice
216+
networks:
217+
- microservices-network
218+
219+
# Load Generator
220+
loadgenerator:
221+
build:
222+
context: ./microservices-demo/src/loadgenerator
223+
dockerfile: Dockerfile
224+
container_name: loadgenerator
225+
environment:
226+
- FRONTEND_ADDR=frontend:8080
227+
- USERS=10
228+
- RATE=1
229+
command: ["-f", "locustfile.py", "--host", "http://frontend:8080", "--headless", "-u", "10", "-r", "1"]
230+
depends_on:
231+
- frontend
232+
networks:
233+
- microservices-network
234+
235+
networks:
236+
microservices-network:
237+
driver: bridge

microservices-demo/src/adservice/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=$BUILDPLATFORM gradle:ubi-minimal AS build
1+
FROM --platform=$BUILDPLATFORM gradle:8.5-jdk21 AS build
22

33
ARG TARGETOS=linux
44
ARG TARGETARCH=x64

microservices-demo/src/currencyservice/Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ ARG TARGETARCH=x64
66
WORKDIR /app
77
COPY package*.json ./
88

9-
RUN npm ci --only=production
9+
RUN npm install --only=production
1010

1111
COPY server.js ./
1212
COPY proto ./proto
13+
COPY data ./data
1314

1415
FROM gcr.io/distroless/nodejs14-debian11 AS runtime
1516

1617
WORKDIR /app
17-
COPY --chown=1000:1000 . .
18+
COPY --chown=1000:1000 --from=build /app/node_modules ./node_modules
19+
COPY --chown=1000:1000 --from=build /app/server.js ./server.js
20+
COPY --chown=1000:1000 --from=build /app/proto ./proto
21+
COPY --chown=1000:1000 --from=build /app/data ./data
1822

1923
EXPOSE 7000
2024
USER 1000:1000

0 commit comments

Comments
 (0)