new build
Browse files- Dockerfile +29 -50
Dockerfile
CHANGED
@@ -1,73 +1,52 @@
|
|
1 |
# Builder stage
|
2 |
FROM python:3.10.0 as builder
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
|
6 |
WORKDIR /srv
|
7 |
-
RUN chown -R admin:admin /srv
|
8 |
-
RUN chmod 755 /srv
|
9 |
-
|
10 |
-
|
11 |
|
|
|
12 |
RUN apt-get update && \
|
13 |
apt-get install -y --no-install-recommends \
|
14 |
-
aria2 ffmpeg
|
15 |
-
libgles2-mesa-dev \
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
freeglut3-dev \
|
20 |
-
libglfw3-dev \
|
21 |
-
libglew-dev \
|
22 |
-
libsdl2-dev \
|
23 |
-
libjpeg-dev \
|
24 |
-
libpng-dev \
|
25 |
-
libfreetype6-dev \
|
26 |
&& rm -rf /var/lib/apt/lists/*
|
27 |
|
28 |
-
#
|
29 |
COPY requirements.txt .
|
30 |
RUN pip install --no-cache-dir -r requirements.txt
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
# Create necessary directories and set permissions
|
36 |
RUN mkdir -p /home/admin/.local/share/BrokenSource/Broken \
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
&& ln -s /home/admin/.local/share/BrokenSource/DepthFlow /usr/local/lib/python3.10/site-packages/Workspace/DepthFlow \
|
43 |
-
&& chmod -R 777 /home/admin/.local /tmp/Video /usr/local/lib/python3.10/site-packages/Workspace
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
# Create a non-root user and give it sudo privileges
|
48 |
-
RUN useradd -m appuser \
|
49 |
-
&& mkdir -p /etc/sudoers.d \
|
50 |
-
&& echo "appuser ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/appuser \
|
51 |
-
&& chmod 0440 /etc/sudoers.d/appuser
|
52 |
-
|
53 |
-
# Switch to the non-root user
|
54 |
-
USER appuser
|
55 |
-
|
56 |
-
|
57 |
|
|
|
58 |
COPY --chown=appuser . /srv
|
59 |
|
60 |
-
#
|
61 |
-
# Create a startup script
|
62 |
RUN echo '#!/bin/bash\n\
|
63 |
-
rm -rf /usr/local/lib/python3.10/site-packages/Workspace\n\
|
64 |
-
mkdir -p /usr/local/lib/python3.10/site-packages/Workspace\n\
|
65 |
ln -sf /home/admin/.local/share/BrokenSource/Broken /usr/local/lib/python3.10/site-packages/Workspace/Broken\n\
|
66 |
ln -sf /home/admin/.local/share/BrokenSource/DepthFlow /usr/local/lib/python3.10/site-packages/Workspace/DepthFlow\n\
|
67 |
-
uvicorn app:app --host 0.0.0.0 --port 8000\n'\
|
68 |
-
> /
|
|
|
|
|
|
|
69 |
|
70 |
-
# Run the startup script when the container launches
|
71 |
-
CMD ["/app/start.sh"]
|
72 |
# Expose the server port
|
73 |
-
EXPOSE
|
|
|
|
|
|
|
|
1 |
# Builder stage
|
2 |
FROM python:3.10.0 as builder
|
3 |
|
4 |
+
# Create non-root users
|
5 |
+
RUN useradd -ms /bin/bash admin && \
|
6 |
+
useradd -ms /bin/bash appuser && \
|
7 |
+
echo "appuser ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/appuser && \
|
8 |
+
chmod 0440 /etc/sudoers.d/appuser
|
9 |
|
10 |
WORKDIR /srv
|
11 |
+
RUN chown -R admin:admin /srv && chmod 755 /srv
|
|
|
|
|
|
|
12 |
|
13 |
+
# Install system dependencies
|
14 |
RUN apt-get update && \
|
15 |
apt-get install -y --no-install-recommends \
|
16 |
+
aria2 ffmpeg libgl1-mesa-dev \
|
17 |
+
libgles2-mesa-dev libglu1-mesa-dev \
|
18 |
+
build-essential cmake freeglut3-dev \
|
19 |
+
libglfw3-dev libglew-dev libsdl2-dev \
|
20 |
+
libjpeg-dev libpng-dev libfreetype6-dev \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
&& rm -rf /var/lib/apt/lists/*
|
22 |
|
23 |
+
# Install Python dependencies
|
24 |
COPY requirements.txt .
|
25 |
RUN pip install --no-cache-dir -r requirements.txt
|
26 |
|
|
|
|
|
|
|
27 |
# Create necessary directories and set permissions
|
28 |
RUN mkdir -p /home/admin/.local/share/BrokenSource/Broken \
|
29 |
+
/home/admin/.local/share/BrokenSource/DepthFlow/Config \
|
30 |
+
/tmp/Video \
|
31 |
+
/usr/local/lib/python3.10/site-packages/Workspace && \
|
32 |
+
chown -R admin:admin /home/admin/.local && \
|
33 |
+
chmod -R 755 /home/admin/.local /tmp/Video /usr/local/lib/python3.10/site-packages/Workspace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
+
# Copy application files
|
36 |
COPY --chown=appuser . /srv
|
37 |
|
38 |
+
# Create startup script
|
|
|
39 |
RUN echo '#!/bin/bash\n\
|
|
|
|
|
40 |
ln -sf /home/admin/.local/share/BrokenSource/Broken /usr/local/lib/python3.10/site-packages/Workspace/Broken\n\
|
41 |
ln -sf /home/admin/.local/share/BrokenSource/DepthFlow /usr/local/lib/python3.10/site-packages/Workspace/DepthFlow\n\
|
42 |
+
exec uvicorn app:app --host 0.0.0.0 --port 8000\n'\
|
43 |
+
> /srv/start.sh && chmod +x /srv/start.sh
|
44 |
+
|
45 |
+
# Switch to the non-root user
|
46 |
+
USER appuser
|
47 |
|
|
|
|
|
48 |
# Expose the server port
|
49 |
+
EXPOSE 8000
|
50 |
+
|
51 |
+
# Run the startup script when the container launches
|
52 |
+
CMD ["/srv/start.sh"]
|