Skip to content

Commit

Permalink
Merge pull request #430 from Kegbot/docker-cache
Browse files Browse the repository at this point in the history
docker: try alternative cache impl
  • Loading branch information
mik3y authored Jul 23, 2022
2 parents 8bced34 + 08e9edd commit b1e3fb2
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 36 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.git
.git/
.github/
build/
*.egg-info
docs/build/
Expand Down
54 changes: 30 additions & 24 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- master
Expand All @@ -20,11 +22,6 @@ jobs:
name: Checkout
uses: actions/checkout@v2

- uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-${{ hashFiles('Dockerfile') }}

-
name: Prepare
id: prepare
Expand Down Expand Up @@ -52,31 +49,40 @@ jobs:

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host

-
name: Set up docker tag names (local registry)
id: meta_local
uses: docker/metadata-action@v4
with:
images: localhost/${{ env.IMAGE_NAME }}

# Set up the tag(s) we will build/push. The `metadata-action` action has
# a bunch of rules and a little language for specifying this. This should
# be how it's configured:
#
# =================== ============================= =============
# When What Example
# =================== ============================= =============
# All runs <target-branch-name>-dev master-dev
# Merge to master "latest" latest
# Merge tag <tag> v1.2.3b1
# Merge semver tag <semver> 1.2.3
# Merge semver tag <major>.<minor> 1.2
-
name: Set up public docker tag names (public registry)
id: meta_public
name: Set up docker tag names
id: docker_meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{base_ref}}-dev
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build locally
uses: docker/build-push-action@v3
with:
context: .
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
tags: ${{ steps.meta_local.outputs.tags }}
tags: ${{ steps.docker_meta.outputs.tags }}
build-args: |
BUILD_DATE=${{ steps.prepare.outputs.build_date }}
GIT_SHORT_SHA=${GITHUB_SHA::8}
Expand All @@ -86,19 +92,19 @@ jobs:
linux/arm/v7
-
name: Login to DockerHub Registry
name: Login to registry
if: ${{ '${{ secrets.DOCKER_HUB_PASSWORD }}' != '' && '${{ secrets.DOCKER_HUB_USERNAME }}' != '' }}
run: echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin

- name: Build and push to public registry
- name: Build and push to registry
if: ${{ '${{ secrets.DOCKER_HUB_PASSWORD }}' != '' && '${{ secrets.DOCKER_HUB_USERNAME }}' != '' }}
uses: docker/build-push-action@v3
with:
context: .
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta_public.outputs.tags }}
tags: ${{ steps.docker_meta.outputs.tags }}
build-args: |
BUILD_DATE=${{ steps.prepare.outputs.build_date }}
GIT_SHORT_SHA=${GITHUB_SHA::8}
Expand Down
13 changes: 9 additions & 4 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

Expand All @@ -16,4 +17,8 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

livehtml:
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

10 changes: 4 additions & 6 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@
# a list of builtin themes.
#
html_theme = "furo"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
html_theme_options = {
"light_logo": "kegbot-logo-black.png",
"dark_logo": "kegbot-logo-white.png",
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down
58 changes: 57 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ sphinx-issues = "*"
sphinx = "*"
vcrpy = "*"
furo = {git = "https://github.com/Kegbot/furo", rev = "kegbot/kegbot"}
sphinx-autobuild = "^2021.3.14"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down

0 comments on commit b1e3fb2

Please sign in to comment.