1
1
# syntax=docker/dockerfile:1
2
2
3
- ## Modified version of https://docusaurus.community/knowledge/deployment/docker/
4
-
5
3
# Stage 1: Base image.
6
4
## Start with a base image containing NodeJS so we can build Docusaurus.
7
5
FROM node:23.3.0-slim AS base
8
6
## Disable colour output from yarn to make logs easier to read.
9
-
10
- ## https://pnpm.io/docker
11
- ENV PNPM_HOME="/pnpm"
12
- ENV PATH="$PNPM_HOME:$PATH"
13
-
14
7
ENV FORCE_COLOR=0
15
8
## Enable corepack.
16
9
RUN corepack enable
17
10
## Set the working directory to `/opt/docusaurus`.
18
11
WORKDIR /opt/docusaurus
19
12
20
- ## Required by docusaurus: [ERROR] Loading of version failed for version current
21
- RUN apt-get update && apt-get install -y git
22
-
13
+ # Stage 2a: Development mode.
23
14
FROM base AS dev
24
15
## Set the working directory to `/opt/docusaurus`.
25
16
WORKDIR /opt/docusaurus
26
17
## Expose the port that Docusaurus will run on.
27
18
EXPOSE 3000
28
19
## Run the development server.
29
- CMD [ -d "node_modules" ] && npm run start -- --host 0.0.0.0 --poll 1000 || pnpm install && pnpm run start -- --host 0.0.0.0 --poll 1000
20
+ CMD [ -d "node_modules" ] && pnpm start -- --host 0.0.0.0 --poll 1000 || pnpm install && pnpm start -- --host 0.0.0.0 --poll 1000
30
21
31
22
# Stage 2b: Production build mode.
32
- FROM base AS preprod
23
+ FROM base AS prod
33
24
## Set the working directory to `/opt/docusaurus`.
34
25
WORKDIR /opt/docusaurus
35
26
36
- ## This is in case someone needs to build the lock file
37
- #RUN apt install python-is-python3 g++ make -y
38
-
39
- COPY docs/package.json /opt/docusaurus/package.json
40
- COPY docs/package-lock.json /opt/docusaurus/package-lock.json
41
-
42
- FROM preprod AS prod
43
-
44
- ## Install dependencies with `--immutable` to ensure reproducibility.
45
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install
46
-
47
- ## Copy over the source code.
48
27
COPY docs/ /opt/docusaurus/
49
28
COPY packages/ /opt/packages/
50
29
51
30
## Required buy docusaurus [ERROR] Loading of version failed for version current
52
31
COPY .git/ /opt/.git/
53
32
54
- # Build from sources
55
- RUN pnpm run build
33
+ ## Install dependencies with `--frozen-lockfile` to ensure reproducibility.
34
+ RUN pnpm install --no-frozen-lockfile
35
+ ## Build the static site.
36
+ RUN pnpm build
56
37
57
38
# Stage 3a: Serve with `docusaurus serve`.
58
39
FROM prod AS serve
59
40
## Expose the port that Docusaurus will run on.
60
41
EXPOSE 3000
61
42
## Run the production server.
62
- CMD ["npm", "run", "serve", "--", "--host", "0.0.0.0", "--no-open"]
63
-
43
+ CMD ["pnpm", "run", "serve", "--host", "0.0.0.0", "--no-open"]
0 commit comments