33ARG PUSH_SENTRY_RELEASE="false"
44
55# Build step #1: build the React front end
6- FROM node:22 -alpine AS build-step
6+ FROM node:23 -alpine AS build-step
77ARG SENTRY_RELEASE=""
88WORKDIR /app
99ENV PATH=/app/node_modules/.bin:$PATH
@@ -31,17 +31,27 @@ RUN sentry-cli releases finalize ${SENTRY_RELEASE}
3131RUN touch sentry
3232
3333# Build step #3: build the API with the client as static files
34- FROM python:3.13 AS false
34+ FROM python:3.13-alpine AS api-build
3535ARG SENTRY_RELEASE=""
3636WORKDIR /app
37+
38+ # Install required system dependencies
39+ RUN apk add --no-cache python3 py3-pip py3-virtualenv
40+
41+ # Create a virtual environment for the application
42+ RUN python3 -m venv /app/venv
43+ ENV PATH="/app/venv/bin:$PATH"
44+
3745COPY --from=build-step /app/build ./build
3846
3947RUN rm ./build/static/js/*.map
4048RUN mkdir ./api && mkdir ./migrations
4149COPY requirements.txt api/ ./api/
4250COPY migrations/ ./migrations/
4351COPY ./config ./config
44- RUN pip install -r ./api/requirements.txt
52+
53+ # Install dependencies inside the virtual environment
54+ RUN pip install --no-cache-dir -r ./api/requirements.txt
4555
4656# Build an image that includes the optional sentry release push build step
4757FROM false AS true
@@ -55,6 +65,9 @@ ENV FLASK_ENV=production
5565ENV FLASK_APP=api.app:create_app
5666ENV SENTRY_RELEASE=$SENTRY_RELEASE
5767
68+ # Ensure Flask uses the virtual environment
69+ ENV PATH="/app/venv/bin:$PATH"
70+
5871EXPOSE 3000
5972
6073CMD ["gunicorn" , "-w" , "4" , "-t" , "600" , "-b" , ":3000" , "--access-logfile" , "-" , "api.wsgi:app" ]
0 commit comments