Attempt #1 to auto compile MongoDB into the build to exclude it from the compose.

This commit is contained in:
Karmaa
2025-03-16 13:07:18 -05:00
parent b585c95b25
commit aa95fee450
3 changed files with 26 additions and 11 deletions

View File

@@ -15,7 +15,7 @@ COPY src/backend/ ./src/backend/
# Stage 3: Final production image
FROM node:18-alpine
RUN apk add --no-cache nginx
RUN apk add --no-cache nginx mongodb~=5
# Configure nginx
COPY docker/nginx.conf /etc/nginx/nginx.conf
@@ -25,13 +25,23 @@ COPY --from=frontend-builder /app/dist /usr/share/nginx/html
COPY --from=backend-builder /app/node_modules ./node_modules
COPY --from=backend-builder /app/src/backend ./src/backend
# Create separate directories for nginx and node
RUN mkdir -p /var/log/nginx && \
# Create persistent directories for MongoDB and nginx
RUN mkdir -p /usr/local/mongodb/data/db && \
mkdir -p /var/log/nginx && \
mkdir -p /var/lib/nginx && \
chown -R nginx:nginx /var/log/nginx /var/lib/nginx
mkdir -p /var/log/mongodb && \
chown -R nginx:nginx /var/log/nginx /var/lib/nginx && \
chown -R mongodb:mongodb /usr/local/mongodb/data/db /var/log/mongodb
# Set environment variables
ENV MONGO_URL=mongodb://localhost:27017/termix \
MONGODB_DATA_DIR=/usr/local/mongodb/data/db \
MONGODB_LOG_DIR=/var/log/mongodb
VOLUME ["/usr/local/mongodb/data/db"]
# Expose ports
EXPOSE 8080 8081 8082
EXPOSE 8080 8081 8082 27017
# Use a entrypoint script to run all services
COPY docker/entrypoint.sh /entrypoint.sh