CMD ["/app/start.sh"]
Browse files- Dockerfile +44 -28
Dockerfile
CHANGED
@@ -1,52 +1,68 @@
|
|
1 |
# Builder stage
|
2 |
FROM python:3.10.0 as builder
|
3 |
|
4 |
-
|
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
|
|
|
|
|
|
|
12 |
|
13 |
-
# Install system dependencies
|
14 |
RUN apt-get update && \
|
15 |
apt-get install -y --no-install-recommends \
|
16 |
-
aria2 ffmpeg
|
17 |
-
libgles2-mesa-dev
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
&& rm -rf /var/lib/apt/lists/*
|
22 |
|
23 |
-
#
|
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 |
-
/
|
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 |
-
|
43 |
-
> /
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# Switch to the non-root user
|
46 |
USER appuser
|
47 |
|
48 |
-
# Expose the server port
|
49 |
-
EXPOSE 8000
|
50 |
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Builder stage
|
2 |
FROM python:3.10.0 as builder
|
3 |
|
4 |
+
RUN useradd -ms /bin/bash admin
|
|
|
|
|
|
|
|
|
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 libgl1-mesa-dev \
|
15 |
+
libgles2-mesa-dev \
|
16 |
+
libglu1-mesa-dev \
|
17 |
+
build-essential \
|
18 |
+
cmake \
|
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 |
+
#copy requirements
|
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 |
+
&& mkdir -p /home/admin/.local/share/BrokenSource/DepthFlow/Config \
|
38 |
+
&& mkdir -p /tmp/Video \
|
39 |
+
&& chmod -R 777 /home/admin/.local /tmp/Video
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
# Create a startup script
|
42 |
RUN echo '#!/bin/bash\n\
|
43 |
+
rm -rf /usr/local/lib/python3.10/site-packages/Workspace\n\
|
44 |
+
mkdir -p /usr/local/lib/python3.10/site-packages/Workspace\n\
|
45 |
ln -sf /home/admin/.local/share/BrokenSource/Broken /usr/local/lib/python3.10/site-packages/Workspace/Broken\n\
|
46 |
ln -sf /home/admin/.local/share/BrokenSource/DepthFlow /usr/local/lib/python3.10/site-packages/Workspace/DepthFlow\n\
|
47 |
+
uvicorn app:app --host 0.0.0.0 --port 7860\n'\
|
48 |
+
> /app/start.sh && chmod +x /app/start.sh
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
# Create a non-root user and give it sudo privileges
|
53 |
+
RUN useradd -m appuser \
|
54 |
+
&& mkdir -p /etc/sudoers.d \
|
55 |
+
&& echo "appuser ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/appuser \
|
56 |
+
&& chmod 0440 /etc/sudoers.d/appuser
|
57 |
|
58 |
# Switch to the non-root user
|
59 |
USER appuser
|
60 |
|
|
|
|
|
61 |
|
62 |
+
|
63 |
+
COPY --chown=appuser . /srv
|
64 |
+
|
65 |
+
# Command to run the application
|
66 |
+
CMD ["/app/start.sh"]
|
67 |
+
# Expose the server port
|
68 |
+
EXPOSE 7860
|