Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# dependencies
node_modules
.pnp
.pnp.*

# build output
.next
out
build
dist

# env files (provide at runtime, not build time)
.env
.env.local
.env.*.local

# version control
.git
.gitignore

# editor / tooling
.claude
.conductor
.ruby-lsp
.vscode
.idea
.DS_Store

# CI / docs / tests (not needed in image)
.github
docs
README.md
LICENSE
coverage
*.tsbuildinfo
next-env.d.ts
vitest.config.ts

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# vercel
.vercel

# docker
Dockerfile
.dockerignore
92 changes: 92 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# syntax=docker/dockerfile:1.7

# Multi-stage build for Next.js 16 (standalone output) on Node.js 22 (Alpine).
#
# Build (Spree env required: pages are prerendered against the Spree API at build time):
# docker build \
# --build-arg SPREE_API_URL=https://your-spree.example.com \
# --build-arg SPREE_PUBLISHABLE_KEY=your_publishable_key \
# -t storefront .
#
# Run:
# docker run -p 3001:3001 --env-file .env.local storefront
#
# Optional Sentry source map upload at build time (skipped when SENTRY_DSN is unset):
# docker build \
# --build-arg SPREE_API_URL=... \
# --build-arg SPREE_PUBLISHABLE_KEY=... \
# --build-arg SENTRY_DSN=... \
# --build-arg SENTRY_ORG=... \
# --build-arg SENTRY_PROJECT=... \
# --build-arg SENTRY_AUTH_TOKEN=... \
# -t storefront .
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

ARG NODE_VERSION=22-alpine


# ---- deps: install production+dev dependencies for the build ----
FROM node:${NODE_VERSION} AS deps
WORKDIR /app

# libc6-compat keeps a few native modules happy on Alpine (musl).
RUN apk add --no-cache libc6-compat

COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --include=dev


# ---- builder: compile the Next.js app ----
FROM node:${NODE_VERSION} AS builder
WORKDIR /app

ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production

# Spree API config — required at build time because the app prerenders pages
# that fetch from Spree (categories, products, etc.).
ARG SPREE_API_URL
ARG SPREE_PUBLISHABLE_KEY
ENV SPREE_API_URL=$SPREE_API_URL \
SPREE_PUBLISHABLE_KEY=$SPREE_PUBLISHABLE_KEY

# Optional Sentry release/source-map upload. When SENTRY_DSN is empty,
# next.config.ts skips withSentryConfig entirely, so the build still works.
ARG SENTRY_DSN=""
ARG SENTRY_ORG=""
ARG SENTRY_PROJECT=""
ARG SENTRY_AUTH_TOKEN=""
ENV SENTRY_DSN=$SENTRY_DSN \
SENTRY_ORG=$SENTRY_ORG \
SENTRY_PROJECT=$SENTRY_PROJECT \
SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN

COPY --from=deps /app/node_modules ./node_modules
COPY . .

RUN npm run build


# ---- runner: minimal runtime image ----
FROM node:${NODE_VERSION} AS runner
WORKDIR /app

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3001
ENV HOSTNAME=0.0.0.0

RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs

# Static assets and the standalone server bundle.
# The standalone output ships its own minimal node_modules.
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3001

CMD ["node", "server.js"]
1 change: 1 addition & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import createNextIntlPlugin from "next-intl/plugin";
const withNextIntl = createNextIntlPlugin();

const nextConfig: NextConfig = {
output: "standalone",
allowedDevOrigins: ["shop.lvh.me", "*.trycloudflare.com", "192.168.33.13"],
env: {
NEXT_PUBLIC_SENTRY_DSN: process.env.SENTRY_DSN || "",
Expand Down
5 changes: 5 additions & 0 deletions src/components/layout/CurrentYear.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"use client";

export function CurrentYear() {
return <>{new Date().getFullYear()}</>;
}
3 changes: 2 additions & 1 deletion src/components/layout/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Link from "next/link";
import { getTranslations } from "next-intl/server";
import { POLICY_LINKS } from "@/lib/constants/policies";
import { getStoreDescription, getStoreName } from "@/lib/store";
import { CurrentYear } from "./CurrentYear";

const storeName = getStoreName();
const storeDescription = getStoreDescription();
Expand Down Expand Up @@ -149,7 +150,7 @@ export async function Footer({

<div className="mt-8 pt-8 border-t border-neutral-800 text-xs text-neutral-400 text-center">
<p>
&copy; {new Date().getFullYear()} {storeName}. {t("poweredBy")}{" "}
&copy; <CurrentYear /> {storeName}. {t("poweredBy")}{" "}
<Link
href="https://spreecommerce.org"
target="_blank"
Expand Down
Loading