Dev 2.0 #23

Merged
LukeGus merged 44 commits from dev-2.0 into main 2025-03-16 19:17:56 +00:00
2 changed files with 18 additions and 18 deletions
Showing only changes of commit 89a123f36c - Show all commits

View File

@@ -14,8 +14,15 @@ RUN npm install
COPY src/backend/ ./src/backend/
# Stage 3: Final production image
FROM node:18-alpine
RUN apk add --no-cache nginx mongodb~=5
FROM mongo:5
# Install Node.js
RUN apt-get update && apt-get install -y \
curl \
nginx \
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Configure nginx
COPY docker/nginx.conf /etc/nginx/nginx.conf
@@ -25,20 +32,13 @@ 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 persistent directories for MongoDB and nginx
RUN mkdir -p /usr/local/mongodb/data/db && \
mkdir -p /var/log/nginx && \
# Create directories for nginx
RUN mkdir -p /var/log/nginx && \
mkdir -p /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
chown -R www-data:www-data /var/log/nginx /var/lib/nginx
# 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"]
ENV MONGO_URL=mongodb://localhost:27017/termix
# Expose ports
EXPOSE 8080 8081 8082 27017

View File

@@ -1,7 +1,7 @@
#!/bin/sh
#!/bin/bash
# Start MongoDB with custom data directory
mongod --fork --dbpath $MONGODB_DATA_DIR --logpath $MONGODB_LOG_DIR/mongodb.log
# Start MongoDB
mongod --fork --logpath /var/log/mongodb.log
# Start nginx
nginx
@@ -12,5 +12,5 @@ node src/backend/ssh.cjs &
# Start the database service
node src/backend/database.cjs &
# Keep the container running
tail -f /dev/null
# Keep the container running and show MongoDB logs
tail -f /var/log/mongodb.log