Weird commited on
Commit ·
61bbb97
1
Parent(s): 498a8cd
Update Dockerfile
Browse files- Dockerfile +48 -1
Dockerfile
CHANGED
|
@@ -45,5 +45,52 @@ RUN \
|
|
| 45 |
# add local files
|
| 46 |
COPY /root /
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
# ports and volumes
|
| 49 |
-
EXPOSE 8443
|
|
|
|
| 45 |
# add local files
|
| 46 |
COPY /root /
|
| 47 |
|
| 48 |
+
WORKDIR /app
|
| 49 |
+
# Create a non-root user and switch to it
|
| 50 |
+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
|
| 51 |
+
&& chown -R user:user /app
|
| 52 |
+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
|
| 53 |
+
USER user
|
| 54 |
+
# All users can use /home/user as their home directory
|
| 55 |
+
ENV HOME=/home/user
|
| 56 |
+
RUN mkdir $HOME/.cache $HOME/.config \
|
| 57 |
+
&& chmod -R 777 $HOME
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
WORKDIR $HOME/app
|
| 61 |
+
|
| 62 |
+
#######################################
|
| 63 |
+
# Start root user section
|
| 64 |
+
#######################################
|
| 65 |
+
|
| 66 |
+
USER root
|
| 67 |
+
|
| 68 |
+
# User Debian packages
|
| 69 |
+
## Security warning : Potential user code executed as root (build time)
|
| 70 |
+
RUN --mount=target=/root/packages.txt,source=packages.txt \
|
| 71 |
+
apt-get update && \
|
| 72 |
+
xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
|
| 73 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 74 |
+
|
| 75 |
+
RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
|
| 76 |
+
bash /root/on_startup.sh
|
| 77 |
+
|
| 78 |
+
#######################################
|
| 79 |
+
# End root user section
|
| 80 |
+
#######################################
|
| 81 |
+
|
| 82 |
+
USER user
|
| 83 |
+
|
| 84 |
+
# Python packages
|
| 85 |
+
RUN --mount=target=requirements.txt,source=requirements.txt \
|
| 86 |
+
pip install --no-cache-dir --upgrade -r requirements.txt
|
| 87 |
+
|
| 88 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 89 |
+
COPY --chown=user . $HOME/app
|
| 90 |
+
|
| 91 |
+
RUN chmod +x start_server.sh
|
| 92 |
+
|
| 93 |
+
CMD ["./start_server.sh"]
|
| 94 |
+
|
| 95 |
# ports and volumes
|
| 96 |
+
#EXPOSE 8443
|