diff --git a/Makefile b/Makefile index f983b548..e51b99a3 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ CORROSION_IMAGE ?= ghcr.io/psviderski/corrosion:latest UCIND_IMAGE ?= ghcr.io/psviderski/ucind:latest +DOCS_IMAGE ?= ghcr.io/psviderski/uncloud-docs:latest update-dev: GOOS=linux GOARCH=amd64 go build -o uncloudd-linux-amd64 ./cmd/uncloudd && \ @@ -68,3 +69,7 @@ test: .PHONY: vet vet: go vet ./... + +.PHONY: docs-image-push +docs-image: + docker buildx build --push --platform linux/amd64,linux/arm64 -t "$(DOCS_IMAGE)" ./docs diff --git a/docs/.dockerignore b/docs/.dockerignore new file mode 100644 index 00000000..bd66041c --- /dev/null +++ b/docs/.dockerignore @@ -0,0 +1,14 @@ +# Ignore everything and use an allowlist of what is allowed to not package any secrets by accident. +* + +# Allow files and directories. +!docs/ +!src/ +!static/ +!pkg/ +!Caddyfile +!*.js +!*.json + +# Ignore unnecessary files inside allowed directories. +**/.DS_Store diff --git a/docs/Caddyfile b/docs/Caddyfile new file mode 100644 index 00000000..bec71d26 --- /dev/null +++ b/docs/Caddyfile @@ -0,0 +1,9 @@ +{ + admin off +} + +:8000 { + root * /usr/share/caddy + file_server + try_files {path} /index.html +} diff --git a/docs/Dockerfile b/docs/Dockerfile new file mode 100644 index 00000000..3bdd5be4 --- /dev/null +++ b/docs/Dockerfile @@ -0,0 +1,27 @@ +# Stage 1: Base image. +## Start with a base image containing NodeJS so we can build Docusaurus. +FROM node:lts-alpine AS base +## Disable colour output from yarn to make logs easier to read. +ENV FORCE_COLOR=0 +## Enable corepack. +RUN corepack enable +## Set the working directory to `/opt/docusaurus`. +WORKDIR /opt/docusaurus + +# Stage 2: Production build. +FROM base AS prod +## Set the working directory to `/opt/docusaurus`. +WORKDIR /opt/docusaurus +## Copy over the source code. +COPY . /opt/docusaurus/ +## Install dependencies with `--immutable` to ensure reproducibility. +RUN npm ci +## Build the static site. +RUN npm run build + +# Stage 3: Serve static site with Caddy. +FROM caddy:2.10.0-alpine AS caddy +## Copy the Caddyfile. +COPY ./Caddyfile /etc/caddy/Caddyfile +## Copy the Docusaurus build output. +COPY --from=prod /opt/docusaurus/build /usr/share/caddy diff --git a/docs/compose.yaml b/docs/compose.yaml new file mode 100644 index 00000000..77d48b08 --- /dev/null +++ b/docs/compose.yaml @@ -0,0 +1,7 @@ +services: + uncloud-docs: + image: ghcr.io/psviderski/uncloud-docs:latest + pull_policy: always + user: nobody + x-ports: + - docs.uncloud.run:8000/https