Changes to Dockerfile to fix error in installing MongoDB
This commit is contained in:
@@ -16,8 +16,13 @@ COPY src/backend/ ./src/backend/
|
|||||||
# Stage 3: Final production image
|
# Stage 3: Final production image
|
||||||
FROM node:18-alpine
|
FROM node:18-alpine
|
||||||
|
|
||||||
# Install nginx and MongoDB
|
# Install nginx
|
||||||
RUN apk add --no-cache nginx mongodb
|
RUN apk add --no-cache nginx
|
||||||
|
|
||||||
|
# Install MongoDB (from MongoDB's official repositories for Alpine)
|
||||||
|
RUN echo "https://repo.mongodb.org/apk/alpine/v5.0/main" > /etc/apk/repositories \
|
||||||
|
&& apk update \
|
||||||
|
&& apk add --no-cache mongodb-org
|
||||||
|
|
||||||
# Configure nginx
|
# Configure nginx
|
||||||
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
||||||
@@ -27,7 +32,7 @@ COPY --from=frontend-builder /app/dist /usr/share/nginx/html
|
|||||||
COPY --from=backend-builder /app/node_modules ./node_modules
|
COPY --from=backend-builder /app/node_modules ./node_modules
|
||||||
COPY --from=backend-builder /app/src/backend ./src/backend
|
COPY --from=backend-builder /app/src/backend ./src/backend
|
||||||
|
|
||||||
# Create necessary directories
|
# Create necessary directories for nginx and MongoDB
|
||||||
RUN mkdir -p /var/log/nginx && \
|
RUN mkdir -p /var/log/nginx && \
|
||||||
mkdir -p /var/lib/nginx && \
|
mkdir -p /var/lib/nginx && \
|
||||||
chown -R nginx:nginx /var/log/nginx /var/lib/nginx
|
chown -R nginx:nginx /var/log/nginx /var/lib/nginx
|
||||||
@@ -37,8 +42,8 @@ ENV MONGO_DATA_DIR=/data/db
|
|||||||
RUN mkdir -p $MONGO_DATA_DIR && \
|
RUN mkdir -p $MONGO_DATA_DIR && \
|
||||||
chown -R mongodb:mongodb $MONGO_DATA_DIR
|
chown -R mongodb:mongodb $MONGO_DATA_DIR
|
||||||
|
|
||||||
# Expose necessary ports
|
# Expose necessary ports (nginx on 8080, Node.js backend on 8081, MongoDB on 27017)
|
||||||
EXPOSE 8080 8081 8082 27017
|
EXPOSE 8080 8081 27017
|
||||||
|
|
||||||
# Use an entrypoint script to run services (nginx, MongoDB, and Node backend)
|
# Use an entrypoint script to run services (nginx, MongoDB, and Node backend)
|
||||||
COPY docker/entrypoint.sh /entrypoint.sh
|
COPY docker/entrypoint.sh /entrypoint.sh
|
||||||
|
|||||||
Reference in New Issue
Block a user