-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
2,987 additions
and
4,106 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
"deep": true, | ||
"install": "always", | ||
"packageManager": "pnpm", | ||
"reject": [] | ||
"reject": ["typescript", "eslint"] | ||
} |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,49 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"typescript.enablePromptUseWorkspaceTsdk": true, | ||
"typescript.enablePromptUseWorkspaceTsdk": false, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "explicit", | ||
"source.fixAll.eslint": "always" | ||
}, | ||
"eslint.workingDirectories": [{ "mode": "auto" }], | ||
"eslint.workingDirectories": [ | ||
{ | ||
"mode": "auto" | ||
} | ||
], | ||
"eslint.format.enable": true, | ||
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"], | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
"typescript", | ||
"typescriptreact" | ||
], | ||
"files.associations": { | ||
"*.mdx": "markdown" | ||
"*.css": "tailwindcss", | ||
"*.mdx": "markdown", | ||
"*.yml.example": "yaml" | ||
}, | ||
"search.exclude": { | ||
"**/.husky": true, | ||
"**/.output": true, | ||
"**/build": true, | ||
"**/dist": true, | ||
}, | ||
"tailwindCSS.emmetCompletions": true, | ||
"tailwindCSS.experimental.classRegex": [ | ||
"tw`([^`]*)", // tw`...` | ||
"tw\\.[^`]+`([^`]*)`", // tw.xxx<xxx>`...` | ||
"tw\\(.*?\\).*?`([^`]*)", // tw(Component)<xxx>`...` | ||
"cn\\(([^)]*)\\)", | ||
"clx\\(([^)]*)\\)", | ||
"cva\\(([^)]*)\\)" | ||
[ | ||
"clsx\\(([^)]*)\\)", | ||
"(?:'|\"|`)([^']*)(?:'|\"|`)" | ||
], | ||
"cn\\(([^)]*)\\)", // cn(xxx) | ||
"clx\\(([^)]*)\\)", // clx(xxx) | ||
"cx\\(([^)]*)\\)", // cx(xxx) | ||
], | ||
"[toml]": { | ||
"editor.formatOnSave": false | ||
"editor.formatOnSave": false, | ||
"editor.defaultFormatter": "tamasfe.even-better-toml" | ||
}, | ||
"[markdown]": { | ||
"editor.defaultFormatter": "darkriszty.markdown-table-prettify" | ||
} | ||
} |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,86 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
# syntax=docker/dockerfile:1.7 | ||
|
||
# Arguments with default value (for build). | ||
ARG RUN_IMAGE=gcr.io/distroless/nodejs20-debian12 | ||
ARG PLATFORM=linux/amd64 | ||
ARG NODE_VERSION=20 | ||
ARG NODE_ENV=production | ||
|
||
# @reference: https://nextjs.org/docs/pages/api-reference/next-config-js/output | ||
ARG HOSTNAME=localhost | ||
ARG PORT=3000 | ||
|
||
# Arguments for envars in runner step. | ||
ARG NEXT_PUBLIC_SITE_URL | ||
|
||
# ----------------------------------------------------------------------------- | ||
# This is base image with `pnpm` package manager | ||
# Base image with pnpm package manager. | ||
# ----------------------------------------------------------------------------- | ||
FROM node:${NODE_VERSION}-alpine AS base | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN apk update && apk add --no-cache jq libc6-compat | ||
RUN corepack enable && corepack prepare pnpm@latest-8 --activate | ||
WORKDIR /app | ||
FROM --platform=$PLATFORM node:${NODE_VERSION}-bookworm-slim AS base | ||
ENV PNPM_HOME="/pnpm" PATH="$PNPM_HOME:$PATH" COREPACK_ENABLE_DOWNLOAD_PROMPT=0 | ||
ENV LEFTHOOK=0 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=true NEXT_TELEMETRY_DISABLED=1 | ||
RUN corepack enable && corepack prepare pnpm@latest-9 --activate | ||
WORKDIR /srv | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Build the application | ||
# Install dependencies and some toolchains. | ||
# ----------------------------------------------------------------------------- | ||
FROM base AS builder | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
ENV NEXT_PUBLIC_SITE_URL $NEXT_PUBLIC_SITE_URL | ||
# Required for building the application. | ||
ENV NEXT_PUBLIC_SITE_URL=http://localhost:3000 | ||
|
||
# Copy the source files | ||
COPY --chown=node:node . . | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm add sharp | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --no-optional | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm build | ||
|
||
# Install dependencies for production | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile | ||
RUN apt update && apt -yqq install tini jq | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install \ | ||
--ignore-scripts && pnpm add sharp && pnpm build | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Production image, copy build output files and run the application | ||
# Compile the application and install production only dependencies. | ||
# ----------------------------------------------------------------------------- | ||
FROM node:${NODE_VERSION}-alpine AS runner | ||
LABEL org.opencontainers.image.source="https://github.com/riipandi/next-start" | ||
FROM base AS pruner | ||
|
||
ENV NEXT_PUBLIC_SITE_URL $NEXT_PUBLIC_SITE_URL | ||
# Required generated files | ||
COPY --from=builder /srv/.next/standalone /srv/.next/standalone | ||
COPY --from=builder /srv/.next/static /srv/.next/standalone/.next/static | ||
COPY --from=builder /srv/public /srv/.next/standalone/public | ||
|
||
ENV HOSTNAME $HOSTNAME | ||
ENV NODE_ENV $NODE_ENV | ||
ENV PORT $PORT | ||
# Required metadata files | ||
COPY --from=builder /srv/package.json /srv/package.json | ||
COPY --from=builder /srv/pnpm-lock.yaml /srv/pnpm-lock.yaml | ||
COPY --from=builder /srv/next.config.mjs /srv/next.config.mjs | ||
COPY --from=builder /srv/.npmrc /srv/.npmrc | ||
|
||
WORKDIR /app | ||
# Install production dependencies and cleanup node_modules. | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install \ | ||
--prod --frozen-lockfile --ignore-scripts && pnpm prune --prod \ | ||
--ignore-scripts && pnpm dlx clean-modules clean --directory \ | ||
".next/standalone/node_modules" --yes | ||
|
||
# Don't run production as root, spawns command as a child process. | ||
RUN addgroup --system --gid 1001 nonroot && adduser --system --uid 1001 nonroot | ||
RUN apk update && apk add --no-cache tini | ||
# ----------------------------------------------------------------------------- | ||
# Production image, copy build output files and run the application. | ||
# ----------------------------------------------------------------------------- | ||
FROM --platform=$PLATFORM $RUN_IMAGE AS runner | ||
LABEL org.opencontainers.image.source="https://github.com/riipandi/next-start" | ||
|
||
# ----- Read application environment variables -------------------------------- | ||
|
||
ARG NEXT_PUBLIC_SITE_URL | ||
ENV NEXT_PUBLIC_SITE_URL=$NEXT_PUBLIC_SITE_URL | ||
|
||
# ----- Read application environment variables -------------------------------- | ||
|
||
# Copy the build output files from the pruner stage. | ||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder --chown=nonroot:nonroot /app/.next/standalone ./ | ||
COPY --from=builder --chown=nonroot:nonroot /app/.next/static ./.next/static | ||
COPY --from=builder --chown=nonroot:nonroot /app/public ./public | ||
COPY --from=builder --chown=nonroot:nonroot /app/next.config.mjs . | ||
# @ref: https://nextjs.org/docs/app/api-reference/next-config-js/output | ||
COPY --from=pruner --chown=nonroot:nonroot /srv/.next/standalone /srv | ||
COPY --from=pruner --chown=nonroot:nonroot /srv/next.config.mjs /srv/next.config.mjs | ||
|
||
# Copy some utilities from builder image. | ||
COPY --from=builder /usr/bin/tini /usr/bin/tini | ||
|
||
# Define the host and port to listen on. | ||
ARG NODE_ENV=production HOSTNAME=0.0.0.0 PORT=3000 | ||
ENV NEXT_TELEMETRY_DISABLED=1 TINI_SUBREAPER=true | ||
ENV NODE_ENV=$NODE_ENV HOSTNAME=$HOST PORT=$PORT | ||
|
||
WORKDIR /srv | ||
USER nonroot:nonroot | ||
EXPOSE $PORT | ||
|
||
ENTRYPOINT ["/sbin/tini", "--"] | ||
CMD ["node", "server.js"] | ||
ENTRYPOINT ["/usr/bin/tini", "--"] | ||
CMD ["/nodejs/bin/node", "/srv/server.js"] |
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json | ||
|
||
services: | ||
pgsql: | ||
image: postgres:17-alpine | ||
container_name: next_start_pgsql | ||
hostname: postgres | ||
restart: unless-stopped | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- pgsql_data:/var/lib/postgresql/data | ||
- ./scripts/pgsql-multidb.sh:/docker-entrypoint-initdb.d/multidb.sh | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: securedb | ||
POSTGRES_MULTIPLE_DATABASES: next_start,extra_db | ||
command: ['postgres', '-c', 'wal_level=logical'] | ||
healthcheck: | ||
test: ['CMD-SHELL', 'pg_isready -U postgres -d next_start'] | ||
interval: 30s | ||
timeout: 20s | ||
retries: 3 | ||
|
||
pgweb: | ||
image: sosedoff/pgweb:latest | ||
container_name: next_start_pgweb | ||
restart: always | ||
ports: | ||
- 54321:8081 | ||
environment: | ||
PGWEB_DATABASE_URL: 'postgres://postgres:securedb@pgsql:5432/next_start?sslmode=disable' | ||
depends_on: | ||
pgsql: | ||
condition: service_started | ||
|
||
mailpit: | ||
image: axllent/mailpit:latest | ||
container_name: next_start_mailpit | ||
restart: unless-stopped | ||
volumes: | ||
- mailpit_data:/data | ||
ports: | ||
- 1025:1025 # port the SMTP server should be accessible on | ||
- 8025:8025 # port the web interface should be accessible on | ||
environment: | ||
# https://github.com/axllent/mailpit/wiki/Runtime-options | ||
# MP_UI_AUTH: 'user1:password1 user2:password2' | ||
TZ: Asia/Jakarta | ||
|
||
volumes: | ||
pgsql_data: | ||
driver: local | ||
mailpit_data: | ||
driver: local |
This file contains 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 characters
This file contains 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 characters
Oops, something went wrong.