Skip to content

Commit

Permalink
build: use non-root privilege in container
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalmhjn committed Oct 25, 2024
1 parent 00a8332 commit 43f63ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,28 @@ FROM python:${PYTHON_VERSION}-slim as base
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /app
RUN groupadd -r modeler && useradd -r -g modeler modeler

ENV HOME=/home/modeler

USER modeler

WORKDIR $HOME

# Install dependencies
COPY requirements.txt .
RUN python -m pip install -r requirements.txt
COPY --chown=modeler:modeler requirements.txt .
RUN python -m pip install --user -r requirements.txt

# Copy the application files
COPY . .
COPY --chown=modeler:modeler . .

# Create folder for saving outputs
RUN mkdir ./predictions
RUN mkdir ./model_output

# Expose the application port
EXPOSE 5000

WORKDIR /app/src
WORKDIR $HOME/src

CMD ["sh", "-c", "python main.py -t -m knn && python app.py"]
4 changes: 1 addition & 3 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

volumes:
traffic-volume:
name: "traffic-volume"
Expand All @@ -13,7 +11,7 @@ services:
ports:
- "5000:5000"
volumes:
- traffic-volume:/app
- traffic-volume:/home/modeler
container_name: traffic-app
stdin_open: true
tty: true

0 comments on commit 43f63ec

Please sign in to comment.