File size: 1,425 Bytes
afed508 d1a02cb afed508 d1a02cb afed508 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# Use a lightweight Python base image
FROM python:3.9-slim-buster
# Set the working directory inside the container
WORKDIR /app
# Copy the HTML file into the container
COPY real_webvm.html .
# Create the Python server script directly in the Dockerfile
# This ensures it has the correct permissions from the start
RUN echo "import http.server" > server.py && \
echo "import socketserver" >> server.py && \
echo "" >> server.py && \
echo "PORT = 8000" >> server.py && \
echo "" >> server.py && \
echo "class Handler(http.server.SimpleHTTPRequestHandler):" >> server.py && \
echo " def end_headers(self):" >> server.py && \
echo " self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')" >> server.py && \
echo " self.send_header('Cross-Origin-Opener-Policy', 'same-origin')" >> server.py && \
echo " super().end_headers()" >> server.py && \
echo "" >> server.py && \
echo "with socketserver.TCPServer(('', PORT), Handler) as httpd:" >> server.py && \
echo " print(f\"Serving real_webvm.html at http://localhost:{PORT}\")" >> server.py && \
echo " httpd.serve_forever()" >> server.py
# Copy the run.sh script into the container
COPY run.sh .
# Make the run.sh script executable
RUN chmod +x run.sh
# Expose the port that the server will listen on
EXPOSE 8000
# Define the command to run when the container starts
CMD ["./run.sh"]
|