Update Dockerfile
Browse files- Dockerfile +14 -7
Dockerfile
CHANGED
|
@@ -1,19 +1,26 @@
|
|
| 1 |
FROM python:3.10.9
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
WORKDIR /
|
| 8 |
-
|
| 9 |
-
# Create the directories with appropriate permissions
|
| 10 |
RUN mkdir -m 777 /tmp/NUMBA_CACHE_DIR /tmp/MPLCONFIGDIR
|
|
|
|
| 11 |
|
| 12 |
# Set environment variables
|
| 13 |
ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR/
|
| 14 |
ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR/
|
| 15 |
|
| 16 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
RUN python -m venv /opt/venv
|
| 18 |
|
| 19 |
# Activate the virtual environment and install requirements
|
|
|
|
| 1 |
FROM python:3.10.9
|
| 2 |
|
| 3 |
+
# Create a non-root user and group with a specified UID and GID
|
| 4 |
+
RUN addgroup --gid 1001 appgroup && adduser --uid 1001 --gid 1001 --disabled-password --gecos "" appuser
|
| 5 |
|
| 6 |
+
# Create directories with appropriate permissions and change ownership
|
|
|
|
|
|
|
|
|
|
| 7 |
RUN mkdir -m 777 /tmp/NUMBA_CACHE_DIR /tmp/MPLCONFIGDIR
|
| 8 |
+
RUN chown -R appuser:appgroup /tmp/NUMBA_CACHE_DIR /tmp/MPLCONFIGDIR
|
| 9 |
|
| 10 |
# Set environment variables
|
| 11 |
ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR/
|
| 12 |
ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR/
|
| 13 |
|
| 14 |
+
# Copy all files to the container
|
| 15 |
+
COPY --chown=appuser:appgroup . .
|
| 16 |
+
|
| 17 |
+
# Set the working directory
|
| 18 |
+
WORKDIR /
|
| 19 |
+
|
| 20 |
+
# Switch to the non-root user
|
| 21 |
+
USER appuser
|
| 22 |
+
|
| 23 |
+
# Install virtualenv and set up the virtual environment
|
| 24 |
RUN python -m venv /opt/venv
|
| 25 |
|
| 26 |
# Activate the virtual environment and install requirements
|