Files
Termix/docker/Dockerfile
T

99 lines
2.2 KiB
Docker
Raw Normal View History

2025-08-07 02:20:27 -05:00
# Stage 1: Install dependencies and build frontend
FROM node:24-alpine AS deps
2025-08-07 02:20:27 -05:00
WORKDIR /app
RUN apk add --no-cache python3 make g++
COPY package*.json ./
2025-09-12 14:42:00 -05:00
ENV npm_config_target_platform=linux
ENV npm_config_target_arch=x64
ENV npm_config_target_libc=glibc
RUN npm ci --force --ignore-scripts && \
2025-08-07 02:20:27 -05:00
npm cache clean --force
# Stage 2: Build frontend
FROM deps AS frontend-builder
WORKDIR /app
COPY . .
RUN npm run build
# Stage 3: Build backend TypeScript
FROM deps AS backend-builder
WORKDIR /app
COPY . .
2025-09-12 14:42:00 -05:00
ENV npm_config_target_platform=linux
ENV npm_config_target_arch=x64
ENV npm_config_target_libc=glibc
RUN npm rebuild better-sqlite3 --force
2025-08-07 02:20:27 -05:00
RUN npm run build:backend
# Stage 4: Production dependencies
FROM node:24-alpine AS production-deps
2025-08-07 02:20:27 -05:00
WORKDIR /app
COPY package*.json ./
2025-09-12 14:42:00 -05:00
ENV npm_config_target_platform=linux
ENV npm_config_target_arch=x64
ENV npm_config_target_libc=glibc
2025-08-07 02:20:27 -05:00
RUN npm ci --only=production --ignore-scripts --force && \
npm cache clean --force
# Stage 5: Build native modules
FROM node:24-alpine AS native-builder
2025-08-07 02:20:27 -05:00
WORKDIR /app
RUN apk add --no-cache python3 make g++
COPY package*.json ./
2025-09-12 14:42:00 -05:00
ENV npm_config_target_platform=linux
ENV npm_config_target_arch=x64
ENV npm_config_target_libc=glibc
# Install native modules and compile them properly
RUN npm ci --only=production --force && \
npm rebuild better-sqlite3 bcryptjs --force && \
2025-08-07 02:20:27 -05:00
npm cache clean --force
# Stage 6: Final image
FROM node:24-alpine
2025-08-07 02:20:27 -05:00
ENV DATA_DIR=/app/data \
PORT=8080 \
NODE_ENV=production
RUN apk add --no-cache nginx gettext su-exec && \
mkdir -p /app/data && \
chown -R node:node /app/data
COPY docker/nginx.conf /etc/nginx/nginx.conf
COPY --from=frontend-builder /app/dist /usr/share/nginx/html
2025-09-12 14:42:00 -05:00
COPY --from=frontend-builder /app/src/locales /usr/share/nginx/html/locales
2025-08-07 02:20:27 -05:00
RUN chown -R nginx:nginx /usr/share/nginx/html
WORKDIR /app
2025-09-12 14:42:00 -05:00
COPY --from=native-builder /app/node_modules /app/node_modules
2025-08-07 02:20:27 -05:00
COPY --from=backend-builder /app/dist/backend ./dist/backend
COPY package.json ./
COPY .env ./.env
2025-08-07 02:20:27 -05:00
RUN chown -R node:node /app
VOLUME ["/app/data"]
EXPOSE ${PORT} 8081 8082 8083 8084 8085
2025-08-07 02:20:27 -05:00
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
2025-08-12 12:04:04 +02:00
CMD ["/entrypoint.sh"]