Files
swiss-datashare/Dockerfile

66 lines
2.2 KiB
Docker
Raw Normal View History

# Stage 1: Frontend dependencies
2025-04-23 08:33:00 +02:00
FROM node:22-alpine AS frontend-dependencies
WORKDIR /opt/app
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci --prefer-offline --no-audit --progress=false
2022-12-10 15:34:01 +01:00
# Stage 2: Build frontend
2025-04-23 08:33:00 +02:00
FROM node:22-alpine AS frontend-builder
2022-12-10 15:34:01 +01:00
WORKDIR /opt/app
COPY ./frontend .
2022-12-10 15:34:01 +01:00
COPY --from=frontend-dependencies /opt/app/node_modules ./node_modules
RUN npm run build
# Stage 3: Backend dependencies
2025-04-23 08:33:00 +02:00
FROM node:22-alpine AS backend-dependencies
feat(auth): add OAuth2 login (#276) * feat(auth): add OAuth2 login with GitHub and Google * chore(translations): add files for Japanese * fix(auth): fix link function for GitHub * feat(oauth): basic oidc implementation * feat(oauth): oauth guard * fix: disable image optimizations for logo to prevent caching issues with custom logos * fix: memory leak while downloading large files * chore(translations): update translations via Crowdin (#278) * New translations en-us.ts (Japanese) * New translations en-us.ts (Japanese) * New translations en-us.ts (Japanese) * release: 0.18.2 * doc(translations): Add Japanese README (#279) * Added Japanese README. * Added JAPANESE README link to README.md. * Updated Japanese README. * Updated Environment Variable Table. * updated zh-cn README. * feat(oauth): unlink account * refactor(oauth): make providers extensible * fix(oauth): fix discoveryUri error when toggle google-enabled * feat(oauth): add microsoft and discord as oauth provider * docs(oauth): update README.md * docs(oauth): update oauth2-guide.md * set password to null for new oauth users * New translations en-us.ts (Japanese) (#281) * chore(translations): add Polish files * fix(oauth): fix random username and password * feat(oauth): add totp * fix(oauth): fix totp throttle * fix(oauth): fix qrcode and remove comment * feat(oauth): add error page * fix(oauth): i18n of error page * feat(auth): add OAuth2 login * fix(auth): fix link function for GitHub * feat(oauth): basic oidc implementation * feat(oauth): oauth guard * feat(oauth): unlink account * refactor(oauth): make providers extensible * fix(oauth): fix discoveryUri error when toggle google-enabled * feat(oauth): add microsoft and discord as oauth provider * docs(oauth): update README.md * docs(oauth): update oauth2-guide.md * set password to null for new oauth users * fix(oauth): fix random username and password * feat(oauth): add totp * fix(oauth): fix totp throttle * fix(oauth): fix qrcode and remove comment * feat(oauth): add error page * fix(oauth): i18n of error page * refactor: return null instead of `false` in `getIdOfCurrentUser` functiom * feat: show original oauth error if available * refactor: run formatter * refactor(oauth): error message i18n * refactor(oauth): make OAuth token available someone may use it (to revoke token or get other info etc.) also improved the i18n message * chore(oauth): remove unused import * chore: add database migration * fix: missing python installation for nanoid --------- Co-authored-by: Elias Schneider <login@eliasschneider.com> Co-authored-by: ふうせん <10260662+fusengum@users.noreply.github.com>
2023-10-22 22:09:53 +08:00
RUN apk add --no-cache python3
WORKDIR /opt/app
COPY backend/package.json backend/package-lock.json ./
RUN npm ci --prefer-offline --no-audit --progress=false || \
(echo "npm ci failed, retrying without cache..." && npm ci --no-audit --progress=false)
2022-12-10 15:34:01 +01:00
# Stage 4: Build backend
2025-04-23 08:33:00 +02:00
FROM node:22-alpine AS backend-builder
RUN apk add openssl
2022-12-10 15:34:01 +01:00
WORKDIR /opt/app
COPY ./backend .
2022-12-10 15:34:01 +01:00
COPY --from=backend-dependencies /opt/app/node_modules ./node_modules
RUN npx prisma generate
RUN npm run build && npm prune --production
2022-12-10 15:34:01 +01:00
# Stage 5: Final image
2025-04-23 08:33:00 +02:00
FROM node:22-alpine AS runner
ENV NODE_ENV=docker
# Delete default node user
RUN deluser --remove-home node
RUN apk update --no-cache \
&& apk upgrade --no-cache \
&& apk add --no-cache curl caddy su-exec openssl
2022-12-08 23:21:31 +01:00
WORKDIR /opt/app/frontend
COPY --from=frontend-builder /opt/app/public ./public
2022-12-10 15:34:01 +01:00
COPY --from=frontend-builder /opt/app/.next/standalone ./
COPY --from=frontend-builder /opt/app/.next/static ./.next/static
COPY --from=frontend-builder /opt/app/public/img /tmp/img
WORKDIR /opt/app/backend
COPY --from=backend-builder /opt/app/node_modules ./node_modules
COPY --from=backend-builder /opt/app/dist ./dist
COPY --from=backend-builder /opt/app/prisma ./prisma
COPY --from=backend-builder /opt/app/package.json ./
COPY --from=backend-builder /opt/app/tsconfig.json ./
2022-12-08 23:21:31 +01:00
WORKDIR /opt/app
2024-12-24 16:06:59 +01:00
COPY ./reverse-proxy /opt/app/reverse-proxy
COPY ./scripts/docker ./scripts/docker
EXPOSE 3000
HEALTHCHECK --interval=10s --timeout=3s CMD /bin/sh -c '(if [[ "$CADDY_DISABLED" = "true" ]]; then curl -fs http://localhost:${BACKEND_PORT:-8080}/api/health; else curl -fs http://localhost:3000/api/health; fi) || exit 1'
2023-04-27 22:31:06 +02:00
ENTRYPOINT ["sh", "./scripts/docker/create-user.sh"]
CMD ["sh", "./scripts/docker/entrypoint.sh"]