Attempt #3 to auto compile MongoDB into the build to exclude it from the compose.
This commit is contained in:
@@ -55,6 +55,7 @@ If you need help with Termix, you can join the [Discord](https://discord.gg/jVQG
|
|||||||
# Show-off
|
# Show-off
|
||||||
|
|
||||||

|

|
||||||
|

|
||||||
|
|
||||||
# License
|
# License
|
||||||
Distributed under the MIT license. See LICENSE for more information.
|
Distributed under the MIT license. See LICENSE for more information.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Stage 1: Build frontend
|
# Stage 1: Build frontend
|
||||||
FROM --platform=$BUILDPLATFORM node:18-alpine AS frontend-builder
|
FROM --platform=$BUILDPLATFORM node:18 AS frontend-builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
@@ -7,7 +7,7 @@ COPY . .
|
|||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 2: Build backend
|
# Stage 2: Build backend
|
||||||
FROM --platform=$BUILDPLATFORM node:18-alpine AS backend-builder
|
FROM --platform=$BUILDPLATFORM node:18 AS backend-builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
@@ -19,6 +19,8 @@ FROM mongo:5
|
|||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
curl \
|
curl \
|
||||||
nginx \
|
nginx \
|
||||||
|
python3 \
|
||||||
|
build-essential \
|
||||||
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
|
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
|
||||||
&& apt-get install -y nodejs \
|
&& apt-get install -y nodejs \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
@@ -28,8 +30,10 @@ RUN apt-get update && apt-get install -y \
|
|||||||
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY --from=frontend-builder /app/dist /usr/share/nginx/html
|
COPY --from=frontend-builder /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
# Copy backend
|
# Setup backend
|
||||||
COPY --from=backend-builder /app/node_modules ./node_modules
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install --omit=dev
|
||||||
COPY --from=backend-builder /app/src/backend ./src/backend
|
COPY --from=backend-builder /app/src/backend ./src/backend
|
||||||
|
|
||||||
# Create directories for MongoDB and nginx
|
# Create directories for MongoDB and nginx
|
||||||
|
|||||||
@@ -1,23 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
# Start MongoDB
|
# Start MongoDB
|
||||||
|
echo "Starting MongoDB..."
|
||||||
mongod --fork --dbpath $MONGODB_DATA_DIR --logpath $MONGODB_LOG_DIR/mongodb.log
|
mongod --fork --dbpath $MONGODB_DATA_DIR --logpath $MONGODB_LOG_DIR/mongodb.log
|
||||||
|
|
||||||
# Wait for MongoDB to be ready
|
# Wait for MongoDB to be ready
|
||||||
echo "Waiting for MongoDB to start..."
|
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
|
sleep 0.5
|
||||||
done
|
done
|
||||||
echo "MongoDB has started"
|
echo "MongoDB has started"
|
||||||
|
|
||||||
# Start nginx
|
# Start nginx
|
||||||
|
echo "Starting nginx..."
|
||||||
nginx
|
nginx
|
||||||
|
|
||||||
|
# Change to app directory
|
||||||
|
cd /app
|
||||||
|
|
||||||
# Start the SSH service
|
# Start the SSH service
|
||||||
|
echo "Starting SSH service..."
|
||||||
node src/backend/ssh.cjs &
|
node src/backend/ssh.cjs &
|
||||||
|
|
||||||
# Start the database service
|
# Start the database service
|
||||||
|
echo "Starting database service..."
|
||||||
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
|
||||||
|
echo "All services started. Tailing MongoDB logs..."
|
||||||
tail -f $MONGODB_LOG_DIR/mongodb.log
|
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
BIN
repo-images/DemoImage2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 602 KiB |
Reference in New Issue
Block a user