diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index b4b09d4197..aa0ac093e4 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -55,6 +55,10 @@ jobs: tag_suffix: emailservice context: ./src/emailservice setup-qemu: true + - file: ./src/ffspostgres/Dockerfile + tag_suffix: ffspostgres + context: ./ + setup-qemu: true # NOTE: # https://github.com/open-telemetry/opentelemetry-demo/issues/956 # Until dedicated ARM runners are available for GHA we cannot upgrade diff --git a/CHANGELOG.md b/CHANGELOG.md index c9180928f4..90e51e67d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ release. ([#1333](https://github.com/open-telemetry/opentelemetry-demo/pull/1333)) * [currency] fix metric exporter options ([#1335](https://github.com/open-telemetry/opentelemetry-demo/pull/1335)) +* [ffspostgres] define and use demo specific postgres image + ([#1338](https://github.com/open-telemetry/opentelemetry-demo/pull/1338)) ## 1.7.2 diff --git a/docker-compose.yml b/docker-compose.yml index d1d662ac94..79fcfb69b0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -228,11 +228,11 @@ services: - OTEL_EXPORTER_OTLP_ENDPOINT - OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc - OTEL_SERVICE_NAME=featureflagservice - - DATABASE_URL=ecto://ffs:ffs@ffs_postgres:5432/ffs + - DATABASE_URL=ecto://ffs:ffs@ffspostgres:5432/ffs healthcheck: test: ["CMD", "curl", "-H", "baggage: synthetic_request=true", "-f", "http://localhost:${FEATURE_FLAG_SERVICE_PORT}"] depends_on: - ffs_postgres: + ffspostgres: condition: service_healthy logging: *logging @@ -540,10 +540,14 @@ services: # Dependent Services # ****************** # Postgres used by Feature Flag service - ffs_postgres: - image: postgres:16.1 - container_name: postgres - user: postgres + ffspostgres: + image: ${IMAGE_NAME}:${IMAGE_VERSION}-ffspostgres + container_name: ffs-postgres + build: + context: ./ + dockerfile: ./src/ffspostgres/Dockerfile + cache_from: + - ${IMAGE_NAME}:${IMAGE_VERSION}-ffspostgres deploy: resources: limits: @@ -554,8 +558,7 @@ services: - POSTGRES_DB=ffs - POSTGRES_PASSWORD=ffs volumes: - - ./src/ffs_postgres/10-ffs_schema.sql:/docker-entrypoint-initdb.d/10-ffs_schema.sql - - ./src/ffs_postgres/20-ffs_data.sql:/docker-entrypoint-initdb.d/20-ffs_data.sql + - ./src/ffspostgres/update-scripts/99-ffs_update.sql:/docker-entrypoint-initdb.d/99-ffs_update.sql healthcheck: test: ["CMD-SHELL", "pg_isready -d ffs -U ffs"] interval: 10s diff --git a/src/ffspostgres/Dockerfile b/src/ffspostgres/Dockerfile new file mode 100644 index 0000000000..d996642d4f --- /dev/null +++ b/src/ffspostgres/Dockerfile @@ -0,0 +1,10 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +FROM postgres:16.1-alpine + +COPY ./src/ffspostgres/init-scripts/ /docker-entrypoint-initdb.d/ + +EXPOSE 5432 +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["postgres"] diff --git a/src/ffs_postgres/10-ffs_schema.sql b/src/ffspostgres/init-scripts/10-ffs_schema.sql similarity index 100% rename from src/ffs_postgres/10-ffs_schema.sql rename to src/ffspostgres/init-scripts/10-ffs_schema.sql diff --git a/src/ffs_postgres/20-ffs_data.sql b/src/ffspostgres/init-scripts/20-ffs_data.sql similarity index 66% rename from src/ffs_postgres/20-ffs_data.sql rename to src/ffspostgres/init-scripts/20-ffs_data.sql index ceca419128..700e993236 100644 --- a/src/ffs_postgres/20-ffs_data.sql +++ b/src/ffspostgres/init-scripts/20-ffs_data.sql @@ -2,11 +2,6 @@ -- SPDX-License-Identifier: Apache-2.0 -- Feature Flags created and initialized on startup --- 'enabled' is a decimal value between 0 and 1 (inclusive) --- 0.0 is always disabled --- 1.0 is always enabled --- All values between set a percentage chance on each request --- example: 0.55 is enabled 55% of the time INSERT INTO public.featureflags (name, description, enabled) VALUES ('productCatalogFailure', 'Fail product catalog service on a specific product', 0), diff --git a/src/ffspostgres/update-scripts/99-ffs_update.sql b/src/ffspostgres/update-scripts/99-ffs_update.sql new file mode 100644 index 0000000000..b66516e954 --- /dev/null +++ b/src/ffspostgres/update-scripts/99-ffs_update.sql @@ -0,0 +1,12 @@ +-- Copyright The OpenTelemetry Authors +-- SPDX-License-Identifier: Apache-2.0 + +-- Feature Flags updated for startup +-- 'enabled' is a decimal value between 0 and 1 (inclusive) +-- 0.0 is always disabled +-- 1.0 is always enabled +-- All values between set a percentage chance on each request +-- example: 0.55 is enabled 55% of the time + +-- UPDATE public.featureflags SET enabled = 0.55 WHERE name = 'cartServiceFailure'; +