Skip to content

Commit

Permalink
Fix Dockerfile
Browse files Browse the repository at this point in the history
virtualenv was not activated in run stage
  • Loading branch information
tsundvoll committed Feb 16, 2024
1 parent 2e32cf8 commit 576a7bb
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
FROM python:3.10-slim AS builder

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 python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Install dependencies before ISAR to cache pip installation
RUN mkdir -p src
COPY setup.py README.md ./
COPY . .
RUN pip install .

# Install the base isar-robot package
RUN pip install isar-robot

COPY . .

RUN pip install .

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

WORKDIR /app
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

EXPOSE 3000

# Env variable for ISAR to know it is running in docker
ENV IS_DOCKER=true

# # Add non-root user
# Add non-root user
RUN useradd --create-home --shell /bin/bash 1000
RUN chown -R 1000 /app
RUN chmod 755 /app
USER 1000

COPY . .
CMD python main.py

0 comments on commit 576a7bb

Please sign in to comment.