Spaces:
Sleeping
Sleeping
Raymond Weitekamp commited on
Commit ·
13e4b0a
1
Parent(s): 1706a3b
Fix Dockerfile permissions handling
Browse files- Dockerfile +17 -19
Dockerfile
CHANGED
|
@@ -26,6 +26,18 @@ RUN mkdir -p /.cache/ezdxf && \
|
|
| 26 |
# Set OCP_VSCODE_LOCK_DIR environment variable
|
| 27 |
ENV OCP_VSCODE_LOCK_DIR=/tmp/ocpvscode
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# Create a non-root user and set up home directory
|
| 30 |
RUN useradd -m -d /home/appuser -s /bin/bash appuser && \
|
| 31 |
touch /home/appuser/.ocpvscode && \
|
|
@@ -33,13 +45,6 @@ RUN useradd -m -d /home/appuser -s /bin/bash appuser && \
|
|
| 33 |
chown -R appuser:appuser /home/appuser && \
|
| 34 |
chmod 666 /home/appuser/.ocpvscode
|
| 35 |
|
| 36 |
-
# Configure Nginx
|
| 37 |
-
COPY nginx.conf /etc/nginx/nginx.conf
|
| 38 |
-
RUN mkdir -p /run/nginx && \
|
| 39 |
-
chown -R appuser:appuser /run/nginx && \
|
| 40 |
-
chown -R appuser:appuser /var/log/nginx && \
|
| 41 |
-
chown -R appuser:appuser /var/lib/nginx
|
| 42 |
-
|
| 43 |
# Install uv and create virtual environment
|
| 44 |
RUN pip install uv && \
|
| 45 |
uv venv /opt/venv
|
|
@@ -47,20 +52,17 @@ RUN pip install uv && \
|
|
| 47 |
# Activate virtual environment
|
| 48 |
ENV PATH="/opt/venv/bin:$PATH"
|
| 49 |
|
| 50 |
-
# Copy only pyproject.toml first to leverage Docker cache
|
| 51 |
-
COPY pyproject.toml .
|
| 52 |
-
|
| 53 |
# Install project and dependencies using uv
|
| 54 |
RUN uv pip install .
|
| 55 |
|
| 56 |
-
# Copy the rest of the application
|
| 57 |
-
COPY . .
|
| 58 |
-
|
| 59 |
# Download and setup openvscode-server
|
| 60 |
RUN wget https://github.com/gitpod-io/openvscode-server/releases/download/openvscode-server-v1.86.2/openvscode-server-v1.86.2-linux-x64.tar.gz -O /tmp/openvscode-server.tar.gz && \
|
| 61 |
tar -xzf /tmp/openvscode-server.tar.gz -C /opt && \
|
| 62 |
rm /tmp/openvscode-server.tar.gz && \
|
| 63 |
-
mv /opt/openvscode-server-v1.86.2-linux-x64 /opt/openvscode-server
|
|
|
|
|
|
|
|
|
|
| 64 |
chown -R appuser:appuser /opt/openvscode-server
|
| 65 |
|
| 66 |
# Switch to non-root user
|
|
@@ -70,9 +72,5 @@ ENV HOME=/home/appuser
|
|
| 70 |
# Expose port 7860 for Hugging Face Spaces
|
| 71 |
EXPOSE 7860
|
| 72 |
|
| 73 |
-
# Create startup script
|
| 74 |
-
COPY start.sh /code/start.sh
|
| 75 |
-
RUN chmod +x /code/start.sh
|
| 76 |
-
|
| 77 |
# Run the startup script
|
| 78 |
-
CMD ["
|
|
|
|
| 26 |
# Set OCP_VSCODE_LOCK_DIR environment variable
|
| 27 |
ENV OCP_VSCODE_LOCK_DIR=/tmp/ocpvscode
|
| 28 |
|
| 29 |
+
# Copy application files first
|
| 30 |
+
COPY . .
|
| 31 |
+
|
| 32 |
+
# Set up startup script with correct permissions
|
| 33 |
+
RUN chmod +x start.sh
|
| 34 |
+
|
| 35 |
+
# Configure Nginx
|
| 36 |
+
RUN mkdir -p /run/nginx && \
|
| 37 |
+
chown -R www-data:www-data /run/nginx && \
|
| 38 |
+
chown -R www-data:www-data /var/log/nginx && \
|
| 39 |
+
chown -R www-data:www-data /var/lib/nginx
|
| 40 |
+
|
| 41 |
# Create a non-root user and set up home directory
|
| 42 |
RUN useradd -m -d /home/appuser -s /bin/bash appuser && \
|
| 43 |
touch /home/appuser/.ocpvscode && \
|
|
|
|
| 45 |
chown -R appuser:appuser /home/appuser && \
|
| 46 |
chmod 666 /home/appuser/.ocpvscode
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
# Install uv and create virtual environment
|
| 49 |
RUN pip install uv && \
|
| 50 |
uv venv /opt/venv
|
|
|
|
| 52 |
# Activate virtual environment
|
| 53 |
ENV PATH="/opt/venv/bin:$PATH"
|
| 54 |
|
|
|
|
|
|
|
|
|
|
| 55 |
# Install project and dependencies using uv
|
| 56 |
RUN uv pip install .
|
| 57 |
|
|
|
|
|
|
|
|
|
|
| 58 |
# Download and setup openvscode-server
|
| 59 |
RUN wget https://github.com/gitpod-io/openvscode-server/releases/download/openvscode-server-v1.86.2/openvscode-server-v1.86.2-linux-x64.tar.gz -O /tmp/openvscode-server.tar.gz && \
|
| 60 |
tar -xzf /tmp/openvscode-server.tar.gz -C /opt && \
|
| 61 |
rm /tmp/openvscode-server.tar.gz && \
|
| 62 |
+
mv /opt/openvscode-server-v1.86.2-linux-x64 /opt/openvscode-server
|
| 63 |
+
|
| 64 |
+
# Set permissions for the entire /code directory
|
| 65 |
+
RUN chown -R appuser:appuser /code && \
|
| 66 |
chown -R appuser:appuser /opt/openvscode-server
|
| 67 |
|
| 68 |
# Switch to non-root user
|
|
|
|
| 72 |
# Expose port 7860 for Hugging Face Spaces
|
| 73 |
EXPOSE 7860
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
# Run the startup script
|
| 76 |
+
CMD ["./start.sh"]
|