Changes to Dockerfile to fix error in installing MongoDB

This commit is contained in:
Karmaa
2025-03-11 23:11:25 -05:00
parent 76e2642c6f
commit 5d007e05fd
2 changed files with 6 additions and 10 deletions

View File

@@ -13,10 +13,10 @@ COPY package*.json ./
RUN npm install
COPY src/backend/ ./src/backend/
# Stage 3: Final production image (based on node:18-alpine)
# Stage 3: Final production image
FROM node:18-alpine
# Install dependencies
# Install dependencies including nginx
RUN apk add --no-cache \
nginx \
bash \
@@ -26,6 +26,9 @@ RUN apk add --no-cache \
libcurl \
&& update-ca-certificates
# Install MongoDB image (version 5)
FROM mongo:5 AS mongodb
# Configure nginx
COPY docker/nginx.conf /etc/nginx/nginx.conf
COPY --from=frontend-builder /app/dist /usr/share/nginx/html
@@ -38,12 +41,9 @@ COPY --from=backend-builder /app/src/backend ./src/backend
RUN mkdir -p /var/log/nginx /var/lib/nginx && \
chown -R nginx:nginx /var/log/nginx /var/lib/nginx
# Expose necessary ports (8080 for nginx, 8081 for backend, 27017 for MongoDB)
# Expose necessary ports
EXPOSE 8080 8081 27017
# Use MongoDB image (version 5)
FROM mongo:5 AS mongodb
# Copy entrypoint script
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

View File

@@ -1,9 +1,5 @@
#!/bin/bash
# Start MongoDB (it should already be running from the mongo:5 container)
echo "Starting MongoDB..."
# MongoDB will run in a separate container, no need to start it here.
# Start NGINX
echo "Starting NGINX..."
nginx -g "daemon off;" &