Changes to Dockerfile to fix error in installing MongoDB

This commit is contained in:
Karmaa
2025-03-11 22:42:42 -05:00
parent e6cef2aa2d
commit 0da37dcfc7

View File

@@ -25,7 +25,7 @@ RUN apt-get update && apt-get install -y \
&& apt-get update && apt-get install -y mongodb-org \ && apt-get update && apt-get install -y mongodb-org \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Create mongodb user and group if they do not exist # Create mongodb user and group
RUN getent group mongodb || groupadd -r mongodb && \ RUN getent group mongodb || groupadd -r mongodb && \
getent passwd mongodb || useradd -r -g mongodb mongodb getent passwd mongodb || useradd -r -g mongodb mongodb
@@ -35,6 +35,10 @@ FROM node:18-alpine
# Install nginx # Install nginx
RUN apk add --no-cache nginx bash RUN apk add --no-cache nginx bash
# Create mongodb user and group in the final image
RUN getent group mongodb || groupadd -r mongodb && \
getent passwd mongodb || useradd -r -g mongodb mongodb
# Install MongoDB from the mongodb-builder stage # Install MongoDB from the mongodb-builder stage
COPY --from=mongodb-builder /usr/bin/mongod /usr/bin/mongod COPY --from=mongodb-builder /usr/bin/mongod /usr/bin/mongod
COPY --from=mongodb-builder /usr/bin/mongo /usr/bin/mongo COPY --from=mongodb-builder /usr/bin/mongo /usr/bin/mongo