mirror of
https://github.com/hugomods/docker.git
synced 2025-04-27 21:52:17 +03:00
Build more images
This commit is contained in:
parent
7c11404e4e
commit
6fd14e64eb
19 changed files with 202 additions and 56 deletions
136
.github/workflows/docker.yml
vendored
136
.github/workflows/docker.yml
vendored
|
@ -1,46 +1,128 @@
|
||||||
name: Check and Build Latest Image
|
name: check and build latest image
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '*/30 * * * *'
|
- cron: '*/30 * * * *'
|
||||||
issue_comment:
|
issue_comment:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
build-and-push-image:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
version: ['', 'reg-']
|
||||||
|
prefix: ['', 'base-', 'go-', 'node-', 'exts-']
|
||||||
|
include:
|
||||||
|
- version: ''
|
||||||
|
gcc: true
|
||||||
|
extended: true
|
||||||
|
- version: ''
|
||||||
|
prefix: ''
|
||||||
|
dockerfile: docker/default/Dockerfile
|
||||||
|
tags: razonyang/hugo:latest,razonyang/hugo:{0}
|
||||||
|
- version: 'reg-'
|
||||||
|
prefix: ''
|
||||||
|
dockerfile: docker/default/Dockerfile
|
||||||
|
tags: razonyang/hugo:reg,razonyang/hugo:reg-{0}
|
||||||
|
- prefix: base-
|
||||||
|
dockerfile: docker/base/Dockerfile
|
||||||
|
tags: razonyang/hugo:{1}base,razonyang/hugo:{2}base-{0}
|
||||||
|
- prefix: go-
|
||||||
|
dockerfile: docker/go/Dockerfile
|
||||||
|
tags: razonyang/hugo:{1}go,razonyang/hugo:{2}go-{0}
|
||||||
|
- prefix: node-
|
||||||
|
dockerfile: docker/node/Dockerfile
|
||||||
|
tags: razonyang/hugo:{1}node,razonyang/hugo:{2}node-{0}
|
||||||
|
- prefix: exts-
|
||||||
|
dockerfile: docker/exts/Dockerfile
|
||||||
|
tags: razonyang/hugo:{1}exts,razonyang/hugo:{2}exts-{0}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.event_name == 'schedule' || github.event.issue.number == 3 }}
|
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event.issue.number == 3 }}
|
||||||
outputs:
|
|
||||||
version: ${{ steps.hugo.outputs.version }}
|
|
||||||
exists: ${{ steps.check.outputs.exists }}
|
|
||||||
steps:
|
steps:
|
||||||
-
|
- name: Fetch latest Hugo release
|
||||||
id: hugo
|
id: release
|
||||||
name: Fetch latest Hugo release
|
|
||||||
run: curl https://api.github.com/repos/gohugoio/hugo/releases/latest -s | jq .tag_name -r | awk '{print "version="substr($1,2)}' >> $GITHUB_OUTPUT
|
run: curl https://api.github.com/repos/gohugoio/hugo/releases/latest -s | jq .tag_name -r | awk '{print "version="substr($1,2)}' >> $GITHUB_OUTPUT
|
||||||
-
|
|
||||||
|
- name: Check if the base image exists
|
||||||
|
if: steps.release.outputs.version != 'ull'
|
||||||
id: check
|
id: check
|
||||||
run: curl https://hub.docker.com/v2/namespaces/razonyang/repositories/hugo/tags/${{steps.hugo.outputs.version}} -s | jq 'has("name")' | awk '{print "exists="$1}' >> $GITHUB_OUTPUT
|
run: curl https://hub.docker.com/v2/namespaces/razonyang/repositories/hugo/tags/${{ matrix.version }}${{ matrix.prefix }}${{ steps.release.outputs.version }} -s | jq 'has("name")' | awk '{print "exists="$1}' >> $GITHUB_OUTPUT
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
- name: Checkout repository
|
||||||
needs: check
|
if: steps.check.outputs.exists == 'false'
|
||||||
if: ${{ ((needs.check.outputs.version != 'ull') && (needs.check.outputs.exists == 'false')) }}
|
uses: actions/checkout@v3
|
||||||
steps:
|
|
||||||
-
|
- name: Set up QEMU
|
||||||
name: Set up QEMU
|
if: steps.check.outputs.exists == 'false'
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
-
|
with:
|
||||||
name: Login to Docker Hub
|
driver: docker
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: razonyang
|
username: razonyang
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
|
||||||
name: Build and push
|
- name: Build the Alpine image
|
||||||
uses: docker/build-push-action@v3
|
if: steps.check.outputs.exists == 'false'
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: ./docker/alpine
|
||||||
|
file: ./docker/alpine/Dockerfile
|
||||||
|
load: true
|
||||||
|
tags: hugo-alpine:latest
|
||||||
|
build-args: |
|
||||||
|
GCC=${{ matrix.gcc }}
|
||||||
|
|
||||||
|
- name: Build the builder image
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: ./docker/builder
|
||||||
|
file: ./docker/builder/Dockerfile
|
||||||
|
load: true
|
||||||
|
tags: hugo-builder:latest
|
||||||
|
build-args: |
|
||||||
|
HUGO_VERSION=v${{ steps.release.outputs.version }}
|
||||||
|
HUGO_EXTENDED=${{ matrix.extended }}
|
||||||
|
|
||||||
|
- name: Build and export to Docker
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
load: true
|
||||||
|
context: .
|
||||||
|
file: ${{ matrix.dockerfile }}
|
||||||
|
tags: razonyang/hugo:${{ matrix.version }}${{ matrix.prefix }}test
|
||||||
|
build-args: |
|
||||||
|
GCC=${{ matrix.gcc }}
|
||||||
|
build-contexts: |
|
||||||
|
alpine=docker-image://hugo-alpine:latest
|
||||||
|
builder=docker-image://hugo-builder:latest
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
|
run: |
|
||||||
|
docker run --rm -v $PWD/site:/src razonyang/hugo:${{ matrix.version }}${{ matrix.prefix }}test hugo
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: razonyang/hugo:latest,razonyang/hugo:${{ needs.check.outputs.version }}
|
context: .
|
||||||
|
file: ${{ matrix.dockerfile }}
|
||||||
|
tags: ${{ format(matrix.tags, steps.release.outputs.version, matrix.version, matrix.version) }}
|
||||||
build-args: |
|
build-args: |
|
||||||
HUGO_VERSION=v${{ needs.check.outputs.version }}
|
GCC=${{ matrix.gcc }}
|
||||||
|
build-contexts: |
|
||||||
|
alpine=docker-image://hugo-alpine:latest
|
||||||
|
builder=docker-image://hugo-builder:latest
|
||||||
|
|
29
Dockerfile
29
Dockerfile
|
@ -1,29 +0,0 @@
|
||||||
ARG GOPROXY=
|
|
||||||
ARG HUGO_VERSION=latest
|
|
||||||
ARG NODE_VERSION=19
|
|
||||||
|
|
||||||
FROM golang:alpine as golang
|
|
||||||
ARG HUGO_VERSION
|
|
||||||
ARG GOPROXY
|
|
||||||
# Go module proxy
|
|
||||||
ENV GOPROXY=${GOPROXY}
|
|
||||||
|
|
||||||
RUN apk add --no-cache build-base
|
|
||||||
|
|
||||||
# Install Hugo
|
|
||||||
RUN go install -tags extended github.com/gohugoio/hugo@${HUGO_VERSION}
|
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine as node
|
|
||||||
|
|
||||||
# Copy Go and Hugo.
|
|
||||||
COPY --from=golang /usr/local/go /usr/local/go
|
|
||||||
COPY --from=golang /go/bin/hugo /usr/local/bin/hugo
|
|
||||||
RUN ln -s /usr/local/go/bin/go /usr/local/bin/go
|
|
||||||
|
|
||||||
RUN apk add --no-cache git
|
|
||||||
|
|
||||||
# Working directory.
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
# Build the site.
|
|
||||||
CMD hugo --minify --gc --enableGitInfo
|
|
4
docker/alpine/Dockerfile
Normal file
4
docker/alpine/Dockerfile
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
FROM alpine
|
||||||
|
ARG GCC
|
||||||
|
RUN apk add --no-cache ca-certificates
|
||||||
|
RUN if [[ -n "$GCC" ]]; then apk add --no-cache gcc; fi
|
5
docker/base/Dockerfile
Normal file
5
docker/base/Dockerfile
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM alpine
|
||||||
|
COPY --from=builder /go/bin/hugo /usr/bin/hugo
|
||||||
|
WORKDIR /src
|
||||||
|
CMD hugo env
|
5
docker/builder/Dockerfile
Normal file
5
docker/builder/Dockerfile
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
FROM golang:alpine
|
||||||
|
ARG HUGO_VERSION=latest
|
||||||
|
ARG HUGO_EXTENDED=
|
||||||
|
RUN apk add --no-cache gcc g++ musl-dev
|
||||||
|
RUN if [[ -z "$HUGO_EXTENDED" ]]; then go install github.com/gohugoio/hugo@${HUGO_VERSION}; else go install -tags extended github.com/gohugoio/hugo@${HUGO_VERSION}; fi
|
8
docker/default/Dockerfile
Normal file
8
docker/default/Dockerfile
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM node:alpine as node
|
||||||
|
COPY --from=builder /usr/local/go /usr/local/go
|
||||||
|
RUN ln -s /usr/local/go/bin/go /usr/local/bin/go
|
||||||
|
COPY --from=builder /go/bin/hugo /usr/local/bin/hugo
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
WORKDIR /src
|
||||||
|
CMD hugo env
|
9
docker/exts/Dockerfile
Normal file
9
docker/exts/Dockerfile
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM node:alpine as node
|
||||||
|
COPY --from=builder /usr/local/go /usr/local/go
|
||||||
|
RUN ln -s /usr/local/go/bin/go /usr/local/bin/go
|
||||||
|
COPY --from=builder /go/bin/hugo /usr/local/bin/hugo
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
RUN npm i -g postcss-cli autoprefixer @fullhuman/postcss-purgecss rtlcss
|
||||||
|
WORKDIR /src
|
||||||
|
CMD hugo env
|
8
docker/go/Dockerfile
Normal file
8
docker/go/Dockerfile
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM golang:alpine
|
||||||
|
ARG GCC
|
||||||
|
RUN apk add --no-cache ca-certificates
|
||||||
|
RUN if [[ -n "$GCC" ]]; then apk add --no-cache gcc; fi
|
||||||
|
COPY --from=builder /go/bin/hugo /usr/local/bin/hugo
|
||||||
|
WORKDIR /src
|
||||||
|
CMD hugo env
|
8
docker/node/Dockerfile
Normal file
8
docker/node/Dockerfile
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM node:alpine
|
||||||
|
ARG GCC
|
||||||
|
RUN apk add --no-cache ca-certificates
|
||||||
|
RUN if [[ -n "$GCC" ]]; then apk add --no-cache gcc; fi
|
||||||
|
COPY --from=builder /go/bin/hugo /usr/local/bin/hugo
|
||||||
|
WORKDIR /src
|
||||||
|
CMD hugo env
|
0
site/.hugo_build.lock
Normal file
0
site/.hugo_build.lock
Normal file
3
site/config.toml
Normal file
3
site/config.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
baseURL = 'http://example.org/'
|
||||||
|
languageCode = 'en-us'
|
||||||
|
title = 'Hugo Example Site'
|
3
site/content/_index.md
Normal file
3
site/content/_index.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
title: Home
|
||||||
|
---
|
5
site/content/bar/index.md
Normal file
5
site/content/bar/index.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Bar
|
||||||
|
---
|
||||||
|
|
||||||
|
Hi, I am bar.
|
5
site/content/foo/index.md
Normal file
5
site/content/foo/index.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Foo
|
||||||
|
---
|
||||||
|
|
||||||
|
Hi, I am Foo.
|
9
site/layouts/_default/baseof.html
Normal file
9
site/layouts/_default/baseof.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{{ .Page.Title }}</title>
|
||||||
|
{{ partial "get-remote" . }}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{ block "main" . }}{{ end }}
|
||||||
|
</body>
|
||||||
|
</html>
|
3
site/layouts/_default/list.html
Normal file
3
site/layouts/_default/list.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{{ define "main" }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ end }}
|
4
site/layouts/_default/single.html
Normal file
4
site/layouts/_default/single.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{{ define "main" }}
|
||||||
|
<h1>{{ .Title }}</h1>
|
||||||
|
<div>{{ .Content }}</div>
|
||||||
|
{{ end }}
|
9
site/layouts/index.html
Normal file
9
site/layouts/index.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{{ define "main" }}
|
||||||
|
<ul>
|
||||||
|
{{ range .Site.RegularPages }}
|
||||||
|
<li>
|
||||||
|
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
{{ end }}
|
5
site/layouts/partials/get-remote.html
Normal file
5
site/layouts/partials/get-remote.html
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{{ $api := "https://api.github.com" }}
|
||||||
|
{{ $resp := resources.GetRemote $api }}
|
||||||
|
{{ if not $resp }}
|
||||||
|
{{ errorf "failed to get remote: %s" $api }}
|
||||||
|
{{ end }}
|
Loading…
Add table
Add a link
Reference in a new issue