Changes to Dockerfile to fix error in installing MongoDB
This commit is contained in:
@@ -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"]
|
||||
@@ -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;
|
||||
|
||||
@@ -66,7 +66,7 @@ export const NewTerminal = forwardRef(({ hostConfig, isVisible }, ref) => {
|
||||
? "http://localhost:8081"
|
||||
: "/",
|
||||
{
|
||||
path: "/socket.io",
|
||||
path: "/ssh-socket.io/",
|
||||
transports: ["websocket", "polling"],
|
||||
}
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ if (socket === null) {
|
||||
? "http://localhost:8082"
|
||||
: "/",
|
||||
{
|
||||
path: "/socket.io",
|
||||
path: "/database-socket.io",
|
||||
transports: ["websocket", "polling"],
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user