Skip to content

Commit

Permalink
maint: docker file regular user (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixKuhnAnsys authored Sep 30, 2024
1 parent 5f28281 commit af3c917
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
FROM python:3.12-slim

# Create a non-root user and group
RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser

# Set the home directory for the non-root user
ENV HOME=/home/appuser
ENV PATH="$HOME/.local/bin:$PATH"

# Set the working directory
WORKDIR /app

# Copy the app folder and the config.yaml file
COPY src /app
# Set the ownership of the /app directory to the non-root user
RUN chown -R appuser:appgroup /app

# Copy the application files and config.yaml, setting ownership to the non-root user
COPY --chown=appuser:appgroup src /app
COPY --chown=appuser:appgroup README.md /app
COPY --chown=appuser:appgroup pyproject.toml /app
COPY --chown=appuser:appgroup configs/config.yaml /app

# readme required by pip
COPY README.md /app
COPY pyproject.toml /app
COPY configs/config.yaml /app
# Switch to the non-root user
USER appuser

# Install dependencies
RUN echo $(ls)
RUN pip install --no-cache-dir .[all]
# Create a virtual environment and install dependencies inside it
RUN python -m venv /app/venv \
&& . /app/venv/bin/activate \
&& pip install --upgrade pip \
&& pip install --no-cache-dir .[all]

# Expose the port that the service will listen on
EXPOSE 50052

# Use the environment variable in CMD
CMD ["sh", "-c", "allie-flowkit-python"]
# Activate the virtual environment and run the service
CMD ["/bin/sh", "-c", ". /app/venv/bin/activate && allie-flowkit-python"]

0 comments on commit af3c917

Please sign in to comment.