Update Dockerfile
Browse files- Dockerfile +20 -3
Dockerfile
CHANGED
@@ -4,9 +4,27 @@ FROM python:3.9-slim-buster
|
|
4 |
# Set the working directory inside the container
|
5 |
WORKDIR /app
|
6 |
|
7 |
-
# Copy the HTML file
|
8 |
-
# Ensure your HTML file is named 'real_webvm.html'
|
9 |
COPY real_webvm.html .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
COPY run.sh .
|
11 |
|
12 |
# Make the run.sh script executable
|
@@ -16,5 +34,4 @@ RUN chmod +x run.sh
|
|
16 |
EXPOSE 8000
|
17 |
|
18 |
# Define the command to run when the container starts
|
19 |
-
# This will execute our run.sh script, which then starts the Python server
|
20 |
CMD ["./run.sh"]
|
|
|
4 |
# Set the working directory inside the container
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Copy the HTML file into the container
|
|
|
8 |
COPY real_webvm.html .
|
9 |
+
|
10 |
+
# Create the Python server script directly in the Dockerfile
|
11 |
+
# This ensures it has the correct permissions from the start
|
12 |
+
RUN echo "import http.server" > server.py && \
|
13 |
+
echo "import socketserver" >> server.py && \
|
14 |
+
echo "" >> server.py && \
|
15 |
+
echo "PORT = 8000" >> server.py && \
|
16 |
+
echo "" >> server.py && \
|
17 |
+
echo "class Handler(http.server.SimpleHTTPRequestHandler):" >> server.py && \
|
18 |
+
echo " def end_headers(self):" >> server.py && \
|
19 |
+
echo " self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')" >> server.py && \
|
20 |
+
echo " self.send_header('Cross-Origin-Opener-Policy', 'same-origin')" >> server.py && \
|
21 |
+
echo " super().end_headers()" >> server.py && \
|
22 |
+
echo "" >> server.py && \
|
23 |
+
echo "with socketserver.TCPServer(('', PORT), Handler) as httpd:" >> server.py && \
|
24 |
+
echo " print(f\"Serving real_webvm.html at http://localhost:{PORT}\")" >> server.py && \
|
25 |
+
echo " httpd.serve_forever()" >> server.py
|
26 |
+
|
27 |
+
# Copy the run.sh script into the container
|
28 |
COPY run.sh .
|
29 |
|
30 |
# Make the run.sh script executable
|
|
|
34 |
EXPOSE 8000
|
35 |
|
36 |
# Define the command to run when the container starts
|
|
|
37 |
CMD ["./run.sh"]
|