2025-05-23 18:11:43 +02:00
|
|
|
FROM node:22.16.0-alpine AS base
|
2024-03-16 15:51:34 +01:00
|
|
|
|
|
|
|
|
FROM base AS builder
|
2024-04-07 11:32:29 +02:00
|
|
|
RUN apk add --no-cache libc6-compat
|
2024-03-16 15:51:34 +01:00
|
|
|
RUN apk update
|
2024-07-25 19:52:31 +02:00
|
|
|
|
2024-03-16 15:51:34 +01:00
|
|
|
# Set working directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
RUN apk add --no-cache libc6-compat curl bash
|
|
|
|
|
RUN apk update
|
2024-12-04 21:37:27 +01:00
|
|
|
COPY . .
|
2024-10-24 22:45:36 +02:00
|
|
|
|
2025-02-03 19:10:49 +01:00
|
|
|
# Install working version of corepack (See https://github.com/nodejs/corepack/issues/612)
|
|
|
|
|
RUN npm install -g corepack@0.31.0 && corepack --version
|
2024-09-21 11:36:21 +02:00
|
|
|
RUN corepack enable pnpm && pnpm install --recursive --frozen-lockfile
|
2024-05-10 23:46:01 +02:00
|
|
|
|
|
|
|
|
# Copy static data as it is not part of the build
|
|
|
|
|
COPY static-data ./static-data
|
2024-07-25 19:52:31 +02:00
|
|
|
ARG SKIP_ENV_VALIDATION='true'
|
2024-10-03 19:59:44 +02:00
|
|
|
ARG CI='true'
|
2024-07-25 19:52:31 +02:00
|
|
|
ARG DISABLE_REDIS_LOGS='true'
|
2025-02-03 19:10:49 +01:00
|
|
|
# Install working version of corepack (See https://github.com/nodejs/corepack/issues/612)
|
|
|
|
|
RUN npm install -g corepack@0.31.0 && corepack --version
|
2024-07-25 19:52:31 +02:00
|
|
|
RUN corepack enable pnpm && pnpm build
|
2024-03-16 15:51:34 +01:00
|
|
|
|
|
|
|
|
FROM base AS runner
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2024-12-31 11:30:29 +01:00
|
|
|
# gettext is required for envsubst, openssl for generating AUTH_SECRET, su-exec for running application as non-root
|
|
|
|
|
RUN apk add --no-cache redis nginx bash gettext su-exec openssl
|
2024-05-12 16:28:44 +02:00
|
|
|
RUN mkdir /appdata
|
2024-05-20 17:34:16 +02:00
|
|
|
VOLUME /appdata
|
2024-04-07 11:32:29 +02:00
|
|
|
|
2024-08-04 21:44:51 +02:00
|
|
|
# Enable homarr cli
|
2024-12-31 11:36:28 +01:00
|
|
|
COPY --from=builder /app/packages/cli/cli.cjs /app/apps/cli/cli.cjs
|
2024-08-04 21:44:51 +02:00
|
|
|
RUN echo $'#!/bin/bash\ncd /app/apps/cli && node ./cli.cjs "$@"' > /usr/bin/homarr
|
|
|
|
|
RUN chmod +x /usr/bin/homarr
|
|
|
|
|
|
|
|
|
|
# Don't run production as root
|
2024-12-31 11:36:28 +01:00
|
|
|
RUN mkdir -p /var/cache/nginx && \
|
|
|
|
|
mkdir -p /var/log/nginx && \
|
|
|
|
|
mkdir -p /var/lib/nginx && \
|
|
|
|
|
touch /run/nginx/nginx.pid && \
|
|
|
|
|
mkdir -p /etc/nginx/templates /etc/nginx/ssl/certs
|
2024-03-16 15:51:34 +01:00
|
|
|
|
2025-01-06 19:59:25 +01:00
|
|
|
COPY --from=builder /app/apps/nextjs/next.config.ts .
|
2024-12-04 21:37:27 +01:00
|
|
|
COPY --from=builder /app/apps/nextjs/package.json .
|
2024-03-16 15:51:34 +01:00
|
|
|
|
2024-12-31 11:36:28 +01:00
|
|
|
COPY --from=builder /app/apps/tasks/tasks.cjs ./apps/tasks/tasks.cjs
|
|
|
|
|
COPY --from=builder /app/apps/websocket/wssServer.cjs ./apps/websocket/wssServer.cjs
|
|
|
|
|
COPY --from=builder /app/node_modules/better-sqlite3/build/Release/better_sqlite3.node /app/build/better_sqlite3.node
|
2024-04-07 11:32:29 +02:00
|
|
|
|
2024-12-31 11:36:28 +01:00
|
|
|
COPY --from=builder /app/packages/db/migrations ./db/migrations
|
2024-03-16 15:51:34 +01:00
|
|
|
|
|
|
|
|
# Automatically leverage output traces to reduce image size
|
|
|
|
|
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
2024-12-31 11:36:28 +01:00
|
|
|
COPY --from=builder /app/apps/nextjs/.next/standalone ./
|
|
|
|
|
COPY --from=builder /app/apps/nextjs/.next/static ./apps/nextjs/.next/static
|
|
|
|
|
COPY --from=builder /app/apps/nextjs/public ./apps/nextjs/public
|
|
|
|
|
COPY scripts/run.sh ./run.sh
|
|
|
|
|
COPY --chmod=777 scripts/entrypoint.sh ./entrypoint.sh
|
|
|
|
|
COPY packages/redis/redis.conf /app/redis.conf
|
|
|
|
|
COPY nginx.conf /etc/nginx/templates/nginx.conf
|
2024-09-16 18:10:58 +02:00
|
|
|
|
2024-03-16 15:51:34 +01:00
|
|
|
|
2024-05-12 16:28:44 +02:00
|
|
|
ENV DB_URL='/appdata/db/db.sqlite'
|
2024-05-10 23:46:01 +02:00
|
|
|
ENV DB_DIALECT='sqlite'
|
|
|
|
|
ENV DB_DRIVER='better-sqlite3'
|
2024-07-25 19:52:31 +02:00
|
|
|
ENV AUTH_PROVIDERS='credentials'
|
2025-01-30 22:14:52 +01:00
|
|
|
ENV NODE_ENV='production'
|
2024-03-16 15:51:34 +01:00
|
|
|
|
2024-12-18 14:10:43 +01:00
|
|
|
ENTRYPOINT [ "/app/entrypoint.sh" ]
|
2025-02-03 19:10:49 +01:00
|
|
|
CMD ["sh", "run.sh"]
|