Skip to content

Commit ec8f582

Browse files
committed
Update Dockerfile and docker-compose.yaml
1 parent 29e760c commit ec8f582

File tree

3 files changed

+31
-38
lines changed

3 files changed

+31
-38
lines changed

Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ FROM base_builder AS http_builder
6161
RUN --mount=type=cache,target=~/.cache/uv \
6262
uv sync --no-dev --group http --no-install-project --frozen --no-editable
6363

64+
# Installs requirements to run production http application
65+
FROM base_builder AS socketio_builder
66+
RUN --mount=type=cache,target=~/.cache/uv \
67+
uv sync --no-dev --group socketio --no-install-project --frozen --no-editable
68+
6469
# Create the base app with the common python packages
6570
FROM base AS base_app
6671
USER nonroot
@@ -75,7 +80,14 @@ FROM base_app AS http_app
7580
COPY --from=http_builder /venv /venv
7681
COPY --chown=nonroot:nonroot src/http_app ./http_app
7782
# Run CMD using array syntax, so it's uses `exec` and runs as PID1
78-
CMD ["opentelemetry-instrument", "uvicorn", "http_app:create_app", "--host", "0.0.0.0", "--port", "8000", "--factory"]
83+
CMD ["opentelemetry-instrument", "python", "-m", "http_app"]
84+
85+
# Copy the socketio python package and requirements from relevant builder
86+
FROM base_app AS socketio_app
87+
COPY --from=socketio_builder_builder /venv /venv
88+
COPY --chown=nonroot:nonroot src/socketio_app ./socketio_app
89+
# Run CMD using array syntax, so it's uses `exec` and runs as PID1
90+
CMD ["opentelemetry-instrument", "python", "-m", "socketio_app"]
7991

8092
# Copy the dramatiq python package and requirements from relevant builder
8193
FROM base_app AS dramatiq_app

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ containers:
88
# To build shared container layers only once we build a single container before the other ones
99
docker compose build --build-arg UID=`id -u`
1010

11-
dev:
12-
uv run uvicorn http_app:create_app --host 0.0.0.0 --port 8000 --factory --reload
11+
dev-http:
12+
uv run ./src/http_app/dev_server.py
13+
14+
dev-socketio:
15+
uv run ./src/socketio_app/dev_server.py
1316

1417
otel:
1518
OTEL_SERVICE_NAME=bootstrap-fastapi OTEL_TRACES_EXPORTER=none OTEL_METRICS_EXPORTER=none OTEL_LOGS_EXPORTER=none uv run opentelemetry-instrument uvicorn http_app:create_app --host 0.0.0.0 --port 8000 --factory

docker-compose.yaml

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
services:
2-
dev:
2+
dev-http: &dev
33
build:
44
dockerfile: Dockerfile
55
context: .
@@ -13,28 +13,23 @@ services:
1313
volumes:
1414
- '.:/app'
1515
depends_on:
16+
- redis
1617
- otel-collector
1718
command:
1819
- opentelemetry-instrument
1920
- python
2021
- ./http_app/dev_server.py
2122

22-
23-
# Production image
24-
http:
25-
build:
26-
dockerfile: Dockerfile
27-
context: .
28-
target: http_app
29-
depends_on:
30-
- otel-collector
31-
env_file: local.env
23+
dev-socketio:
24+
<<: *dev
3225
environment:
33-
OTEL_SERVICE_NAME: "bootstrap-fastapi-http"
26+
OTEL_SERVICE_NAME: "bootstrap-socketio-dev"
3427
ports:
35-
- '8001:8000'
36-
volumes:
37-
- './src/sqlite.db:/app/sqlite.db'
28+
- '8001:8001'
29+
command:
30+
- opentelemetry-instrument
31+
- python
32+
- ./socketio_app/dev_server.py
3833

3934
#########################
4035
#### Helper services ####
@@ -49,19 +44,10 @@ services:
4944
image: redis
5045

5146
dramatiq-worker:
52-
build:
53-
dockerfile: Dockerfile
54-
context: .
55-
target: dramatiq_app
56-
env_file: local.env
47+
<<: *dev
5748
environment:
5849
OTEL_SERVICE_NAME: "bootstrap-fastapi-dramatiq-worker"
59-
working_dir: "/app/src"
60-
volumes:
61-
- '.:/app'
62-
depends_on:
63-
- redis
64-
- otel-collector
50+
ports: []
6551
command:
6652
- opentelemetry-instrument
6753
- dramatiq
@@ -128,7 +114,7 @@ services:
128114
depends_on:
129115
- kratos
130116
- auth-ui
131-
- dev
117+
- dev-http
132118
ports:
133119
# Public traffic port
134120
- "8080:4455"
@@ -155,11 +141,3 @@ services:
155141
- "make"
156142
- "test"
157143

158-
ci-test:
159-
build:
160-
dockerfile: Dockerfile
161-
context: .
162-
target: dev
163-
command:
164-
- "make"
165-
- "ci-test"

0 commit comments

Comments
 (0)