diff --git a/docker/Dockerfile b/docker/Dockerfile index 24e2cf5b..0f8e7db7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -16,19 +16,13 @@ COPY src/backend/ ./src/backend/ # Stage 3: Final production image FROM node:18-alpine -# Install nginx and required dependencies for MongoDB -RUN apk add --no-cache nginx \ - && apk add --no-cache \ - curl \ +# Install nginx and MongoDB (from the MongoDB repository) +RUN apk add --no-cache \ + nginx \ bash \ - ca-certificates \ - && curl -fsSL https://repo.mongodb.org/apk/alpine/v5.0/main/x86_64/mongodb-org-5.0.7-alpine3.13.tar.gz -o mongodb.tar.gz \ - && tar -xvzf mongodb.tar.gz -C /usr/local \ - && rm mongodb.tar.gz \ - && ln -s /usr/local/mongodb-org-5.0.7/bin/* /usr/local/bin/ \ - && mkdir -p /data/db \ - && mkdir -p /var/log/mongodb \ - && chown -R mongodb:mongodb /data/db /var/log/mongodb + && echo "https://repo.mongodb.org/repo/alpine-3.18/mongodb-org/5.0/main" >> /etc/apk/repositories \ + && apk update \ + && apk add --no-cache mongodb-org # Configure nginx COPY docker/nginx.conf /etc/nginx/nginx.conf @@ -38,15 +32,20 @@ COPY --from=frontend-builder /app/dist /usr/share/nginx/html COPY --from=backend-builder /app/node_modules ./node_modules COPY --from=backend-builder /app/src/backend ./src/backend -# Create necessary directories for nginx and MongoDB +# Create necessary directories RUN mkdir -p /var/log/nginx && \ mkdir -p /var/lib/nginx && \ chown -R nginx:nginx /var/log/nginx /var/lib/nginx -# Expose necessary ports -EXPOSE 8080 8081 27017 +# MongoDB setup +ENV MONGO_DATA_DIR=/data/db +RUN mkdir -p $MONGO_DATA_DIR && \ + chown -R mongodb:mongodb $MONGO_DATA_DIR -# Use an entrypoint script to run services (nginx, MongoDB, Node backend) +# Expose necessary ports +EXPOSE 8080 8081 8082 27017 + +# Use an entrypoint script to run services (nginx, MongoDB, and Node backend) COPY docker/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh CMD ["/entrypoint.sh"] \ No newline at end of file diff --git a/docker/nginx.conf b/docker/nginx.conf index 3756133b..23b3e4f2 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -34,7 +34,7 @@ http { } # Proxy database requests - location /database/ { + location /database-socket.io/ { proxy_pass http://127.0.0.1:8082; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; diff --git a/src/Terminal.jsx b/src/Terminal.jsx index 4e205814..95b1e808 100644 --- a/src/Terminal.jsx +++ b/src/Terminal.jsx @@ -66,7 +66,7 @@ export const NewTerminal = forwardRef(({ hostConfig, isVisible }, ref) => { ? "http://localhost:8081" : "/", { - path: "/socket.io", + path: "/ssh-socket.io/", transports: ["websocket", "polling"], } ); diff --git a/src/User.jsx b/src/User.jsx index 952a2236..2429cc8e 100644 --- a/src/User.jsx +++ b/src/User.jsx @@ -10,7 +10,7 @@ if (socket === null) { ? "http://localhost:8082" : "/", { - path: "/socket.io", + path: "/database-socket.io", transports: ["websocket", "polling"], } );