Commit be21eba931
Unsigned
Layout: unified · split
web/Dockerfile +23 −11
| @@ -1,7 +1,7 @@ | |||
| 1 | ############################################################################### | 1 | ############################################################################### |
| 2 | # A lightweight, non-root, multi-stage, cross-architecture Dockerfile # | 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 # | 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 # | 4 | # For docs visit the GitHub repo: https://github.com/lissy93/awesome-privacy # |
| 5 | # Licensed under MIT (C) Alicia Sykes <https://aliciasykes.com> 2024 # | 5 | # Licensed under MIT (C) Alicia Sykes <https://aliciasykes.com> 2024 # |
| 6 | ############################################################################### | 6 | ############################################################################### |
| 7 | # Usage: # | 7 | # Usage: # |
| @@ -15,18 +15,30 @@ | |||
| 15 | # Open your browser and navigate to http://127.0.0.1:8080 # | 15 | # Open your browser and navigate to http://127.0.0.1:8080 # |
| 16 | ############################################################################### | 16 | ############################################################################### |
| 17 | 17 | ||
| 18 | # Stage 1: Build the app (Alpine + Node.js) | 18 | # Stage 1: Install deps |
| 19 | # Copies manifest and src files from host, installs deps, and builds the app | 19 | FROM node:24-alpine AS deps |
| 20 | FROM node:16-alpine as build | ||
| 21 | WORKDIR /app | 20 | WORKDIR /app |
| 22 | COPY package.json yarn.lock .env* ./ | 21 | RUN corepack enable |
| 23 | RUN yarn install --frozen-lockfile | 22 | COPY package.json yarn.lock .yarnrc.yml ./ |
| 23 | COPY .yarn .yarn | ||
| 24 | RUN yarn install --immutable | ||
| 25 | |||
| 26 | # Stage 2: Build the site (SSG + standalone Node server) | ||
| 27 | FROM node:24-alpine AS build | ||
| 28 | WORKDIR /app | ||
| 29 | RUN corepack enable | ||
| 30 | COPY --from=deps /app/node_modules ./node_modules | ||
| 24 | COPY . . | 31 | COPY . . |
| 32 | ENV DEPLOY_TARGET=node OUTPUT=static | ||
| 25 | RUN yarn build | 33 | RUN yarn build |
| 26 | 34 | ||
| 27 | # Stage 2: Serve the app (Alpine + NGINX) | 35 | # Stage 3: Production runtime (non-root, minimal) |
| 28 | # Copies dist from the previous stage, exposes port 80, and starts web server | 36 | FROM node:24-alpine AS runtime |
| 29 | FROM nginx:alpine as runtime | 37 | RUN addgroup -S app && adduser -S app -G app |
| 30 | COPY --from=build /app/dist /usr/share/nginx/html | 38 | WORKDIR /app |
| 39 | COPY --from=build --chown=app:app /app/dist ./dist | ||
| 40 | COPY --from=deps --chown=app:app /app/node_modules ./node_modules | ||
| 41 | USER app | ||
| 42 | ENV HOST=0.0.0.0 PORT=80 | ||
| 31 | EXPOSE 80 | 43 | EXPOSE 80 |
| 32 | CMD ["nginx", "-g", "daemon off;"] | 44 | CMD ["node", "dist/server/entry.mjs"] |