Skip to content

Commit

Permalink
proper multistage build
Browse files Browse the repository at this point in the history
  • Loading branch information
squi-ddy committed Nov 28, 2023
1 parent 5a8f490 commit 50559f4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
FROM python:3.10-alpine
FROM python:3.10-alpine AS build

WORKDIR /server
RUN apk add --no-cache --virtual build-deps pkgconf mariadb-dev gcc musl-dev
COPY . .

RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

COPY requirements.txt .
RUN pip install -r requirements.txt
RUN apk del build-deps


FROM python:3.10-alpine AS runtime

WORKDIR /server
RUN apk add --no-cache mariadb-connector-c

COPY --from=build /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

COPY . .
EXPOSE 5000
CMD ["python", "-m", "app"]

0 comments on commit 50559f4

Please sign in to comment.