Skip to content

Commit

Permalink
chore: parametrize services Dockerfile path (open-telemetry#1600)
Browse files Browse the repository at this point in the history
* chore: parametrize services Dockerfile path

* chore: add ad service relative path

* chore: add services path as environment variable

* ci: fix emailservice context build

* remove unused *_PATH environment variable

---------

Co-authored-by: Juliano Costa <julianocosta89@outlook.com>
  • Loading branch information
rogercoll and julianocosta89 committed Jun 19, 2024
1 parent c0fa17f commit 8a211c0
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 33 deletions.
20 changes: 20 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,52 @@ OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative
# ******************
# Core Demo Services
# ******************
# Accounting Service
ACCOUNTING_SERVICE_DOCKERFILE=./src/accountingservice/Dockerfile

# Ad Service
AD_SERVICE_PORT=9555
AD_SERVICE_ADDR=adservice:${AD_SERVICE_PORT}
AD_SERVICE_DOCKERFILE=./src/adservice/Dockerfile

# Cart Service
CART_SERVICE_PORT=7070
CART_SERVICE_ADDR=cartservice:${CART_SERVICE_PORT}
CART_SERVICE_DOCKERFILE=./src/cartservice/src/Dockerfile

# Checkout Service
CHECKOUT_SERVICE_PORT=5050
CHECKOUT_SERVICE_ADDR=checkoutservice:${CHECKOUT_SERVICE_PORT}
CHECKOUT_SERVICE_DOCKERFILE=./src/checkoutservice/Dockerfile

# Currency Service
CURRENCY_SERVICE_PORT=7001
CURRENCY_SERVICE_ADDR=currencyservice:${CURRENCY_SERVICE_PORT}
CURRENCY_SERVICE_DOCKERFILE=./src/currencyservice/Dockerfile

# Email Service
EMAIL_SERVICE_PORT=6060
EMAIL_SERVICE_ADDR=http://emailservice:${EMAIL_SERVICE_PORT}
EMAIL_SERVICE_DOCKERFILE=./src/emailservice/Dockerfile

# Fraud Service
FRAUD_SERVICE_DOCKERFILE=./src/frauddetectionservice/Dockerfile

# Frontend
FRONTEND_PORT=8080
FRONTEND_ADDR=frontend:${FRONTEND_PORT}
FRONTEND_DOCKERFILE=./src/frontend/Dockerfile

# Frontend Proxy (Envoy)
FRONTEND_HOST=frontend
ENVOY_PORT=8080
FRONTEND_PROXY_ADDR=frontend-proxy:${ENVOY_PORT}
FRONTEND_PROXY_DOCKERFILE=./src/frontendproxy/Dockerfile

# Image Provider
IMAGE_PROVIDER_HOST=imageprovider
IMAGE_PROVIDER_PORT=8081
IMAGE_PROVIDER_DOCKERFILE=./src/imageprovider/Dockerfile

# Load Generator
LOCUST_WEB_PORT=8089
Expand All @@ -77,26 +91,32 @@ LOCUST_HOST=http://${FRONTEND_PROXY_ADDR}
LOCUST_WEB_HOST=loadgenerator
LOCUST_AUTOSTART=true
LOCUST_HEADLESS=false
LOAD_GENERATOR_DOCKERFILE=./src/loadgenerator/Dockerfile

# Payment Service
PAYMENT_SERVICE_PORT=50051
PAYMENT_SERVICE_ADDR=paymentservice:${PAYMENT_SERVICE_PORT}
PAYMENT_SERVICE_DOCKERFILE=./src/paymentservice/Dockerfile

# Product Catalog Service
PRODUCT_CATALOG_SERVICE_PORT=3550
PRODUCT_CATALOG_SERVICE_ADDR=productcatalogservice:${PRODUCT_CATALOG_SERVICE_PORT}
PRODUCT_CATALOG_DOCKERFILE=./src/productcatalogservice/Dockerfile

# Quote Service
QUOTE_SERVICE_PORT=8090
QUOTE_SERVICE_ADDR=http://quoteservice:${QUOTE_SERVICE_PORT}
QUOTE_SERVICE_DOCKERFILE=./src/quoteservice/Dockerfile

# Recommendation Service
RECOMMENDATION_SERVICE_PORT=9001
RECOMMENDATION_SERVICE_ADDR=recommendationservice:${RECOMMENDATION_SERVICE_PORT}
RECOMMENDATION_SERVICE_DOCKERFILE=./src/recommendationservice/Dockerfile

# Shipping Service
SHIPPING_SERVICE_PORT=50050
SHIPPING_SERVICE_ADDR=shippingservice:${SHIPPING_SERVICE_PORT}
SHIPPING_SERVICE_DOCKERFILE=./src/shippingservice/Dockerfile

# ******************
# Dependent Services
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/component_build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
setup-qemu: true
- file: ./src/emailservice/Dockerfile
tag_suffix: emailservice
context: ./src/emailservice
context: ./
setup-qemu: true
- file: ./src/frauddetectionservice/Dockerfile
tag_suffix: frauddetectionservice
Expand Down
26 changes: 13 additions & 13 deletions docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
container_name: ad-service
build:
context: ./
dockerfile: ./src/adservice/Dockerfile
dockerfile: ${AD_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-adservice
deploy:
Expand Down Expand Up @@ -53,7 +53,7 @@ services:
container_name: cart-service
build:
context: ./
dockerfile: ./src/cartservice/src/Dockerfile
dockerfile: ${CART_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-cartservice
deploy:
Expand Down Expand Up @@ -84,7 +84,7 @@ services:
container_name: checkout-service
build:
context: ./
dockerfile: ./src/checkoutservice/Dockerfile
dockerfile: ${CHECKOUT_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-checkoutservice
deploy:
Expand Down Expand Up @@ -130,7 +130,7 @@ services:
container_name: currency-service
build:
context: ./
dockerfile: ./src/currencyservice/Dockerfile
dockerfile: ${CURRENCY_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-currencyservice
deploy:
Expand Down Expand Up @@ -182,7 +182,7 @@ services:
container_name: frontend
build:
context: ./
dockerfile: ./src/frontend/Dockerfile
dockerfile: ${FRONTEND_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-frontend
deploy:
Expand Down Expand Up @@ -241,7 +241,7 @@ services:
container_name: frontend-proxy
build:
context: ./
dockerfile: src/frontendproxy/Dockerfile
dockerfile: ${FRONTEND_PROXY_DOCKERFILE}
deploy:
resources:
limits:
Expand Down Expand Up @@ -284,7 +284,7 @@ services:
container_name: imageprovider
build:
context: ./
dockerfile: ./src/imageprovider/Dockerfile
dockerfile: ${IMAGE_PROVIDER_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-imageprovider
deploy:
Expand All @@ -311,7 +311,7 @@ services:
container_name: load-generator
build:
context: ./
dockerfile: ./src/loadgenerator/Dockerfile
dockerfile: ${LOAD_GENERATOR_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-loadgenerator
deploy:
Expand Down Expand Up @@ -349,7 +349,7 @@ services:
container_name: payment-service
build:
context: ./
dockerfile: ./src/paymentservice/Dockerfile
dockerfile: ${PAYMENT_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-paymentservice
deploy:
Expand Down Expand Up @@ -377,7 +377,7 @@ services:
container_name: product-catalog-service
build:
context: ./
dockerfile: ./src/productcatalogservice/Dockerfile
dockerfile: ${PRODUCT_CATALOG_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-productcatalogservice
deploy:
Expand Down Expand Up @@ -405,7 +405,7 @@ services:
container_name: quote-service
build:
context: ./
dockerfile: ./src/quoteservice/Dockerfile
dockerfile: ${QUOTE_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-quoteservice
deploy:
Expand Down Expand Up @@ -433,7 +433,7 @@ services:
container_name: recommendation-service
build:
context: ./
dockerfile: ./src/recommendationservice/Dockerfile
dockerfile: ${RECOMMENDATION_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-recommendationservice
deploy:
Expand Down Expand Up @@ -466,7 +466,7 @@ services:
container_name: shipping-service
build:
context: ./
dockerfile: ./src/shippingservice/Dockerfile
dockerfile: ${SHIPPING_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-shippingservice
deploy:
Expand Down
35 changes: 18 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
container_name: accounting-service
build:
context: ./
dockerfile: ./src/accountingservice/Dockerfile
dockerfile: ${ACCOUNTING_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-accountingservice
deploy:
Expand All @@ -50,7 +50,7 @@ services:
container_name: ad-service
build:
context: ./
dockerfile: ./src/adservice/Dockerfile
dockerfile: ${AD_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-adservice
deploy:
Expand Down Expand Up @@ -82,7 +82,7 @@ services:
container_name: cart-service
build:
context: ./
dockerfile: ./src/cartservice/src/Dockerfile
dockerfile: ${CART_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-cartservice
deploy:
Expand Down Expand Up @@ -116,7 +116,7 @@ services:
container_name: checkout-service
build:
context: ./
dockerfile: ./src/checkoutservice/Dockerfile
dockerfile: ${CHECKOUT_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-checkoutservice
deploy:
Expand Down Expand Up @@ -168,7 +168,7 @@ services:
container_name: currency-service
build:
context: ./
dockerfile: ./src/currencyservice/Dockerfile
dockerfile: ${CURRENCY_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-currencyservice
deploy:
Expand All @@ -190,10 +190,11 @@ services:

# Email service
emailservice:
image: ${IMAGE_NAME}:${DEMO_VERSION}-emailservice
image: demo/emailservice-contrib:latest
container_name: email-service
build:
context: ./src/emailservice
context: ./
dockerfile: ${EMAIL_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-emailservice
deploy:
Expand All @@ -220,7 +221,7 @@ services:
container_name: frauddetection-service
build:
context: ./
dockerfile: ./src/frauddetectionservice/Dockerfile
dockerfile: ${FRAUD_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-frauddetectionservice
deploy:
Expand Down Expand Up @@ -251,7 +252,7 @@ services:
container_name: frontend
build:
context: ./
dockerfile: ./src/frontend/Dockerfile
dockerfile: ${FRONTEND_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-frontend
deploy:
Expand Down Expand Up @@ -312,7 +313,7 @@ services:
container_name: frontend-proxy
build:
context: ./
dockerfile: src/frontendproxy/Dockerfile
dockerfile: ${FRONTEND_PROXY_DOCKERFILE}
deploy:
resources:
limits:
Expand Down Expand Up @@ -355,7 +356,7 @@ services:
container_name: imageprovider
build:
context: ./
dockerfile: ./src/imageprovider/Dockerfile
dockerfile: ${IMAGE_PROVIDER_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-imageprovider
deploy:
Expand All @@ -382,7 +383,7 @@ services:
container_name: load-generator
build:
context: ./
dockerfile: ./src/loadgenerator/Dockerfile
dockerfile: ${LOAD_GENERATOR_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-loadgenerator
deploy:
Expand Down Expand Up @@ -420,7 +421,7 @@ services:
container_name: payment-service
build:
context: ./
dockerfile: ./src/paymentservice/Dockerfile
dockerfile: ${PAYMENT_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-paymentservice
deploy:
Expand Down Expand Up @@ -451,7 +452,7 @@ services:
container_name: product-catalog-service
build:
context: ./
dockerfile: ./src/productcatalogservice/Dockerfile
dockerfile: ${PRODUCT_CATALOG_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-productcatalogservice
deploy:
Expand Down Expand Up @@ -482,7 +483,7 @@ services:
container_name: quote-service
build:
context: ./
dockerfile: ./src/quoteservice/Dockerfile
dockerfile: ${QUOTE_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-quoteservice
deploy:
Expand Down Expand Up @@ -510,7 +511,7 @@ services:
container_name: recommendation-service
build:
context: ./
dockerfile: ./src/recommendationservice/Dockerfile
dockerfile: ${RECOMMENDATION_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-recommendationservice
deploy:
Expand Down Expand Up @@ -546,7 +547,7 @@ services:
container_name: shipping-service
build:
context: ./
dockerfile: ./src/shippingservice/Dockerfile
dockerfile: ${SHIPPING_SERVICE_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-shippingservice
deploy:
Expand Down
4 changes: 2 additions & 2 deletions src/emailservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ FROM base as builder

WORKDIR /tmp

COPY Gemfile Gemfile.lock .
COPY ./src/emailservice/Gemfile ./src/emailservice/Gemfile.lock ./

#RUN apk update && apk add make gcc musl-dev gcompat && bundle install
RUN apt-get update && apt-get install build-essential -y && bundle install
FROM base as release

WORKDIR /email_server

COPY . .
COPY ./src/emailservice/ .

RUN chmod 666 ./Gemfile.lock

Expand Down

0 comments on commit 8a211c0

Please sign in to comment.