diff --git a/old/.dockerignore b/.dockerignore similarity index 57% rename from old/.dockerignore rename to .dockerignore index 4b720b6..6ad4181 100644 --- a/old/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ node_modules -.next/ -next-env.d.ts -#env* +.nuxt/ +.output/ +dist +env* push-subscriptions.json diff --git a/old/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml similarity index 100% rename from old/.forgejo/workflows/build.yaml rename to .forgejo/workflows/build.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1dfde30 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# syntax=docker.io/docker/dockerfile:1 +# Based on Next.js's docker image example +FROM node:22 AS base + +# Install dependencies only when needed +FROM base AS deps +WORKDIR /app + +COPY package.json pnpm-lock.yaml* ./ +RUN corepack enable pnpm && pnpm i --frozen-lockfile + +# Rebuild the source code only when needed +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +RUN corepack enable pnpm && pnpm run build + +# Production image, copy all the files and run next +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV=production + +COPY --from=builder /app/.output ./ +COPY --chown=node:node schedule.json . +RUN echo '[]' > push-subscriptions.json && chown node:node push-subscriptions.json + +USER node + +EXPOSE 3000 + +ENV PORT=3000 +ENV HOST="0.0.0.0" + +CMD ["node", "server/index.mjs"] diff --git a/old/Dockerfile b/old/Dockerfile deleted file mode 100644 index 563b5e9..0000000 --- a/old/Dockerfile +++ /dev/null @@ -1,48 +0,0 @@ -# syntax=docker.io/docker/dockerfile:1 -FROM node:22 AS base - -# Install dependencies only when needed -FROM base AS deps -WORKDIR /app - -COPY package.json pnpm-lock.yaml* ./ -RUN corepack enable pnpm && pnpm i --frozen-lockfile - -# Rebuild the source code only when needed -FROM base AS builder -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . - -ENV NEXT_TELEMETRY_DISABLED=1 -RUN corepack enable pnpm && pnpm run build - -# Production image, copy all the files and run next -FROM base AS runner -WORKDIR /app - -ENV NODE_ENV=production -ENV NEXT_TELEMETRY_DISABLED=1 - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs - -COPY --from=builder /app/public ./public - -# Automatically leverage output traces to reduce image size -# https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static -COPY --chown=nextjs:nodejs schedule.json . -RUN echo '[]' > push-subscriptions.json && chown nextjs:nodejs push-subscriptions.json - -USER nextjs - -EXPOSE 3000 - -ENV PORT=3000 - -# server.js is created by next build from the standalone output -# https://nextjs.org/docs/pages/api-reference/config/next-config-js/output -ENV HOSTNAME="0.0.0.0" -CMD ["node", "server.js"]