Attempt #3 to auto compile MongoDB into the build to exclude it from the compose.
This commit is contained in:
@@ -32,13 +32,21 @@ 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 directories for nginx
|
# Create directories for MongoDB and nginx
|
||||||
RUN mkdir -p /var/log/nginx && \
|
RUN mkdir -p /data/db && \
|
||||||
|
mkdir -p /var/log/nginx && \
|
||||||
mkdir -p /var/lib/nginx && \
|
mkdir -p /var/lib/nginx && \
|
||||||
|
mkdir -p /var/log/mongodb && \
|
||||||
|
chown -R mongodb:mongodb /data/db /var/log/mongodb && \
|
||||||
chown -R www-data:www-data /var/log/nginx /var/lib/nginx
|
chown -R www-data:www-data /var/log/nginx /var/lib/nginx
|
||||||
|
|
||||||
# Set environment variables
|
# Set environment variables
|
||||||
ENV MONGO_URL=mongodb://localhost:27017/termix
|
ENV MONGO_URL=mongodb://localhost:27017/termix \
|
||||||
|
MONGODB_DATA_DIR=/data/db \
|
||||||
|
MONGODB_LOG_DIR=/var/log/mongodb
|
||||||
|
|
||||||
|
# Create volume for MongoDB data
|
||||||
|
VOLUME ["/data/db"]
|
||||||
|
|
||||||
# Expose ports
|
# Expose ports
|
||||||
EXPOSE 8080 8081 8082 27017
|
EXPOSE 8080 8081 8082 27017
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Start MongoDB
|
# Start MongoDB
|
||||||
mongod --fork --logpath /var/log/mongodb.log
|
mongod --fork --dbpath $MONGODB_DATA_DIR --logpath $MONGODB_LOG_DIR/mongodb.log
|
||||||
|
|
||||||
|
# Wait for MongoDB to be ready
|
||||||
|
echo "Waiting for MongoDB to start..."
|
||||||
|
until mongo --eval "print(\"waited for connection\")" > /dev/null 2>&1; do
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
echo "MongoDB has started"
|
||||||
|
|
||||||
# Start nginx
|
# Start nginx
|
||||||
nginx
|
nginx
|
||||||
@@ -13,4 +20,4 @@ node src/backend/ssh.cjs &
|
|||||||
node src/backend/database.cjs &
|
node src/backend/database.cjs &
|
||||||
|
|
||||||
# Keep the container running and show MongoDB logs
|
# Keep the container running and show MongoDB logs
|
||||||
tail -f /var/log/mongodb.log
|
tail -f $MONGODB_LOG_DIR/mongodb.log
|
||||||
Reference in New Issue
Block a user