From 8c52568d69d0c593e42de5855cf8af92e19ebeb7 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Sat, 11 Oct 2025 15:42:49 +0300 Subject: [PATCH 01/19] Update deploy.yaml --- .github/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From a0bab2d91f4c420e463cd6e89bcbebd37dad2f4d Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Sat, 11 Oct 2025 15:42:59 +0300 Subject: [PATCH 02/19] Change trigger branch from 'new-site-next' to 'main' --- .github/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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/**' From 8f48293634932d6101d5d33693adb9fc1bdd238a Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Sat, 11 Oct 2025 15:50:39 +0300 Subject: [PATCH 03/19] Fix .gitignore to include next-env.d.ts --- quackstack/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quackstack/.gitignore b/quackstack/.gitignore index ce4649f..2600acf 100644 --- a/quackstack/.gitignore +++ b/quackstack/.gitignore @@ -26,4 +26,4 @@ yarn-error.log* # typescript *.tsbuildinfo -next-env.d.ts \ No newline at end of file +next-env.d.ts From 238b729c0f585e6253b4e8045a640a9c980d9f4f Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Sat, 11 Oct 2025 16:36:05 +0300 Subject: [PATCH 04/19] Update package-lock.json From f2e7d301a6b61e81d98780baf029f03854739e80 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Sat, 11 Oct 2025 16:37:07 +0300 Subject: [PATCH 05/19] Fix formatting in package.json From e1ca7c3aaff0142ca1a5179f29b476782bca5097 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Sat, 11 Oct 2025 16:56:28 +0300 Subject: [PATCH 06/19] Update .gitignore From 6224b88a370c04fd7c693b4f71daf487349532b5 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:06:05 +0300 Subject: [PATCH 07/19] Update .gitignore --- quackstack/.gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/quackstack/.gitignore b/quackstack/.gitignore index 2600acf..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 From 9b3c938833c64d05b10d1d25bda9e33e453b9d49 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Sat, 11 Oct 2025 18:40:18 +0300 Subject: [PATCH 08/19] Delete deployment/docker-stacks.yaml --- deployment/docker-stacks.yaml | 45 ----------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 deployment/docker-stacks.yaml diff --git a/deployment/docker-stacks.yaml b/deployment/docker-stacks.yaml deleted file mode 100644 index b0655b5..0000000 --- a/deployment/docker-stacks.yaml +++ /dev/null @@ -1,45 +0,0 @@ -version: "3.8" - -services: - qs-site: - image: ghcr.io/quackstack-ltd/quackstack.net:latest - environment: - NODE_ENV: production - HOSTNAME: "0.0.0.0" - networks: - - shared_network - deploy: - replicas: 2 - restart_policy: - condition: on-failure - update_config: - parallelism: 1 - delay: 5s - order: start-first - labels: - - traefik.enable=true - - traefik.swarm.network=shared_network - - # Router for the website - - traefik.http.routers.qs-site.rule=Host(`site.quackstack.net`) - - traefik.http.routers.qs-site.entrypoints=websecure - - traefik.http.routers.qs-site.tls=true - - traefik.http.routers.qs-site.tls.certresolver=myresolver - - # Internal port for the service - - traefik.http.services.qs-site.loadbalancer.server.port=3000 - healthcheck: - test: - [ - "CMD-SHELL", - "set -e; \ - wget -q -T 10 -O /dev/null https://site.quackstack.net/ || exit 1" - ] - interval: 30s - timeout: 10s - retries: 5 - start_period: 30s - -networks: - shared_network: - external: true From e6267a72ee89d9fb080987a727bbe110299305bb Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Sat, 11 Oct 2025 18:40:42 +0300 Subject: [PATCH 09/19] Add Docker stack configuration for qs-site service --- deployment/docker-stack.yaml | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 deployment/docker-stack.yaml diff --git a/deployment/docker-stack.yaml b/deployment/docker-stack.yaml new file mode 100644 index 0000000..b0655b5 --- /dev/null +++ b/deployment/docker-stack.yaml @@ -0,0 +1,45 @@ +version: "3.8" + +services: + qs-site: + image: ghcr.io/quackstack-ltd/quackstack.net:latest + environment: + NODE_ENV: production + HOSTNAME: "0.0.0.0" + networks: + - shared_network + deploy: + replicas: 2 + restart_policy: + condition: on-failure + update_config: + parallelism: 1 + delay: 5s + order: start-first + labels: + - traefik.enable=true + - traefik.swarm.network=shared_network + + # Router for the website + - traefik.http.routers.qs-site.rule=Host(`site.quackstack.net`) + - traefik.http.routers.qs-site.entrypoints=websecure + - traefik.http.routers.qs-site.tls=true + - traefik.http.routers.qs-site.tls.certresolver=myresolver + + # Internal port for the service + - traefik.http.services.qs-site.loadbalancer.server.port=3000 + healthcheck: + test: + [ + "CMD-SHELL", + "set -e; \ + wget -q -T 10 -O /dev/null https://site.quackstack.net/ || exit 1" + ] + interval: 30s + timeout: 10s + retries: 5 + start_period: 30s + +networks: + shared_network: + external: true From e37c334ba49512585ea32f2a1d71bebea1f7900c Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Tue, 14 Oct 2025 09:20:42 +0300 Subject: [PATCH 10/19] Update next.config.mjs --- quackstack/next.config.mjs | 1 + 1 file changed, 1 insertion(+) 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); From 93b5349f5c01395d4610e6bf2f7f93e37a2853af Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Tue, 14 Oct 2025 09:35:51 +0300 Subject: [PATCH 11/19] Refactor Dockerfile for Next.js application --- quackstack/Dockerfile | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/quackstack/Dockerfile b/quackstack/Dockerfile index cb44a60..5db4133 100644 --- a/quackstack/Dockerfile +++ b/quackstack/Dockerfile @@ -1,51 +1,30 @@ -# syntax=docker.io/docker/dockerfile:1 - 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 - -# 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 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 -# 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 WORKDIR /app - ENV NODE_ENV=production -# Uncomment the following line in case you want to disable telemetry during runtime. -# ENV NEXT_TELEMETRY_DISABLED=1 +ENV HOSTNAME=0.0.0.0 +ENV PORT=3000 -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs +RUN addgroup --system --gid 1001 nodejs \ + && adduser --system --uid 1001 nextjs COPY --from=builder /app/public ./public +COPY --from=builder /app/.next/standalone ./ # contains server.js +COPY --from=builder /app/.next/static ./.next/static 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"] From 87aac35f347278521d98f286173916f64a1e3606 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Tue, 14 Oct 2025 09:40:08 +0300 Subject: [PATCH 12/19] Refactor Dockerfile COPY commands for clarity --- quackstack/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quackstack/Dockerfile b/quackstack/Dockerfile index 5db4133..57c46c0 100644 --- a/quackstack/Dockerfile +++ b/quackstack/Dockerfile @@ -21,9 +21,9 @@ ENV PORT=3000 RUN addgroup --system --gid 1001 nodejs \ && adduser --system --uid 1001 nextjs -COPY --from=builder /app/public ./public -COPY --from=builder /app/.next/standalone ./ # contains server.js +COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static +COPY --from=builder /app/public ./public USER nextjs EXPOSE 3000 From 317d3f2725091975beccec8b4b2d5925c46cba56 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:33:12 +0300 Subject: [PATCH 13/19] Update Dockerfile --- quackstack/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quackstack/Dockerfile b/quackstack/Dockerfile index 57c46c0..863f33f 100644 --- a/quackstack/Dockerfile +++ b/quackstack/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine AS base +FROM node:20 AS base FROM base AS deps RUN apk add --no-cache libc6-compat From d4be278dc8070d815dad89e244e20cae8468bc59 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Tue, 14 Oct 2025 12:20:47 +0300 Subject: [PATCH 14/19] Update Dockerfile for improved dependency management --- quackstack/Dockerfile | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/quackstack/Dockerfile b/quackstack/Dockerfile index 863f33f..27c74b7 100644 --- a/quackstack/Dockerfile +++ b/quackstack/Dockerfile @@ -1,30 +1,37 @@ -FROM node:20 AS base +FROM node:20-bookworm-slim AS base +ENV PNPM_HOME=/pnpm +ENV PATH=$PNPM_HOME:$PATH +RUN corepack enable pnpm FROM base AS deps -RUN apk add --no-cache libc6-compat +# Install only what you need; ca-certificates is useful if you ever curl HTTPS +RUN apt-get update \ + && apt-get install -y --no-install-recommends ca-certificates \ + && rm -rf /var/lib/apt/lists/* WORKDIR /app -COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./ -RUN corepack enable pnpm && pnpm i --frozen-lockfile +COPY package.json pnpm-lock.yaml .npmrc* ./ +RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \ + pnpm fetch --frozen-lockfile FROM base AS builder WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules +COPY --from=deps /pnpm/store /pnpm/store +COPY package.json pnpm-lock.yaml .npmrc* ./ +RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \ + pnpm install --frozen-lockfile --offline COPY . . -RUN corepack enable pnpm && pnpm run build +RUN pnpm run build -FROM base AS runner +FROM node:20-bookworm-slim AS runner WORKDIR /app -ENV NODE_ENV=production -ENV HOSTNAME=0.0.0.0 -ENV PORT=3000 - -RUN addgroup --system --gid 1001 nodejs \ - && adduser --system --uid 1001 nextjs - +ENV NODE_ENV=production HOSTNAME=0.0.0.0 PORT=3000 +# non-root user +RUN groupadd -g 1001 nodejs \ + && useradd -u 1001 -g nodejs -s /usr/sbin/nologin -m nextjs +# Copy standalone output produced by `output: 'standalone'` COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static COPY --from=builder /app/public ./public - USER nextjs EXPOSE 3000 CMD ["node", "server.js"] From 2a9be868117f65e1a21107f8ebe36d79206555c0 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Tue, 14 Oct 2025 12:25:38 +0300 Subject: [PATCH 15/19] Update Dockerfile --- quackstack/Dockerfile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/quackstack/Dockerfile b/quackstack/Dockerfile index 27c74b7..7db2e1a 100644 --- a/quackstack/Dockerfile +++ b/quackstack/Dockerfile @@ -4,34 +4,43 @@ ENV PATH=$PNPM_HOME:$PATH RUN corepack enable pnpm FROM base AS deps -# Install only what you need; ca-certificates is useful if you ever curl HTTPS +# HTTPS certs are useful for fetch; keep image lean RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY package.json pnpm-lock.yaml .npmrc* ./ +# Populate the pnpm store cache. This is a cache mount; no COPY later. RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \ pnpm fetch --frozen-lockfile FROM base AS builder WORKDIR /app -COPY --from=deps /pnpm/store /pnpm/store +# Bring in only the files that affect install; install from cached store offline COPY package.json pnpm-lock.yaml .npmrc* ./ RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \ pnpm install --frozen-lockfile --offline +# Now add the rest of the source and build COPY . . RUN pnpm run build FROM node:20-bookworm-slim AS runner WORKDIR /app -ENV NODE_ENV=production HOSTNAME=0.0.0.0 PORT=3000 -# non-root user +ENV NODE_ENV=production \ + HOSTNAME=0.0.0.0 \ + PORT=3000 +# Certs for HTTPS healthchecks and outbound calls +RUN apt-get update \ + && apt-get install -y --no-install-recommends ca-certificates \ + && rm -rf /var/lib/apt/lists/* +# Non-root user RUN groupadd -g 1001 nodejs \ && useradd -u 1001 -g nodejs -s /usr/sbin/nologin -m nextjs -# Copy standalone output produced by `output: 'standalone'` + COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static COPY --from=builder /app/public ./public + USER nextjs EXPOSE 3000 CMD ["node", "server.js"] From bfc4f752935595b0cded0c4171370350115d1d1e Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:35:28 +0300 Subject: [PATCH 16/19] Refactor Dockerfile for improved build process --- quackstack/Dockerfile | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/quackstack/Dockerfile b/quackstack/Dockerfile index 7db2e1a..a7b2b80 100644 --- a/quackstack/Dockerfile +++ b/quackstack/Dockerfile @@ -1,26 +1,18 @@ -FROM node:20-bookworm-slim AS base +FROM node:20-bookworm-slim AS builder ENV PNPM_HOME=/pnpm ENV PATH=$PNPM_HOME:$PATH -RUN corepack enable pnpm - -FROM base AS deps -# HTTPS certs are useful for fetch; keep image lean +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/* -WORKDIR /app -COPY package.json pnpm-lock.yaml .npmrc* ./ -# Populate the pnpm store cache. This is a cache mount; no COPY later. -RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \ - pnpm fetch --frozen-lockfile -FROM base AS builder WORKDIR /app -# Bring in only the files that affect install; install from cached store offline COPY package.json pnpm-lock.yaml .npmrc* ./ + RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \ - pnpm install --frozen-lockfile --offline -# Now add the rest of the source and build + pnpm install --frozen-lockfile + COPY . . RUN pnpm run build @@ -29,11 +21,11 @@ WORKDIR /app ENV NODE_ENV=production \ HOSTNAME=0.0.0.0 \ PORT=3000 -# Certs for HTTPS healthchecks and outbound calls + RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates \ && rm -rf /var/lib/apt/lists/* -# Non-root user + RUN groupadd -g 1001 nodejs \ && useradd -u 1001 -g nodejs -s /usr/sbin/nologin -m nextjs From 12fb9698fb9fd9aaa6560657301c81ad6a70aab5 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Tue, 21 Oct 2025 11:36:33 +0300 Subject: [PATCH 17/19] Update docker-stack.yaml --- deployment/docker-stack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/docker-stack.yaml b/deployment/docker-stack.yaml index b0655b5..44deb99 100644 --- a/deployment/docker-stack.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: From 09bd668fea044e83b326ca20e5e7414cfa4f0c10 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:10:22 +0300 Subject: [PATCH 18/19] Update CMD to point to the correct server path --- quackstack/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quackstack/Dockerfile b/quackstack/Dockerfile index a7b2b80..115e55f 100644 --- a/quackstack/Dockerfile +++ b/quackstack/Dockerfile @@ -35,4 +35,4 @@ COPY --from=builder /app/public ./public USER nextjs EXPOSE 3000 -CMD ["node", "server.js"] +CMD ["node", "apps/web/server.js"] From 0d89355b338ae47085157198d41c088592d1db1f Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:13:47 +0300 Subject: [PATCH 19/19] Update Dockerfile --- quackstack/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quackstack/Dockerfile b/quackstack/Dockerfile index 115e55f..a7b2b80 100644 --- a/quackstack/Dockerfile +++ b/quackstack/Dockerfile @@ -35,4 +35,4 @@ COPY --from=builder /app/public ./public USER nextjs EXPOSE 3000 -CMD ["node", "apps/web/server.js"] +CMD ["node", "server.js"]