Clean up code
This commit is contained in:
@@ -2,13 +2,10 @@
|
||||
FROM node:18-alpine AS deps
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies for native modules
|
||||
RUN apk add --no-cache python3 make g++
|
||||
|
||||
# Copy dependency files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies with caching
|
||||
RUN npm ci --force && \
|
||||
npm cache clean --force
|
||||
|
||||
@@ -16,30 +13,24 @@ RUN npm ci --force && \
|
||||
FROM deps AS frontend-builder
|
||||
WORKDIR /app
|
||||
|
||||
# Copy source files
|
||||
COPY . .
|
||||
|
||||
# Build frontend
|
||||
RUN npm run build
|
||||
|
||||
# Stage 3: Build backend TypeScript
|
||||
FROM deps AS backend-builder
|
||||
WORKDIR /app
|
||||
|
||||
# Copy source files
|
||||
COPY . .
|
||||
|
||||
# Build backend TypeScript to JavaScript
|
||||
RUN npm run build:backend
|
||||
|
||||
# Stage 4: Production dependencies
|
||||
FROM node:18-alpine AS production-deps
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only production dependency files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install only production dependencies
|
||||
RUN npm ci --only=production --ignore-scripts --force && \
|
||||
npm cache clean --force
|
||||
|
||||
@@ -47,13 +38,10 @@ RUN npm ci --only=production --ignore-scripts --force && \
|
||||
FROM node:18-alpine AS native-builder
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache python3 make g++
|
||||
|
||||
# Copy dependency files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install only the native modules we need
|
||||
RUN npm ci --only=production bcryptjs better-sqlite3 --force && \
|
||||
npm cache clean --force
|
||||
|
||||
@@ -63,35 +51,26 @@ ENV DATA_DIR=/app/data \
|
||||
PORT=8080 \
|
||||
NODE_ENV=production
|
||||
|
||||
# Install dependencies in a single layer
|
||||
RUN apk add --no-cache nginx gettext su-exec && \
|
||||
mkdir -p /app/data && \
|
||||
chown -R node:node /app/data
|
||||
|
||||
# Setup nginx and frontend
|
||||
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY --from=frontend-builder /app/dist /usr/share/nginx/html
|
||||
RUN chown -R nginx:nginx /usr/share/nginx/html
|
||||
|
||||
# Setup backend
|
||||
WORKDIR /app
|
||||
|
||||
# Copy production dependencies and native modules
|
||||
COPY --from=production-deps /app/node_modules /app/node_modules
|
||||
COPY --from=native-builder /app/node_modules/bcryptjs /app/node_modules/bcryptjs
|
||||
COPY --from=native-builder /app/node_modules/better-sqlite3 /app/node_modules/better-sqlite3
|
||||
|
||||
# Copy compiled backend JavaScript
|
||||
COPY --from=backend-builder /app/dist/backend ./dist/backend
|
||||
|
||||
# Copy package.json for scripts
|
||||
COPY package.json ./
|
||||
|
||||
RUN chown -R node:node /app
|
||||
|
||||
VOLUME ["/app/data"]
|
||||
|
||||
# Expose ports
|
||||
EXPOSE ${PORT} 8081 8082 8083 8084
|
||||
|
||||
COPY docker/entrypoint.sh /entrypoint.sh
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
services:
|
||||
termix:
|
||||
#image: ghcr.io/lukegus/termix:latest
|
||||
image: ghcr.io/lukegus/termix:dev-1.0-development-latest
|
||||
image: ghcr.io/lukegus/termix:latest
|
||||
container_name: termix
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3800:8080"
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- termix-data:/app/data
|
||||
environment:
|
||||
# Generate random salt here https://www.lastpass.com/features/password-generator (max 32 characters, include all characters for settings)
|
||||
SALT: "2v.F7!6a!jIzmJsu|[)h61$ZMXs;,i+~"
|
||||
PORT: 8080
|
||||
|
||||
volumes:
|
||||
termix-data:
|
||||
|
||||
@@ -4,11 +4,9 @@ set -e
|
||||
export PORT=${PORT:-8080}
|
||||
echo "Configuring web UI to run on port: $PORT"
|
||||
|
||||
# Configure nginx with the correct port
|
||||
envsubst '${PORT}' < /etc/nginx/nginx.conf > /etc/nginx/nginx.conf.tmp
|
||||
mv /etc/nginx/nginx.conf.tmp /etc/nginx/nginx.conf
|
||||
|
||||
# Setup data directory
|
||||
mkdir -p /app/data
|
||||
chown -R node:node /app/data
|
||||
chmod 755 /app/data
|
||||
@@ -16,12 +14,10 @@ chmod 755 /app/data
|
||||
echo "Starting nginx..."
|
||||
nginx
|
||||
|
||||
# Start backend services
|
||||
echo "Starting backend services..."
|
||||
cd /app
|
||||
export NODE_ENV=production
|
||||
|
||||
# Start the compiled TypeScript backend
|
||||
if command -v su-exec > /dev/null 2>&1; then
|
||||
su-exec node node dist/backend/starter.js
|
||||
else
|
||||
@@ -30,5 +26,4 @@ fi
|
||||
|
||||
echo "All services started"
|
||||
|
||||
# Keep container running
|
||||
tail -f /dev/null
|
||||
Reference in New Issue
Block a user