web/Dockerfile
44 lines · 2025 bytes
1###############################################################################
2# A lightweight, non-root, multi-stage, cross-architecture Dockerfile #
3# That you can use in order to easily deploy Awesome Privacy to any server #
4# For docs visit the GitHub repo: https://github.com/lissy93/awesome-privacy #
5# Licensed under MIT (C) Alicia Sykes <https://aliciasykes.com> 2024 #
6###############################################################################
7# Usage: #
8# Step 1: Build the Docker image #
9# docker build -t awesome-privacy . #
10# #
11# Step 2: Run the Docker container #
12# docker run -p 8080:80 awesome-privacy #
13# #
14# Step 3: Access the running app #
15# Open your browser and navigate to http://127.0.0.1:8080 #
16###############################################################################
17
18# Stage 1: Install deps
19FROM node:24-alpine AS deps
20WORKDIR /app
21RUN corepack enable
22COPY package.json yarn.lock .yarnrc.yml ./
23COPY .yarn .yarn
24RUN yarn install --immutable
25
26# Stage 2: Build the site (SSG + standalone Node server)
27FROM node:24-alpine AS build
28WORKDIR /app
29RUN corepack enable
30COPY --from=deps /app/node_modules ./node_modules
31COPY . .
32ENV DEPLOY_TARGET=node OUTPUT=static
33RUN yarn build
34
35# Stage 3: Production runtime (non-root, minimal)
36FROM node:24-alpine AS runtime
37RUN addgroup -S app && adduser -S app -G app
38WORKDIR /app
39COPY --from=build --chown=app:app /app/dist ./dist
40COPY --from=deps --chown=app:app /app/node_modules ./node_modules
41USER app
42ENV HOST=0.0.0.0 PORT=80
43EXPOSE 80
44CMD ["node", "dist/server/entry.mjs"]