Skip to content

Commit c611689

Browse files
committed
feat/refactor: revert changes to docker entry point, supply MONITORING arg to Dockerfile and github action
1 parent d9e3299 commit c611689

File tree

4 files changed

+29
-31
lines changed

4 files changed

+29
-31
lines changed

.github/workflows/build_and_deploy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ jobs:
2020
context: ./src/backend
2121
build_target: service
2222
image_name: ghcr.io/${{ github.repository }}/backend
23-
dockerfile: Dockerfile
2423
scan_image: false
24+
extra_build_args: |
25+
MONITORING=${{ secrets.MONITORING }}
2526
secrets: inherit
2627

2728
extra-vars:

compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ services:
1616
build:
1717
context: src/backend
1818
dockerfile: Dockerfile
19+
args:
20+
- MONITORING=${MONITORING}
1921
depends_on:
2022
- db
2123
- minio

src/backend/Dockerfile

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ RUN set -ex \
99
&& apt-get update \
1010
&& DEBIAN_FRONTEND=noninteractive apt-get install \
1111
-y --no-install-recommends \
12-
"build-essential" \
13-
"gcc" \
14-
"g++" \
15-
"libpcre2-dev" \
16-
"libpq-dev" \
17-
"libspatialindex-dev" \
18-
"libproj-dev" \
19-
"libgeos-dev" \
20-
"libgdal-dev" \
21-
"git" \
12+
"build-essential" \
13+
"gcc" \
14+
"g++" \
15+
"libpcre2-dev" \
16+
"libpq-dev" \
17+
"libspatialindex-dev" \
18+
"libproj-dev" \
19+
"libgeos-dev" \
20+
"libgdal-dev" \
21+
"git" \
2222
&& rm -rf /var/lib/apt/lists/*
2323

2424
WORKDIR /project
@@ -50,11 +50,19 @@ STOPSIGNAL SIGINT
5050
COPY ./pyproject.toml ./alembic.ini ./uv.lock /project/
5151
COPY packages /project/packages
5252

53+
ARG MONITORING
54+
5355
# Install dependencies using uv (caching to improve speed for repeated builds)
5456
RUN --mount=type=cache,target=/root/.cache/uv \
5557
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
56-
--mount=type=bind,source=uv.lock,target=uv.lock \
57-
uv sync --locked --no-editable --no-dev
58+
--mount=type=bind,source=uv.lock,target=uv.lock <<EOT
59+
set -e
60+
EXTRA_GROUPS=""
61+
if [ "$MONITORING" = "sentry" ]; then
62+
EXTRA_GROUPS="--group monitoring"
63+
fi
64+
uv sync --locked --no-editable --no-dev $EXTRA_GROUPS
65+
EOT
5866

5967
# Run stage (final stage)
6068
FROM python:$PYTHON_IMG_TAG-slim-trixie AS service
@@ -70,9 +78,9 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
7078
CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
7179

7280
RUN set -ex \
73-
&& apt-get update \
74-
&& DEBIAN_FRONTEND=noninteractive apt-get install \
75-
-y --no-install-recommends \
81+
&& apt-get update \
82+
&& DEBIAN_FRONTEND=noninteractive apt-get install \
83+
-y --no-install-recommends \
7684
"nano" \
7785
"curl" \
7886
"gettext-base" \
@@ -85,7 +93,7 @@ RUN set -ex \
8593
"libproj25" \
8694
"libgeos-c1t64" \
8795
"libgdal36" \
88-
&& rm -rf /var/lib/apt/lists/*
96+
&& rm -rf /var/lib/apt/lists/*
8997

9098
# Retrieve global Python packages and dependencies from the build stage
9199
COPY --from=build /opt/python /opt/python

src/backend/docker-entrypoint.sh

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22

33
set -eo pipefail
44

5-
# Function to install monitoring dependencies if MONITORING is set
6-
install_monitoring_deps() {
7-
if [ "$MONITORING" = "sentry" ]; then
8-
echo "Installing monitoring dependencies..."
9-
uv sync --locked --no-editable --no-dev --group monitoring
10-
else
11-
echo "MONITORING is blank/invalid, skipping installation of monitoring dependencies."
12-
fi
13-
}
14-
155
wait_for_db() {
166
max_retries=30
177
retry_interval=5
@@ -29,13 +19,10 @@ wait_for_db() {
2919
exit 1 # Exit with an error code
3020
}
3121

32-
# Install monitoring dependencies
33-
install_monitoring_deps
34-
3522
# Start wait in background with tmp log files
3623
wait_for_db &
3724
wait
3825

3926
exec "$@"
4027

41-
exit 0
28+
exit 0

0 commit comments

Comments
 (0)