-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
37 lines (28 loc) · 931 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
FROM python:3.12
# Install required packages
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
sudo\
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Create a non-root user
RUN useradd --create-home appuser \
&& echo "appuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/appuser \
&& chmod 0440 /etc/sudoers.d/appuser
# Switch to the non-root user
USER appuser
# Set up work directory
WORKDIR /home/appuser/app
# Set file permissions for the app directory
RUN chmod -R 755 /home/appuser/app
# Install pip requirements
RUN python3 -m pip install --upgrade pip
COPY requirements.txt /home/appuser/app/
RUN python3 -m pip install -r requirements.txt
# Switch back to the non-root user
USER appuser
# Copy other files (inceases likelihood of cache hits if requirements.txt didn't change)
COPY . /home/appuser/app/
# Set the entrypoint
ENTRYPOINT ["/usr/bin/bash"]