• This repository has been archived on 23/Jan/2021
  • Stars
    star
    233
  • Rank 166,650 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

:octocat: GitHub Action to set up Docker Buildx

GitHub release GitHub marketplace Test workflow Codecov Become a sponsor Paypal Donate

Moved to Docker organization

This action is ARCHIVED and will not receive any updates, update your workflows to use the official Docker actions.

Replace

      - name: Set up Docker Buildx
        uses: crazy-max/ghaction-docker-buildx@v3

With

      # https://github.com/docker/setup-qemu-action
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      # https://github.com/docker/setup-buildx-action
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

About

GitHub Action to set up Docker Buildx.

If you are interested, check out my other :octocat: GitHub Actions!

GitHub Action to set up Docker Buildx


Usage

Quick start

Here is a simple example to build a Docker image with buildx (BuildKit)

name: buildx

on:
  pull_request:
    branches: master
  push:
    branches: master
    tags:

jobs:
  buildx:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v2
      -
        name: Set up Docker Buildx
        id: buildx
        uses: crazy-max/ghaction-docker-buildx@v3
        with:
          buildx-version: latest
          qemu-version: latest
      -
        name: Available platforms
        run: echo ${{ steps.buildx.outputs.platforms }}
      -
        name: Run Buildx
        run: |
          docker buildx build \
            --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x \
            --output "type=image,push=false" \
            --file ./test/Dockerfile ./test

Build and push to DockerHub

Another example to build and push Diun Docker image on DockerHub.

  • On push event, Docker image crazymax/diun:edge is built and pushed on DockerHub.
  • On pull_request event, Docker image crazymax/diun:edge is built.
  • On schedule event, Docker image crazymax/diun:nightly is built and pushed on DockerHub.
  • On push tags event, Docker image crazymax/diun:<version> and crazymax/diun:latest is built and pushed on DockerHub.
name: buildx

on:
  schedule:
    - cron: '0 10 * * *' # everyday at 10am
  pull_request:
    branches: master
  push:
    branches: master
    tags:
      - v*

jobs:
  buildx:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v2
      -
        name: Prepare
        id: prepare
        run: |
          DOCKER_IMAGE=crazymax/diun
          DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x
          VERSION=edge

          if [[ $GITHUB_REF == refs/tags/* ]]; then
            VERSION=${GITHUB_REF#refs/tags/v}
          fi
          if [ "${{ github.event_name }}" = "schedule" ]; then
            VERSION=nightly
          fi

          TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
          if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
            TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
          fi

          echo ::set-output name=docker_image::${DOCKER_IMAGE}
          echo ::set-output name=version::${VERSION}
          echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
            --build-arg VERSION=${VERSION} \
            --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
            --build-arg VCS_REF=${GITHUB_SHA::8} \
            ${TAGS} --file ./test/Dockerfile ./test
      -
        name: Set up Docker Buildx
        uses: crazy-max/ghaction-docker-buildx@v3
      -
        name: Docker Buildx (build)
        run: |
          docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
      -
        name: Login to DockerHub
        if: success() && github.event_name != 'pull_request'
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      -
        name: Docker Buildx (push)
        if: success() && github.event_name != 'pull_request'
        run: |
          docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
      -
        name: Inspect image
        if: always() && github.event_name != 'pull_request'
        run: |
          docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}

Leverage buildx cache

You can leverage cache using @actions/cache with this action.

name: buildx

on:
  pull_request:
    branches: master
  push:
    branches: master

jobs:
  buildx:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v2
      -
        name: Set up Docker Buildx
        uses: crazy-max/ghaction-docker-buildx@v3
      -
        name: Cache Docker layers
        uses: actions/cache@v2
        id: cache
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-
      -
        name: Docker Buildx (build)
        run: |
          docker buildx build \
            --cache-from "type=local,src=/tmp/.buildx-cache" \
            --cache-to "type=local,dest=/tmp/.buildx-cache" \
            --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x \
            --output "type=image,push=false" \
            --tag crazymax/diun:latest \
            --file ./Dockerfile-diun ./
      -
        name: Login to DockerHub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      -
        name: Docker Buildx (push)
        run: |
          docker buildx build \
            --cache-from "type=local,src=/tmp/.buildx-cache" \
            --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x \
            --output "type=image,push=true" \
            --tag crazymax/diun:latest \
            --file ./Dockerfile-diun ./
      -
        name: Inspect image
        run: |
          docker buildx imagetools inspect crazymax/diun:latest

Projects using this action

Customizing

inputs

Following inputs can be used as step.with keys

Name Type Default Description
buildx-version String latest Buildx version. Example: v0.3.0
qemu-version String latest qemu-user-static version (Docker tag). Example: 4.2.0-7

outputs

Following outputs are available

Name Type Description
platforms String Available platforms (comma separated)

environment variables

The following official docker environment variables are supported:

Name Type Default Description
DOCKER_CONFIG String ~/.docker The location of your client configuration files

Keep up-to-date with GitHub Dependabot

Since Dependabot has native GitHub Actions support, to enable it on your GitHub repo all you need to do is add the .github/dependabot.yml file:

version: 2
updates:
  # Maintain dependencies for GitHub Actions
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "daily"

Limitation

This action is only available for Linux virtual environments.

How can I help?

All kinds of contributions are welcome ๐Ÿ™Œ! The most basic way to show your support is to star ๐ŸŒŸ the project, or to raise issues ๐Ÿ’ฌ You can also support this project by becoming a sponsor on GitHub ๐Ÿ‘ or by making a Paypal donation to ensure this journey continues indefinitely! ๐Ÿš€

Thanks again for your support, it is much appreciated! ๐Ÿ™

License

MIT. See LICENSE for more details.

More Repositories

1

WindowsSpyBlocker

Block spying and tracking on Windows
Go
4,186
star
2

diun

Receive notifications when an image is updated on a Docker registry
Go
2,073
star
3

docker-jetbrains-license-server

JetBrains License Server Docker image
Dockerfile
1,241
star
4

swarm-cronjob

Create jobs on a time-based schedule on Docker Swarm
Go
641
star
5

csgo-server-launcher

Counter-Strike Global Offensive Dedicated Server Launcher
Shell
580
star
6

docker-fail2ban

Fail2ban Docker image
Dockerfile
542
star
7

ftpgrab

Grab your files periodically from a remote FTP or SFTP server easily
Go
438
star
8

ghaction-github-pages

:octocat: GitHub Action to deploy to GitHub Pages
TypeScript
408
star
9

nodejs-portable

Node.js portable on Windows
Go
385
star
10

docker-rtorrent-rutorrent

rTorrent and ruTorrent Docker image
Dockerfile
356
star
11

docker-samba

Samba Docker image
Dockerfile
351
star
12

ghaction-import-gpg

GitHub Action to import a GPG key
TypeScript
283
star
13

docker-cloudflared

Cloudflared proxy-dns Docker image
Dockerfile
266
star
14

docker-nextcloud

Nextcloud Docker image
Dockerfile
213
star
15

ddns-route53

Dynamic DNS for Amazon Route 53 on a time-based schedule
Go
203
star
16

docker-firefox-syncserver

Firefox Sync Server Docker image
Dockerfile
188
star
17

docker-matomo

Matomo (formerly Piwik) Docker image
Dockerfile
161
star
18

docker-flarum

Flarum Docker image
Dockerfile
157
star
19

undock

Extract contents of a container image in a local folder
Go
156
star
20

xgo

Go CGO cross compiler
Shell
145
star
21

ghaction-virustotal

GitHub Action to upload and scan files with VirusTotal
TypeScript
139
star
22

ghaction-github-labeler

:octocat: GitHub Action to manage labels on GitHub
TypeScript
123
star
23

firefox-history-merger

Merge Firefox history and repair missing favicons with ease
Go
87
star
24

ghaction-chocolatey

:octocat: GitHub Action for Chocolatey, the package manager for Windows
Dockerfile
67
star
25

docker-qbittorrent

qBittorrent Docker image
Dockerfile
65
star
26

docker-msmtpd

Lightweight SMTP relay Docker image using msmtpd
Dockerfile
64
star
27

docker-osxcross

MacOSX cross toolchain as Docker image
Dockerfile
60
star
28

geoip-updater

Download and update MaxMind's GeoIP2 databases on a time-based schedule
Go
55
star
29

ghaction-container-scan

GitHub Action to check for vulnerabilities in your container image
TypeScript
55
star
30

dokuwiki-plugin-syntaxhighlighter4

SyntaxHighlighter4 plugin for DokuWiki
PHP
53
star
31

ghaction-xgo

:octocat: GitHub Action for xgo, a Golang CGO cross compiler
TypeScript
52
star
32

git-rewrite-author

Rewrite authors / commiters history of a git repository with ease
Go
48
star
33

ghaction-upx

GitHub Action for UPX, the Ultimate Packer for eXecutables
TypeScript
48
star
34

docker-docker

Docker in Docker (DinD) image
Dockerfile
47
star
35

docker-pure-ftpd

Pure-FTPd Docker image based on Alpine Linux with MySQL, PostgreSQL and LDAP support
Dockerfile
47
star
36

ghaction-github-runtime

GitHub Action to expose GitHub runtime to the workflow
Dockerfile
46
star
37

CwsMailBounceHandler

๐Ÿ“ฌ PHP class to help webmasters handle bounce-back, feedback loop and ARF mails in standard DSN
PHP
41
star
38

docker-unbound

Unbound Docker image
Dockerfile
41
star
39

goxx

Go CGO cross-compiler Docker image
Shell
40
star
40

docker-dokuwiki

DokuWiki Docker image
Dockerfile
38
star
41

ghaction-dump-context

GitHub Action composite to dump context
37
star
42

docker-healthchecks

Healthchecks Docker image
Dockerfile
36
star
43

rocketchat-uptimerobot

Uptime Robot integration for Rocket.Chat
JavaScript
34
star
44

goreleaser-xx

Cross compilation helper for GoReleaser
Go
33
star
45

aetraymenu

Aestan Tray Menu
Pascal
33
star
46

ghaction-github-status

GitHub Action to check GitHub Status in your workflow
TypeScript
32
star
47

docker-alpine-s6

Alpine Linux with s6 overlay
Dockerfile
29
star
48

ghaction-dockerhub-mirror

GitHub Action to mirror a DockerHub repo to another registry
29
star
49

docker-linguist

GitHub Linguist Docker image
HCL
27
star
50

artifactory-cleanup

Cleanup artifacts on Jfrog Artifactory with advanced settings
Go
27
star
51

docker-7zip

7-Zip Docker image
Dockerfile
26
star
52

IconsRefresh

Refresh icons on Desktop, Start Menu and Taskbar
Go
26
star
53

docker-ejtserver

EJT License Server Docker image
Dockerfile
19
star
54

yasu

Yet Another Switch User
Dockerfile
17
star
55

docker-rrdcached

RRDcached Docker image
Dockerfile
17
star
56

travis-wait-enhanced

Prevent Travis CI from thinking a long-running process has stalled
Go
17
star
57

ghaction-setup-docker

GitHub Action to set up (download and install) Docker CE
TypeScript
16
star
58

ghaction-setup-containerd

GitHub Action to set up containerd
TypeScript
16
star
59

login-servers-enhanced

Fork of the official login-servers Adminer plugin with enhancements
PHP
16
star
60

docker-n8n

n8n Docker image
Dockerfile
15
star
61

ghaction-hugo

:octocat: GitHub Action for Hugo, the world's fastest framework for building websites
TypeScript
13
star
62

docker-svn2git-mirror

๐Ÿณ Docker image to mirror SVN repositories to Git periodically
Dockerfile
13
star
63

CwsShareCount

PHP class to get social share count for Delicious, Facebook, Google+, Linkedin, Pinterest, Reddit, StumbleUpon and Twitter.
PHP
13
star
64

docker-allhands2-buildx-bake

buildx bake demo @ Docker Community All-Hands #2
HCL
13
star
65

gonfig

Lightweight config handling for Go
Go
11
star
66

crazy-max

10
star
67

docker-artifactory

JFrog Artifactory Docker images
10
star
68

echo-ipfilter

Middleware that provides ipfilter support for echo framework
Go
10
star
69

ghaction-docker-status

GitHub Action to check Docker system status in your workflow
TypeScript
9
star
70

docker-shodan

Shodan Docker image
HCL
9
star
71

expect-nt

Fork of Expect for Windows NT by Gordon Chaffee
C
8
star
72

gotestlist

List tests in the given Go packages
Go
8
star
73

dockerfile

Official Dockerfile frontend that enables building Dockerfiles with BuildKit
Go
8
star
74

ghaction-github-release

GitHub Action for creating GitHub Releases
TypeScript
6
star
75

CwsCaptcha

PHP class to generate a captcha to avoid spam.
PHP
6
star
76

crazy-max.github.io

Homepage
HTML
6
star
77

CwsDump

PHP class to replace var_dump(), print_r() based on the Xdebug style.
PHP
6
star
78

CwsCrypto

PHP class for password hashing with multi encryption methods
PHP
6
star
79

CwsSession

PHP class to manipulate sessions. Data are securely encrypted and sessions are stored in database.
PHP
5
star
80

buildkit-nofrontend

Go
5
star
81

Killer

Kill a program by process name and clean-up notify and tray icons
C#
5
star
82

rtorrent-launcher

๐Ÿš€ A simple bash script to launch rtorrent as a daemon
Shell
4
star
83

docker-snmpd

๐Ÿณ SNMP daemon Docker image based on Alpine Linux
Dockerfile
4
star
84

docker-loop

Simple loop for dummy services
Dockerfile
4
star
85

dokuwiki-plugin-syntaxhighlighter3

๐Ÿ“ Fork of SyntaxHighlighter3 plugin for DokuWiki
CSS
4
star
86

docker-syntaxhighlighter

๐Ÿณ Docker image to build SyntaxHighlighter javascript plugin
Dockerfile
4
star
87

rocketchat-xray

JFrog Xray integration for Rocket.Chat
JavaScript
4
star
88

rocketchat-appveyor

AppVeyor integration for Rocket.Chat
JavaScript
4
star
89

CwsDebug

PHP class to output additional messages for debug
PHP
4
star
90

docker-syspass

๐Ÿณ sysPass Docker image based on Alpine Linux
Dockerfile
4
star
91

shares-erasor

A DOS Batch script to remove all shares and disable auto shares on Windows systems.
Shell
4
star
92

IOPriority

Fork of IO Priority
C#
3
star
93

docker-inboxen

๐Ÿณ Inboxen Docker image based on Alpine Linux
Dockerfile
3
star
94

rocketchat-microbadger

MicroBadger integration for Rocket.Chat
JavaScript
3
star
95

CwsCurl

A flexible wrapper PHP class for the cURL extension.
PHP
3
star
96

geass

A multi-user front-end client for rTorrent with many features
3
star
97

CwsOvhLogsDownloader

PHP class to download the Apache access and error, FTP, CGI, Out and SSH logs available on http://logs.ovh.net from a shared hosting.
PHP
3
star
98

gohealthchecks

Go client library for accessing the Healthchecks API
Go
2
star
99

ama

Ask me Anything!
2
star
100

crossfit-reader

๐Ÿ’ณ Card reader application for ACR122U device affiliate to the Crossfit Nancy booking application
Java
2
star