Last active
August 16, 2024 08:30
Revisions
-
mogeko revised this gist
Aug 16, 2024 . 2 changed files with 28 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ #!/usr/bin/env node (async () => { const response = await fetch("http://localhost:3000/api/ping"); const result = await response.text(); if (!response.ok) { throw new Error(`Healthcheck failed: ${response.status}`); } else if (result !== "pong") { throw new Error(`Healthcheck failed: ${result} !== pong`); } else { console.info("\x1b[32m", "Healthcheck passed", "\x1b[0m"); } })().catch((error) => { console.error(error.message); process.exit(1); }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,23 @@ FROM docker.io/library/node:22-bookworm AS base ENV CI="true" PNPM_HOME="/opt/pnpm" PATH="/opt/pnpm:$PATH" RUN corepack enable pnpm WORKDIR /app FROM base AS preprocess COPY . /app RUN --mount=type=cache,id=pnpm,target=/opt/pnpm/store <<EOF turbo_version=$(node -p "require('./package.json').devDependencies.turbo") pnpm install --global "turbo@${turbo_version}" EOF RUN turbo prune web --docker FROM base AS builder COPY --from=preprocess /app/out/json /app RUN --mount=type=cache,id=pnpm,target=/opt/pnpm/store \ pnpm install --frozen-lockfile COPY --from=preprocess /app/out/full /app RUN pnpm run build --filter=web @@ -32,3 +32,7 @@ ENV HOSTNAME="0.0.0.0" PORT="3000" EXPOSE 3000 CMD ["/app/apps/web/server.js"] COPY --from=preprocess /app/scripts/healthcheck.cjs /app/healthcheck.cjs HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD ["/nodejs/bin/node", "/app/healthcheck.cjs"] -
mogeko revised this gist
Aug 15, 2024 . 1 changed file with 0 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,12 +13,6 @@ EOF RUN turbo prune web --docker FROM base AS builder COPY --from=turbo-prune /app/out/json /app RUN --mount=type=cache,id=pnpm,target=/root/pnpm/store \ @@ -29,7 +23,6 @@ RUN pnpm run build --filter=web FROM gcr.io/distroless/nodejs22-debian12 COPY --from=builder /app/apps/web/.next/standalone /app COPY --from=builder /app/apps/web/.next/static /app/apps/web/.next/static COPY --from=builder /app/apps/web/public /app/apps/web/public -
mogeko created this gist
Aug 12, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ FROM node:22-bookworm AS base ENV CI="true" PNPM_HOME="/root/pnpm" PATH="/root/pnpm:$PATH" RUN corepack enable pnpm WORKDIR /app FROM base AS turbo-prune COPY . /app RUN --mount=type=cache,id=pnpm,target=/root/pnpm/store <<EOF turbo_version=$(node -p "require('./package.json').devDependencies.turbo") pnpm install --global "turbo@${turbo_version}" EOF RUN turbo prune web --docker FROM base AS prod-deps COPY --from=turbo-prune /app/out/json /app RUN --mount=type=cache,id=pnpm,target=/root/pnpm/store \ pnpm install --prod --frozen-lockfile FROM base AS builder COPY --from=turbo-prune /app/out/json /app RUN --mount=type=cache,id=pnpm,target=/root/pnpm/store \ pnpm install --frozen-lockfile COPY --from=turbo-prune /app/out/full /app RUN pnpm run build --filter=web FROM gcr.io/distroless/nodejs22-debian12 COPY --from=prod-deps /app /app COPY --from=builder /app/apps/web/.next/standalone /app COPY --from=builder /app/apps/web/.next/static /app/apps/web/.next/static COPY --from=builder /app/apps/web/public /app/apps/web/public ENV HOSTNAME="0.0.0.0" PORT="3000" EXPOSE 3000 CMD ["/app/apps/web/server.js"]