Skip to content

Commit

Permalink
fix: dockerfile updated with multistage build
Browse files Browse the repository at this point in the history
Signed-off-by: Rajdeep Roy Chowdhury <[email protected]>
  • Loading branch information
Razdeep committed May 31, 2024
1 parent 32f616f commit 27ac73a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
FROM alpine:3.20.0
FROM alpine:3.20.0 as builder

RUN addgroup -S cfpredictorgroup && adduser -S cfpredictor -G cfpredictorgroup

WORKDIR /home/cfpredictor

COPY run.py requirements.txt /home/cfpredictor/
COPY app ./app

RUN apk add --update --no-cache python3 clang && \
RUN apk add --update --no-cache python3 clang python3-devel && \
python3 -m venv .venv && \
/home/cfpredictor/.venv/bin/python3 -m ensurepip --upgrade && \
/home/cfpredictor/.venv/bin/pip3 --no-cache install --upgrade pip setuptools && \
/home/cfpredictor/.venv/bin/pip3 --no-cache install -r requirements.txt

FROM alpine:3.20.0

RUN addgroup -S cfpredictorgroup && adduser -S cfpredictor -G cfpredictorgroup && \
apk add --update --no-cache python3

WORKDIR /home/cfpredictor

COPY --from=builder /home/cfpredictor/.venv/ /home/cfpredictor/.venv/
COPY run.py requirements.txt /home/cfpredictor/
COPY app ./app

USER cfpredictor

CMD ["python3", "run.py"]
CMD [".venv/bin/python3", "run.py"]

0 comments on commit 27ac73a

Please sign in to comment.