Changes to Dockerfile to fix error in installing MongoDB
This commit is contained in:
@@ -13,10 +13,10 @@ COPY package*.json ./
|
|||||||
RUN npm install
|
RUN npm install
|
||||||
COPY src/backend/ ./src/backend/
|
COPY src/backend/ ./src/backend/
|
||||||
|
|
||||||
# Stage 3: Final production image (based on node:18-alpine)
|
# Stage 3: Final production image
|
||||||
FROM node:18-alpine
|
FROM node:18-alpine
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies including nginx
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
nginx \
|
nginx \
|
||||||
bash \
|
bash \
|
||||||
@@ -26,6 +26,9 @@ RUN apk add --no-cache \
|
|||||||
libcurl \
|
libcurl \
|
||||||
&& update-ca-certificates
|
&& update-ca-certificates
|
||||||
|
|
||||||
|
# Install MongoDB image (version 5)
|
||||||
|
FROM mongo:5 AS mongodb
|
||||||
|
|
||||||
# Configure nginx
|
# Configure nginx
|
||||||
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY --from=frontend-builder /app/dist /usr/share/nginx/html
|
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 && \
|
RUN mkdir -p /var/log/nginx /var/lib/nginx && \
|
||||||
chown -R nginx:nginx /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
|
EXPOSE 8080 8081 27017
|
||||||
|
|
||||||
# Use MongoDB image (version 5)
|
|
||||||
FROM mongo:5 AS mongodb
|
|
||||||
|
|
||||||
# Copy entrypoint script
|
# Copy entrypoint script
|
||||||
COPY docker/entrypoint.sh /entrypoint.sh
|
COPY docker/entrypoint.sh /entrypoint.sh
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/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
|
# Start NGINX
|
||||||
echo "Starting NGINX..."
|
echo "Starting NGINX..."
|
||||||
nginx -g "daemon off;" &
|
nginx -g "daemon off;" &
|
||||||
|
|||||||
Reference in New Issue
Block a user