Skip to content

Commit 9ed7785

Browse files
[postgres] Define and use image for postgres (#1338)
* define and use postgres image Signed-off-by: Pierre Tessier <[email protected]> * define and use postgres image Signed-off-by: Pierre Tessier <[email protected]> * define and use postgres image Signed-off-by: Pierre Tessier <[email protected]> * add postgres image Signed-off-by: Pierre Tessier <[email protected]> --------- Signed-off-by: Pierre Tessier <[email protected]> Co-authored-by: Juliano Costa <[email protected]>
1 parent 0d9cf78 commit 9ed7785

File tree

7 files changed

+39
-13
lines changed

7 files changed

+39
-13
lines changed

.github/workflows/build-images.yml

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ jobs:
5555
tag_suffix: emailservice
5656
context: ./src/emailservice
5757
setup-qemu: true
58+
- file: ./src/ffspostgres/Dockerfile
59+
tag_suffix: ffspostgres
60+
context: ./
61+
setup-qemu: true
5862
# NOTE:
5963
# https://github.com/open-telemetry/opentelemetry-demo/issues/956
6064
# Until dedicated ARM runners are available for GHA we cannot upgrade

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ release.
1515
([#1333](https://github.com/open-telemetry/opentelemetry-demo/pull/1333))
1616
* [currency] fix metric exporter options
1717
([#1335](https://github.com/open-telemetry/opentelemetry-demo/pull/1335))
18+
* [ffspostgres] define and use demo specific postgres image
19+
([#1338](https://github.com/open-telemetry/opentelemetry-demo/pull/1338))
1820

1921
## 1.7.2
2022

docker-compose.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ services:
228228
- OTEL_EXPORTER_OTLP_ENDPOINT
229229
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc
230230
- OTEL_SERVICE_NAME=featureflagservice
231-
- DATABASE_URL=ecto://ffs:ffs@ffs_postgres:5432/ffs
231+
- DATABASE_URL=ecto://ffs:ffs@ffspostgres:5432/ffs
232232
healthcheck:
233233
test: ["CMD", "curl", "-H", "baggage: synthetic_request=true", "-f", "http://localhost:${FEATURE_FLAG_SERVICE_PORT}"]
234234
depends_on:
235-
ffs_postgres:
235+
ffspostgres:
236236
condition: service_healthy
237237
logging: *logging
238238

@@ -540,10 +540,14 @@ services:
540540
# Dependent Services
541541
# ******************
542542
# Postgres used by Feature Flag service
543-
ffs_postgres:
544-
image: postgres:16.1
545-
container_name: postgres
546-
user: postgres
543+
ffspostgres:
544+
image: ${IMAGE_NAME}:${IMAGE_VERSION}-ffspostgres
545+
container_name: ffs-postgres
546+
build:
547+
context: ./
548+
dockerfile: ./src/ffspostgres/Dockerfile
549+
cache_from:
550+
- ${IMAGE_NAME}:${IMAGE_VERSION}-ffspostgres
547551
deploy:
548552
resources:
549553
limits:
@@ -554,8 +558,7 @@ services:
554558
- POSTGRES_DB=ffs
555559
- POSTGRES_PASSWORD=ffs
556560
volumes:
557-
- ./src/ffs_postgres/10-ffs_schema.sql:/docker-entrypoint-initdb.d/10-ffs_schema.sql
558-
- ./src/ffs_postgres/20-ffs_data.sql:/docker-entrypoint-initdb.d/20-ffs_data.sql
561+
- ./src/ffspostgres/update-scripts/99-ffs_update.sql:/docker-entrypoint-initdb.d/99-ffs_update.sql
559562
healthcheck:
560563
test: ["CMD-SHELL", "pg_isready -d ffs -U ffs"]
561564
interval: 10s

src/ffspostgres/Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
FROM postgres:16.1-alpine
5+
6+
COPY ./src/ffspostgres/init-scripts/ /docker-entrypoint-initdb.d/
7+
8+
EXPOSE 5432
9+
ENTRYPOINT ["docker-entrypoint.sh"]
10+
CMD ["postgres"]

src/ffs_postgres/20-ffs_data.sql src/ffspostgres/init-scripts/20-ffs_data.sql

-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
-- SPDX-License-Identifier: Apache-2.0
33

44
-- Feature Flags created and initialized on startup
5-
-- 'enabled' is a decimal value between 0 and 1 (inclusive)
6-
-- 0.0 is always disabled
7-
-- 1.0 is always enabled
8-
-- All values between set a percentage chance on each request
9-
-- example: 0.55 is enabled 55% of the time
105
INSERT INTO public.featureflags (name, description, enabled)
116
VALUES
127
('productCatalogFailure', 'Fail product catalog service on a specific product', 0),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Copyright The OpenTelemetry Authors
2+
-- SPDX-License-Identifier: Apache-2.0
3+
4+
-- Feature Flags updated for startup
5+
-- 'enabled' is a decimal value between 0 and 1 (inclusive)
6+
-- 0.0 is always disabled
7+
-- 1.0 is always enabled
8+
-- All values between set a percentage chance on each request
9+
-- example: 0.55 is enabled 55% of the time
10+
11+
-- UPDATE public.featureflags SET enabled = 0.55 WHERE name = 'cartServiceFailure';
12+

0 commit comments

Comments
 (0)