Skip to content

Commit

Permalink
Add multi-stage build for Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
tsundvoll committed Jan 19, 2024
1 parent 39d9c6d commit 531699e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
FROM python:3.10.13-slim-bookworm
FROM python:3.10-slim AS base

WORKDIR /app
RUN apt-get update
RUN apt-get install -y --no-install-recommends build-essential gcc
RUN python -m pip install --upgrade pip

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

RUN apt-get update
RUN apt-get install gcc python3-dev -y
RUN python -m pip install --upgrade pip

# Install dependencies before ISAR to cache pip installation
RUN mkdir -p src
COPY setup.py README.md ./
Expand All @@ -22,6 +20,12 @@ COPY . .

RUN pip install .

FROM python:3.10-slim
COPY --from=base $VIRTUAL_ENV $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

WORKDIR /app

EXPOSE 3000

# Env variable for ISAR to know it is running in docker
Expand Down

0 comments on commit 531699e

Please sign in to comment.