From 8a211c02047846dae50babfdddddc1e291aff0b0 Mon Sep 17 00:00:00 2001 From: Roger Coll Date: Wed, 19 Jun 2024 14:08:00 +0200 Subject: [PATCH] chore: parametrize services Dockerfile path (#1600) * 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 --- .env | 20 +++++++++++ .github/workflows/component_build-images.yml | 2 +- docker-compose.minimal.yml | 26 +++++++-------- docker-compose.yml | 35 ++++++++++---------- src/emailservice/Dockerfile | 4 +-- 5 files changed, 54 insertions(+), 33 deletions(-) diff --git a/.env b/.env index 4b9d67b285..dd86d9dbe2 100644 --- a/.env +++ b/.env @@ -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 @@ -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 diff --git a/.github/workflows/component_build-images.yml b/.github/workflows/component_build-images.yml index e908ec6f79..510d1e0de1 100644 --- a/.github/workflows/component_build-images.yml +++ b/.github/workflows/component_build-images.yml @@ -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 diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml index 1e1b89aa63..8d1fa8961b 100644 --- a/docker-compose.minimal.yml +++ b/docker-compose.minimal.yml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -241,7 +241,7 @@ services: container_name: frontend-proxy build: context: ./ - dockerfile: src/frontendproxy/Dockerfile + dockerfile: ${FRONTEND_PROXY_DOCKERFILE} deploy: resources: limits: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/docker-compose.yml b/docker-compose.yml index 2e00a3232c..2ddfa71221 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -312,7 +313,7 @@ services: container_name: frontend-proxy build: context: ./ - dockerfile: src/frontendproxy/Dockerfile + dockerfile: ${FRONTEND_PROXY_DOCKERFILE} deploy: resources: limits: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/src/emailservice/Dockerfile b/src/emailservice/Dockerfile index 3bba376281..b3bb161afe 100644 --- a/src/emailservice/Dockerfile +++ b/src/emailservice/Dockerfile @@ -8,7 +8,7 @@ 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 @@ -16,7 +16,7 @@ FROM base as release WORKDIR /email_server -COPY . . +COPY ./src/emailservice/ . RUN chmod 666 ./Gemfile.lock