Files
ttl.sh/web/Dockerfile
Marc Campbell f2ac28558f Add Next.js website with SSR support
- Create new Next.js app in web/ directory
- Configure standalone output for Docker deployment
- Add Dockerfile with multi-stage build
- Add web service to docker-compose.yaml
- Update nginx to proxy to Next.js container (port 3000)
- Remove static site deployment from Ansible

The website now runs as a containerized Next.js app with SSR,
enabling dynamic features and modern React development.

Note: Static site in static/ folder retained for reference.
Signed-off-by: Marc Campbell <marc.e.campbell@gmail.com>
2026-02-03 12:30:42 +00:00

42 lines
870 B
Docker

FROM node:20-alpine AS base
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]