Skip to content

Commit d65f7f0

Browse files
🐳 🆕 add Dockerfile.docs and update docker-compose
Since the docs dependend on the files from packages, we have to include the Dockerfile.docs in the root directory because of the build context. Adding a new docker-compose-docs.yaml to always build the docs from the file directly. Just adding a new service for the docs: $ docker compose up --build [+] Building 55.5s (20/20) FINISHED docker:desktop-linux => [docs internal] load build definition from Dockerfile.docs 0.0s => => transferring dockerfile: 1.88kB 0.0s => [docs] resolve image config for docker.io/docker/dockerfile:1 1.7s => CACHED [docs] docker-image://docker.io/docker/dockerfile:1@sha256:93bfd3b68c109427185cd78b4779fc82b484b0b7618e36d0f104d4d801e66d25 0.0s => [docs internal] load build definition from Dockerfile.docs 0.0s => [docs internal] load metadata for docker.io/library/node:23.3.0-slim 1.3s => [docs internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [docs base 1/4] FROM docker.io/library/node:23.3.0-slim@sha256:8b30809f66a6ea8896b9a5d004b4fe2cc0e8061d981d3784fb0e80a19b86ab9d 0.0s => [docs internal] load build context 0.1s => => transferring context: 409.46kB 0.1s => CACHED [docs base 2/4] RUN corepack enable 0.0s => CACHED [docs base 3/4] WORKDIR /opt/docusaurus 0.0s => CACHED [docs base 4/4] RUN apt-get update && apt-get install -y git 0.0s => CACHED [docs prod 1/8] WORKDIR /opt/docusaurus 0.0s => CACHED [docs prod 2/8] COPY docs/package.json /opt/docusaurus/package.json 0.0s => CACHED [docs prod 3/8] COPY docs/package-lock.json /opt/docusaurus/package-lock.json 0.0s => CACHED [docs prod 4/8] RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install 0.0s => CACHED [docs prod 5/8] COPY docs/ /opt/docusaurus/ 0.0s => CACHED [docs prod 6/8] COPY packages/ /opt/packages/ 0.0s => [docs prod 7/8] COPY .git/ /opt/.git/ 0.1s => [docs prod 8/8] RUN pnpm run build 51.4s => [docs] exporting to image 0.8s => => exporting layers 0.8s => => writing image sha256:0a580f2889191121880df85b8951563386f838f7e5f8723dec750ce292334498 0.0s => => naming to docker.io/library/eliza-docs 0.0s [+] Running 1/0 ✔ Container eliza-docs-1 Recreated 0.0s Attaching to docs-1 docs-1 | (node:1) ExperimentalWarning: CommonJS module /usr/local/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /usr/local/lib/node_modules/npm/node_modules/supports-color/index.js using require(). docs-1 | Support for loading ES Module in require() is an experimental feature and might change at any time docs-1 | (Use `node --trace-warnings ...` to show where the warning was created) docs-1 | docs-1 | > eliza-docs@0.1.7-alpha.2 serve docs-1 | > docusaurus serve --host 0.0.0.0 --no-open docs-1 | docs-1 | [SUCCESS] Serving "build" directory at: http://0.0.0.0:3000/eliza/
1 parent 6f77bf0 commit d65f7f0

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

Dockerfile.docs

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# syntax=docker/dockerfile:1
2+
3+
## Modified version of https://docusaurus.community/knowledge/deployment/docker/
4+
5+
# Stage 1: Base image.
6+
## Start with a base image containing NodeJS so we can build Docusaurus.
7+
FROM node:23.3.0-slim AS base
8+
## 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+
ENV FORCE_COLOR=0
15+
## Enable corepack.
16+
RUN corepack enable
17+
## Set the working directory to `/opt/docusaurus`.
18+
WORKDIR /opt/docusaurus
19+
20+
## Required by docusaurus: [ERROR] Loading of version failed for version current
21+
RUN apt-get update && apt-get install -y git
22+
23+
FROM base AS dev
24+
## Set the working directory to `/opt/docusaurus`.
25+
WORKDIR /opt/docusaurus
26+
## Expose the port that Docusaurus will run on.
27+
EXPOSE 3000
28+
## 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
30+
31+
# Stage 2b: Production build mode.
32+
FROM base AS prod
33+
## Set the working directory to `/opt/docusaurus`.
34+
WORKDIR /opt/docusaurus
35+
36+
COPY docs/package.json /opt/docusaurus/package.json
37+
COPY docs/package-lock.json /opt/docusaurus/package-lock.json
38+
39+
## Install dependencies with `--immutable` to ensure reproducibility.
40+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install
41+
42+
## Copy over the source code.
43+
COPY docs/ /opt/docusaurus/
44+
COPY packages/ /opt/packages/
45+
46+
## Required buy docusaurus [ERROR] Loading of version failed for version current
47+
COPY .git/ /opt/.git/
48+
49+
# Build from sources
50+
RUN pnpm run build
51+
52+
# Stage 3a: Serve with `docusaurus serve`.
53+
FROM prod AS serve
54+
## Expose the port that Docusaurus will run on.
55+
EXPOSE 3000
56+
## Run the production server.
57+
CMD ["npm", "run", "serve", "--", "--host", "0.0.0.0", "--no-open"]
58+

docker-compose-docs.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
docs:
3+
build:
4+
dockerfile: Dockerfile.docs
5+
context: .
6+
target: serve
7+
ports:
8+
- 3000:3000
9+

0 commit comments

Comments
 (0)