Updated socket connection code to support docker. Also updated dockerfile and entrypoint to support new file structure.
This commit is contained in:
@@ -23,16 +23,10 @@ COPY docker/nginx.conf /etc/nginx/nginx.conf
|
|||||||
# Copy built frontend to nginx's web directory
|
# Copy built frontend to nginx's web directory
|
||||||
COPY ./dist /usr/share/nginx/html
|
COPY ./dist /usr/share/nginx/html
|
||||||
|
|
||||||
# Set up backend directory and entrypoint script
|
|
||||||
COPY ./src/backend /src/backend
|
|
||||||
COPY ./src/backend/entrypoint.sh /src/backend/entrypoint.sh
|
|
||||||
|
|
||||||
# Make entrypoint script executable
|
|
||||||
RUN chmod +x /src/backend/entrypoint.sh
|
|
||||||
|
|
||||||
# Expose necessary ports
|
# Expose necessary ports
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
EXPOSE 8081
|
EXPOSE 8081
|
||||||
|
|
||||||
# Use entrypoint.sh to run both the backend and nginx
|
# Use entrypoint.sh to run both the backend and nginx
|
||||||
ENTRYPOINT ["/src/backend/entrypoint.sh"]
|
RUN chmod +x /app/src/backend/entrypoint.sh
|
||||||
|
ENTRYPOINT ["/app/src/backend/entrypoint.sh"]
|
||||||
@@ -27,6 +27,11 @@ http {
|
|||||||
proxy_set_header Connection 'upgrade';
|
proxy_set_header Connection 'upgrade';
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_cache_bypass $http_upgrade;
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
|
||||||
|
# CORS headers
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*'; # Allow all origins (can be restricted to a specific domain)
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST'; # Allow GET and POST methods
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Content-Type, Accept'; # Standard headers for requests
|
||||||
}
|
}
|
||||||
|
|
||||||
# Error pages
|
# Error pages
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Start the backend server
|
# Start the backend server
|
||||||
node /src/backend/server.cjs &
|
node /app/src/backend/server.cjs &
|
||||||
|
|
||||||
# Start nginx in the foreground
|
# Start nginx in the foreground
|
||||||
exec nginx -g 'daemon off;'
|
exec nginx -g 'daemon off;'
|
||||||
@@ -7,6 +7,7 @@ const io = socketIo(server, {
|
|||||||
cors: {
|
cors: {
|
||||||
origin: "*",
|
origin: "*",
|
||||||
methods: ["GET", "POST"],
|
methods: ["GET", "POST"],
|
||||||
|
transports: ["polling", "websocket"],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user