Spaces:
Sleeping
Sleeping
Raymond Weitekamp
commited on
Commit
·
84beecb
1
Parent(s):
c88d551
Add build-time Nginx proxy test
Browse files- Dockerfile +41 -1
Dockerfile
CHANGED
|
@@ -12,6 +12,8 @@ RUN apt-get update && apt-get install -y \
|
|
| 12 |
libx11-dev \
|
| 13 |
libxrender1 \
|
| 14 |
nginx \
|
|
|
|
|
|
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
# Create matplotlib config directory with proper permissions
|
|
@@ -30,7 +32,7 @@ ENV OCP_VSCODE_LOCK_DIR=/tmp/ocpvscode
|
|
| 30 |
COPY . .
|
| 31 |
|
| 32 |
# Set up startup script with correct permissions
|
| 33 |
-
RUN chmod +x start.sh
|
| 34 |
|
| 35 |
# Configure Nginx with proper permissions
|
| 36 |
RUN mkdir -p /var/lib/nginx/body && \
|
|
@@ -47,6 +49,44 @@ RUN mkdir -p /var/lib/nginx/body && \
|
|
| 47 |
chmod -R 755 /var/log/nginx && \
|
| 48 |
chmod -R 755 /run/nginx
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
# Create a non-root user and set up home directory
|
| 51 |
RUN useradd -m -d /home/appuser -s /bin/bash appuser && \
|
| 52 |
touch /home/appuser/.ocpvscode && \
|
|
|
|
| 12 |
libx11-dev \
|
| 13 |
libxrender1 \
|
| 14 |
nginx \
|
| 15 |
+
curl \
|
| 16 |
+
netcat \
|
| 17 |
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
# Create matplotlib config directory with proper permissions
|
|
|
|
| 32 |
COPY . .
|
| 33 |
|
| 34 |
# Set up startup script with correct permissions
|
| 35 |
+
RUN chmod +x start.sh test_nginx.sh
|
| 36 |
|
| 37 |
# Configure Nginx with proper permissions
|
| 38 |
RUN mkdir -p /var/lib/nginx/body && \
|
|
|
|
| 49 |
chmod -R 755 /var/log/nginx && \
|
| 50 |
chmod -R 755 /run/nginx
|
| 51 |
|
| 52 |
+
# Create a test script for build-time verification
|
| 53 |
+
RUN echo '#!/bin/bash\n\
|
| 54 |
+
echo "Starting test server on port 7861..."\n\
|
| 55 |
+
python3 -m http.server 7861 &\n\
|
| 56 |
+
SERVER_PID=$!\n\
|
| 57 |
+
\n\
|
| 58 |
+
echo "Starting test server on port 3939..."\n\
|
| 59 |
+
python3 -m http.server 3939 &\n\
|
| 60 |
+
VIEWER_PID=$!\n\
|
| 61 |
+
\n\
|
| 62 |
+
echo "Starting nginx..."\n\
|
| 63 |
+
nginx\n\
|
| 64 |
+
\n\
|
| 65 |
+
echo "Waiting for servers to start..."\n\
|
| 66 |
+
sleep 2\n\
|
| 67 |
+
\n\
|
| 68 |
+
echo "Testing main app proxy..."\n\
|
| 69 |
+
MAIN_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:7860/)\n\
|
| 70 |
+
echo "Main app status: $MAIN_STATUS"\n\
|
| 71 |
+
\n\
|
| 72 |
+
echo "Testing viewer proxy..."\n\
|
| 73 |
+
VIEWER_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:7860/proxy/3939/viewer)\n\
|
| 74 |
+
echo "Viewer status: $VIEWER_STATUS"\n\
|
| 75 |
+
\n\
|
| 76 |
+
nginx -s stop\n\
|
| 77 |
+
kill $SERVER_PID $VIEWER_PID\n\
|
| 78 |
+
\n\
|
| 79 |
+
if [ "$MAIN_STATUS" = "200" ] && [ "$VIEWER_STATUS" = "200" ]; then\n\
|
| 80 |
+
echo "All tests passed!"\n\
|
| 81 |
+
exit 0\n\
|
| 82 |
+
else\n\
|
| 83 |
+
echo "Tests failed!"\n\
|
| 84 |
+
exit 1\n\
|
| 85 |
+
fi' > /code/test_build.sh && chmod +x /code/test_build.sh
|
| 86 |
+
|
| 87 |
+
# Run the build-time test
|
| 88 |
+
RUN /code/test_build.sh
|
| 89 |
+
|
| 90 |
# Create a non-root user and set up home directory
|
| 91 |
RUN useradd -m -d /home/appuser -s /bin/bash appuser && \
|
| 92 |
touch /home/appuser/.ocpvscode && \
|