Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[postgres] Define and use image for postgres #1338

Merged
merged 5 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 11 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/ffspostgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
12 changes: 12 additions & 0 deletions src/ffspostgres/update-scripts/99-ffs_update.sql
Original file line number Diff line number Diff line change
@@ -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';

Loading