Skip to content

Commit 6f9ac1f

Browse files
committed
chore: add Docker image for docs and Uncloud Compose deployment (dogfooding!)
1 parent 6a98acb commit 6f9ac1f

File tree

5 files changed

+62
-0
lines changed

5 files changed

+62
-0
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CORROSION_IMAGE ?= ghcr.io/psviderski/corrosion:latest
22
UCIND_IMAGE ?= ghcr.io/psviderski/ucind:latest
3+
DOCS_IMAGE ?= ghcr.io/psviderski/uncloud-docs:latest
34

45
update-dev:
56
GOOS=linux GOARCH=amd64 go build -o uncloudd-linux-amd64 ./cmd/uncloudd && \
@@ -68,3 +69,7 @@ test:
6869
.PHONY: vet
6970
vet:
7071
go vet ./...
72+
73+
.PHONY: docs-image-push
74+
docs-image:
75+
docker buildx build --push --platform linux/amd64,linux/arm64 -t "$(DOCS_IMAGE)" ./docs

docs/.dockerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Ignore everything and use an allowlist of what is allowed to not package any secrets by accident.
2+
*
3+
4+
# Allow files and directories.
5+
!docs/
6+
!src/
7+
!static/
8+
!pkg/
9+
!Caddyfile
10+
!*.js
11+
!*.json
12+
13+
# Ignore unnecessary files inside allowed directories.
14+
**/.DS_Store

docs/Caddyfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
admin off
3+
}
4+
5+
:8000 {
6+
root * /usr/share/caddy
7+
file_server
8+
try_files {path} /index.html
9+
}

docs/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Stage 1: Base image.
2+
## Start with a base image containing NodeJS so we can build Docusaurus.
3+
FROM node:lts-alpine AS base
4+
## Disable colour output from yarn to make logs easier to read.
5+
ENV FORCE_COLOR=0
6+
## Enable corepack.
7+
RUN corepack enable
8+
## Set the working directory to `/opt/docusaurus`.
9+
WORKDIR /opt/docusaurus
10+
11+
# Stage 2: Production build.
12+
FROM base AS prod
13+
## Set the working directory to `/opt/docusaurus`.
14+
WORKDIR /opt/docusaurus
15+
## Copy over the source code.
16+
COPY . /opt/docusaurus/
17+
## Install dependencies with `--immutable` to ensure reproducibility.
18+
RUN npm ci
19+
## Build the static site.
20+
RUN npm run build
21+
22+
# Stage 3: Serve static site with Caddy.
23+
FROM caddy:2.10.0-alpine AS caddy
24+
## Copy the Caddyfile.
25+
COPY ./Caddyfile /etc/caddy/Caddyfile
26+
## Copy the Docusaurus build output.
27+
COPY --from=prod /opt/docusaurus/build /usr/share/caddy

docs/compose.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
uncloud-docs:
3+
image: ghcr.io/psviderski/uncloud-docs:latest
4+
pull_policy: always
5+
user: nobody
6+
x-ports:
7+
- docs.uncloud.run:8000/https

0 commit comments

Comments
 (0)