Changes to Dockerfile to fix error in installing MongoDB
This commit is contained in:
@@ -16,13 +16,19 @@ 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
|
# Install nginx and required dependencies for MongoDB
|
||||||
RUN apk add --no-cache nginx
|
RUN apk add --no-cache nginx \
|
||||||
|
&& apk add --no-cache \
|
||||||
# Install MongoDB (from MongoDB's official repositories for Alpine)
|
curl \
|
||||||
RUN echo "https://repo.mongodb.org/apk/alpine/v5.0/main" > /etc/apk/repositories \
|
bash \
|
||||||
&& apk update \
|
ca-certificates \
|
||||||
&& apk add --no-cache mongodb-org
|
&& 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
|
||||||
|
|
||||||
# Configure nginx
|
# Configure nginx
|
||||||
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
||||||
@@ -37,15 +43,10 @@ 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
|
||||||
|
|
||||||
# MongoDB setup
|
# Expose necessary ports
|
||||||
ENV MONGO_DATA_DIR=/data/db
|
|
||||||
RUN mkdir -p $MONGO_DATA_DIR && \
|
|
||||||
chown -R mongodb:mongodb $MONGO_DATA_DIR
|
|
||||||
|
|
||||||
# Expose necessary ports (nginx on 8080, Node.js backend on 8081, MongoDB on 27017)
|
|
||||||
EXPOSE 8080 8081 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, Node backend)
|
||||||
COPY docker/entrypoint.sh /entrypoint.sh
|
COPY docker/entrypoint.sh /entrypoint.sh
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
CMD ["/entrypoint.sh"]
|
CMD ["/entrypoint.sh"]
|
||||||
Reference in New Issue
Block a user