Skip to content

Commit b2f6fbf

Browse files
chore: introduce .env.override for docker-compose (open-telemetry#1584)
* chore: introduce .env.override for docker-compose * parametrize docker compose cmd and env files --------- Co-authored-by: Austin Parker <[email protected]>
1 parent 379cf62 commit b2f6fbf

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

.env.override

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT PUSH CHANGES OF THIS FILE TO opentelemetry/opentelemetry-demo
2+
# PLACE YOUR .env ENVIRONMENT VARIABLES OVERRIDES IN THIS FILE

Makefile

+24-21
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ TOOLS_DIR := ./internal/tools
1010
MISSPELL_BINARY=bin/misspell
1111
MISSPELL = $(TOOLS_DIR)/$(MISSPELL_BINARY)
1212

13+
DOCKER_COMPOSE_CMD ?= docker compose
14+
DOCKER_COMPOSE_ENV=--env-file .env --env-file .env.override
15+
1316
# see https://github.com/open-telemetry/build-tools/releases for semconvgen updates
1417
# Keep links in semantic_conventions/README.md and .vscode/settings.json in sync!
1518
SEMCONVGEN_VERSION=0.11.0
@@ -74,17 +77,17 @@ install-tools: $(MISSPELL)
7477

7578
.PHONY: build
7679
build:
77-
docker compose build
80+
$(DOCKER_COMPOSE_CMD) build
7881

7982
.PHONY: build-and-push-dockerhub
8083
build-and-push-dockerhub:
81-
docker compose --env-file .dockerhub.env -f docker-compose.yml build
82-
docker compose --env-file .dockerhub.env -f docker-compose.yml push
84+
$(DOCKER_COMPOSE_CMD) --env-file .dockerhub.env -f docker-compose.yml build
85+
$(DOCKER_COMPOSE_CMD) --env-file .dockerhub.env -f docker-compose.yml push
8386

8487
.PHONY: build-and-push-ghcr
8588
build-and-push-ghcr:
86-
docker compose --env-file .ghcr.env -f docker-compose.yml build
87-
docker compose --env-file .ghcr.env -f docker-compose.yml push
89+
$(DOCKER_COMPOSE_CMD) --env-file .ghcr.env -f docker-compose.yml build
90+
$(DOCKER_COMPOSE_CMD) --env-file .ghcr.env -f docker-compose.yml push
8891

8992
.PHONY: build-env-file
9093
build-env-file:
@@ -97,12 +100,12 @@ build-env-file:
97100

98101
.PHONY: run-tests
99102
run-tests:
100-
docker compose run frontendTests
101-
docker compose run traceBasedTests
103+
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) run frontendTests
104+
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) run traceBasedTests
102105

103106
.PHONY: run-tracetesting
104107
run-tracetesting:
105-
docker compose run traceBasedTests ${SERVICES_TO_TEST}
108+
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) run traceBasedTests ${SERVICES_TO_TEST}
106109

107110
.PHONY: generate-protobuf
108111
generate-protobuf:
@@ -124,7 +127,7 @@ generate-kubernetes-manifests:
124127

125128
.PHONY: start
126129
start:
127-
docker compose up --force-recreate --remove-orphans --detach
130+
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) up --force-recreate --remove-orphans --detach
128131
@echo ""
129132
@echo "OpenTelemetry Demo is running."
130133
@echo "Go to http://localhost:8080 for the demo UI."
@@ -135,7 +138,7 @@ start:
135138

136139
.PHONY: start-minimal
137140
start-minimal:
138-
docker compose -f docker-compose.minimal.yml up --force-recreate --remove-orphans --detach
141+
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) up -f docker-compose.minimal.yml up --force-recreate --remove-orphans --detach
139142
@echo ""
140143
@echo "OpenTelemetry Demo in minimal mode is running."
141144
@echo "Go to http://localhost:8080 for the demo UI."
@@ -147,7 +150,7 @@ start-minimal:
147150
# Observabilty-Driven Development (ODD)
148151
.PHONY: start-odd
149152
start-odd:
150-
docker compose --profile odd up --force-recreate --remove-orphans --detach
153+
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) --profile odd up --force-recreate --remove-orphans --detach
151154
@echo ""
152155
@echo "OpenTelemetry Demo is running."
153156
@echo "Go to http://localhost:8080 for the demo UI."
@@ -159,7 +162,7 @@ start-odd:
159162

160163
.PHONY: stop
161164
stop:
162-
docker compose --profile tests --profile odd down --remove-orphans --volumes
165+
$(DOCKER_COMPOSE_CMD) --profile tests --profile odd down --remove-orphans --volumes
163166
@echo ""
164167
@echo "OpenTelemetry Demo is stopped."
165168

@@ -173,10 +176,10 @@ ifdef SERVICE
173176
endif
174177

175178
ifdef service
176-
docker compose stop $(service)
177-
docker compose rm --force $(service)
178-
docker compose create $(service)
179-
docker compose start $(service)
179+
$(DOCKER_COMPOSE_CMD) stop $(service)
180+
$(DOCKER_COMPOSE_CMD) rm --force $(service)
181+
$(DOCKER_COMPOSE_CMD) create $(service)
182+
$(DOCKER_COMPOSE_CMD) start $(service)
180183
else
181184
@echo "Please provide a service name using `service=[service name]` or `SERVICE=[service name]`"
182185
endif
@@ -191,11 +194,11 @@ ifdef SERVICE
191194
endif
192195

193196
ifdef service
194-
docker compose build $(service)
195-
docker compose stop $(service)
196-
docker compose rm --force $(service)
197-
docker compose create $(service)
198-
docker compose start $(service)
197+
$(DOCKER_COMPOSE_CMD) build $(service)
198+
$(DOCKER_COMPOSE_CMD) stop $(service)
199+
$(DOCKER_COMPOSE_CMD) rm --force $(service)
200+
$(DOCKER_COMPOSE_CMD) create $(service)
201+
$(DOCKER_COMPOSE_CMD) start $(service)
199202
else
200203
@echo "Please provide a service name using `service=[service name]` or `SERVICE=[service name]`"
201204
endif

0 commit comments

Comments
 (0)