diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index 58d433b..efa1b47 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -3,7 +3,7 @@ name: Image Build & Push QS Off Site on: workflow_dispatch: push: - branches: [ new-site-next ] + branches: [ main ] paths: - 'quackstack/**' diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 118c46a..8a76721 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -4,7 +4,7 @@ on: workflow_run: workflows: [ "Image Build & Push QS Off Site" ] types: [ completed ] - branches: [ new-site-next ] + branches: [ main ] workflow_dispatch: diff --git a/deployment/docker-stacks.yaml b/deployment/docker-stack.yaml similarity index 98% rename from deployment/docker-stacks.yaml rename to deployment/docker-stack.yaml index b0655b5..44deb99 100644 --- a/deployment/docker-stacks.yaml +++ b/deployment/docker-stack.yaml @@ -9,7 +9,7 @@ services: networks: - shared_network deploy: - replicas: 2 + replicas: 1 restart_policy: condition: on-failure update_config: diff --git a/quackstack/.gitignore b/quackstack/.gitignore index ce4649f..612c00f 100644 --- a/quackstack/.gitignore +++ b/quackstack/.gitignore @@ -1,5 +1,3 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - # dependencies /node_modules @@ -26,4 +24,4 @@ yarn-error.log* # typescript *.tsbuildinfo -next-env.d.ts \ No newline at end of file +next-env.d.ts diff --git a/quackstack/Dockerfile b/quackstack/Dockerfile index cb44a60..a7b2b80 100644 --- a/quackstack/Dockerfile +++ b/quackstack/Dockerfile @@ -1,51 +1,38 @@ -# syntax=docker.io/docker/dockerfile:1 +FROM node:20-bookworm-slim AS builder +ENV PNPM_HOME=/pnpm +ENV PATH=$PNPM_HOME:$PATH +RUN corepack enable pnpm \ + && pnpm config set store-dir /pnpm/store +RUN apt-get update \ + && apt-get install -y --no-install-recommends ca-certificates \ + && rm -rf /var/lib/apt/lists/* -FROM node:20-alpine AS base - -# Install dependencies only when needed -FROM base AS deps -# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. -RUN apk add --no-cache libc6-compat WORKDIR /app +COPY package.json pnpm-lock.yaml .npmrc* ./ -# Install dependencies based on the preferred package manager -COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./ -RUN corepack enable pnpm && pnpm i --frozen-lockfile; - +RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \ + pnpm install --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 pnpm run build -# Next.js collects completely anonymous telemetry data about general usage. -# Learn more here: https://nextjs.org/telemetry -# Uncomment the following line in case you want to disable telemetry during the build. -# 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 +FROM node:20-bookworm-slim AS runner WORKDIR /app +ENV NODE_ENV=production \ + HOSTNAME=0.0.0.0 \ + PORT=3000 -ENV NODE_ENV=production -# Uncomment the following line in case you want to disable telemetry during runtime. -# ENV NEXT_TELEMETRY_DISABLED=1 +RUN apt-get update \ + && apt-get install -y --no-install-recommends ca-certificates \ + && rm -rf /var/lib/apt/lists/* -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs +RUN groupadd -g 1001 nodejs \ + && useradd -u 1001 -g nodejs -s /usr/sbin/nologin -m nextjs +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static COPY --from=builder /app/public ./public 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"] \ No newline at end of file +CMD ["node", "server.js"] diff --git a/quackstack/next.config.mjs b/quackstack/next.config.mjs index 5055cb0..3d72356 100644 --- a/quackstack/next.config.mjs +++ b/quackstack/next.config.mjs @@ -17,6 +17,7 @@ const nextConfig = { unoptimized: true, }, pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'], + output: 'standalone', }; export default withNextra(nextConfig);