Skip to content

Commit 4511b9a

Browse files
committed
release: build docs as container image
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
1 parent 034b68e commit 4511b9a

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,21 @@ jobs:
155155
if: ${{ env.SEND_SLACK_MSG == 'true' }}
156156
run: |
157157
curl -X POST -H 'Content-type: application/json' --data '{"text":"${{ env.DOCS_SLACK_MSG }}"}' ${{ secrets.SLACK_WEBHOOK }}
158+
image:
159+
runs-on: ubuntu-22.04
160+
if: github.repository_owner == 'docker'
161+
steps:
162+
-
163+
name: Set up Docker Buildx
164+
uses: docker/setup-buildx-action@v3
165+
-
166+
name: Build website
167+
uses: docker/bake-action@v5
168+
with:
169+
files: |
170+
docker-bake.hcl
171+
targets: image
172+
set: |
173+
*.cache-from=type=gha,scope=deploy-${{ env.BRANCH_NAME }}
174+
*.cache-to=type=gha,scope=deploy-${{ env.BRANCH_NAME }},mode=max
175+
push: true

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ARG ALPINE_VERSION=3.20
66
ARG GO_VERSION=1.22
77
# HTML_TEST_VERSION sets the wjdp/htmltest version for HTML testing
88
ARG HTMLTEST_VERSION=0.17.0
9+
ARG NGINX_VERSION=1.27
910

1011
# base is the base stage with build dependencies
1112
FROM golang:${GO_VERSION}-alpine AS base
@@ -41,7 +42,9 @@ FROM build-base AS build
4142
ARG HUGO_ENV
4243
# DOCS_URL sets the base URL for the site
4344
ARG DOCS_URL
44-
RUN hugo --gc --minify -d /out -e $HUGO_ENV -b $DOCS_URL
45+
ENV HUGO_ENVIRONMENT=$HUGO_ENV
46+
ENV HUGO_BASEURL=$DOCS_URL
47+
RUN hugo --gc --minify -d /out
4548

4649
# lint lints markdown files
4750
FROM davidanson/markdownlint-cli2:v0.12.1 AS lint
@@ -129,6 +132,10 @@ set -ex
129132
./scripts/test_go_redirects.sh
130133
EOT
131134

135+
# image creates a Docker image for the documentation site
136+
FROM nginx:${NGINX_VERSION}-alpine AS image
137+
COPY --from=release / /usr/share/nginx/html
138+
132139
# release is an empty scratch image with only compiled assets
133140
FROM scratch AS release
134141
COPY --from=build /out /

docker-bake.hcl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ target "release" {
3232
output = [DOCS_SITE_DIR]
3333
}
3434

35+
target "image" {
36+
args = {
37+
HUGO_ENV = HUGO_ENV
38+
DOCS_URL = ""
39+
}
40+
target = "image"
41+
attest = [
42+
"type=provenance,mode=max",
43+
"type=sbom",
44+
]
45+
tags = ["docs/docker-docs:latest"]
46+
output = ["type=docker"]
47+
}
48+
3549
group "validate" {
3650
targets = ["lint", "test", "unused-media", "test-go-redirects"]
3751
}

0 commit comments

Comments
 (0)