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

This commit is contained in:
Karmaa
2025-03-16 13:39:04 -05:00
parent 0a5138f7ca
commit 0b7e12a1fa
5 changed files with 19 additions and 5 deletions

View File

@@ -55,6 +55,7 @@ If you need help with Termix, you can join the [Discord](https://discord.gg/jVQG
# Show-off
![Demo Image](repo-images/DemoImage1.png)
![Demo Image](repo-images/DemoImage2.png)
# License
Distributed under the MIT license. See LICENSE for more information.

View File

@@ -1,5 +1,5 @@
# Stage 1: Build frontend
FROM --platform=$BUILDPLATFORM node:18-alpine AS frontend-builder
FROM --platform=$BUILDPLATFORM node:18 AS frontend-builder
WORKDIR /app
COPY package*.json ./
RUN npm install
@@ -7,7 +7,7 @@ COPY . .
RUN npm run build
# Stage 2: Build backend
FROM --platform=$BUILDPLATFORM node:18-alpine AS backend-builder
FROM --platform=$BUILDPLATFORM node:18 AS backend-builder
WORKDIR /app
COPY package*.json ./
RUN npm install
@@ -19,6 +19,8 @@ FROM mongo:5
RUN apt-get update && apt-get install -y \
curl \
nginx \
python3 \
build-essential \
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
@@ -28,8 +30,10 @@ RUN apt-get update && apt-get install -y \
COPY docker/nginx.conf /etc/nginx/nginx.conf
COPY --from=frontend-builder /app/dist /usr/share/nginx/html
# Copy backend
COPY --from=backend-builder /app/node_modules ./node_modules
# Setup backend
WORKDIR /app
COPY package*.json ./
RUN npm install --omit=dev
COPY --from=backend-builder /app/src/backend ./src/backend
# Create directories for MongoDB and nginx

View File

@@ -1,23 +1,32 @@
#!/bin/bash
set -e
# Start MongoDB
echo "Starting MongoDB..."
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
until mongosh --eval "print(\"waited for connection\")" > /dev/null 2>&1; do
sleep 0.5
done
echo "MongoDB has started"
# Start nginx
echo "Starting nginx..."
nginx
# Change to app directory
cd /app
# Start the SSH service
echo "Starting SSH service..."
node src/backend/ssh.cjs &
# Start the database service
echo "Starting database service..."
node src/backend/database.cjs &
# Keep the container running and show MongoDB logs
echo "All services started. Tailing MongoDB logs..."
tail -f $MONGODB_LOG_DIR/mongodb.log

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 KiB

After

Width:  |  Height:  |  Size: 454 KiB

BIN
repo-images/DemoImage2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 KiB