https://github.com/serversideup/github-action-docker-build
Build and publish docker images automatically with GitHub Actions ⚡️
https://github.com/serversideup/github-action-docker-build
ci cicd docker docker-build docker-builds docker-buildx docker-buildx-qemu github-actions
Last synced: 6 months ago
JSON representation
Build and publish docker images automatically with GitHub Actions ⚡️
- Host: GitHub
- URL: https://github.com/serversideup/github-action-docker-build
- Owner: serversideup
- License: gpl-3.0
- Created: 2022-10-25T17:18:25.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-03T19:12:48.000Z (over 2 years ago)
- Last Synced: 2025-07-17T00:10:57.509Z (12 months ago)
- Topics: ci, cicd, docker, docker-build, docker-builds, docker-buildx, docker-buildx-qemu, github-actions
- Homepage:
- Size: 152 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
Hi! We're [Dan](https://twitter.com/danpastori) and [Jay](https://twitter.com/jaydrogers). We're a two person team with a passion for open source products. We created [Server Side Up](https://serversideup.net) to help share what we learn.
### Find us at:
* 📖 [Blog](https://serversideup.net) - get the latest guides and free courses on all things web/mobile development.
* 🙋 [Community](https://community.serversideup.net) - get friendly help from our community members.
* 🤵♂️ [Get Professional Help](https://serversideup.net/get-help) - get guaranteed responses within next business day.
* 💻 [GitHub](https://github.com/serversideup) - check out our other open source projects
* 📫 [Newsletter](https://serversideup.net/subscribe) - skip the algorithms and get quality content right to your inbox
* 🐥 [Twitter](https://twitter.com/serversideup) - you can also follow [Dan](https://twitter.com/danpastori) and [Jay](https://twitter.com/jaydrogers)
* ❤️ [Sponsor Us](https://github.com/sponsors/serversideup) - please consider sponsoring us so we can create more helpful resources
### Our Sponsors
All of our software is free an open to the world. None of this can be brought to you without the financial backing of our sponsors.
# About this project
This is a GitHub Action intended to simplify the process for building automated Docker images with GitHub Actions.
### Features:
- ✅ **Stupid simple to use** - just pass in the tags, registry, and credentials and you're good to go
- 🚀 **Customize your docker image names/tags** - easily pass in what you want it to be
- 🤓 **Multi-arch support** - build for multiple architectures
- 📦 **Multi-registry support** - build and push to up to 3 registries simultaneously (Docker Hub, GitHub Container Registry, and private registries)
- 🔀 **Context aware** - great if you have a Dockerfile in a different part of your repo
# Usage
## Single Registry Example
Here is a basic example workflow for publishing to a single registry:
```yml
name: Docker Publish (Production Images)
on:
push:
jobs:
docker-publish:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build and push Docker image
uses: serversideup/github-action-docker-build@v6
with:
tags: serversideup/financial-freedom:latest
registry-username: ${{ secrets.DOCKER_HUB_USERNAME }}
registry-password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
platforms: "linux/amd64,linux/arm/v7,linux/arm64/v8"
```
## Multiple Registry Example
You can now push to up to **3 different registries** in a single build! Perfect for publishing to Docker Hub, GitHub Container Registry, and your own private registry simultaneously:
```yml
name: Docker Publish (Multiple Registries)
on:
push:
branches:
- main
jobs:
docker-publish:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build and push to multiple registries
uses: serversideup/github-action-docker-build@v6
with:
# Tag with multiple registry prefixes
tags: |
docker.io/myorg/myapp:latest
ghcr.io/myorg/myapp:latest
registry.example.com/myapp:latest
# Registry 1: Docker Hub
registry: "docker.io"
registry-username: ${{ secrets.DOCKER_HUB_USERNAME }}
registry-password: ${{ secrets.DOCKER_HUB_TOKEN }}
# Registry 2: GitHub Container Registry
registry-2: "ghcr.io"
registry-2-username: ${{ github.actor }}
registry-2-password: ${{ secrets.GITHUB_TOKEN }}
# Registry 3: Custom Private Registry
registry-3: "registry.example.com"
registry-3-username: ${{ secrets.CUSTOM_REGISTRY_USER }}
registry-3-password: ${{ secrets.CUSTOM_REGISTRY_TOKEN }}
platforms: "linux/amd64,linux/arm64"
```
**💡 Pro tip:** You only need to specify the registries you want to use. Registry 2 and 3 are optional and will be skipped if credentials aren't provided.
### Configuration options
**🔀 Input Name**|**📚 Description**|**🛑 Required**|**👉 Default**
:-----:|:-----:|:-----:|:-----:
tags|Enter the tag(s) you would like to name your image with. (example: `myorg/myapp:production`) Use multi-line format for multiple tags.|⚠️ Yes|
registry|Choose which container image repository to upload to. See all options.| |`docker.io`
registry-username|Enter the username to authenticate with your first registry.|⚠️ Yes|
registry-password|Enter the password or token to authenticate with your registry. (an access token is highly recommended)|⚠️ Yes|
registry-token (deprecated)| Use `registry-password` instead||
context|The build context directory (the directory containing your Dockerfile and build files).| |`.`
dockerfile|Filename of the Dockerfile within the context that you set.| |`./Dockerfile`
platforms|Comma separated list of platforms.| |`linux/amd64`
target|The target build stage to build.| |
#### If you have more than one registry
**🔀 Input Name**|**📚 Description**|**🛑 Required**|**👉 Default**
:-----:|:-----:|:-----:|:-----:
registry-2|Choose which container image repository to upload to. See all options.| |
registry-2-username|Enter the username to authenticate with your second registry.|⚠️ Yes (if you use the 2nd registry)|
registry-2-password|Enter the token or password to authenticate with your second registry. (an access token is highly recommended)|⚠️ Yes (if you use the 2nd registry)|
registry-3|Choose which container image repository to upload to. See all options.| |
registry-3-username|Enter the username to authenticate with your third registry.|⚠️ Yes (if you use the 3rd registry)|
registry-3-password|Enter the token or password to authenticate with your third registry. (an access token is highly recommended)|⚠️ Yes (if you use the 3rd registry)|
> [!NOTE]
> At least one registry's credentials must be provided (either registry 1, 2, or 3).
### Important security notice
Always use encrypted secrets when passing sensitive information. [Learn more here →](https://docs.github.com/en/actions/security-guides/encrypted-secrets)
### Security Disclosures
If you find a security vulnerability, please let us know as soon as possible.
[View Our Responsible Disclosure Policy →](https://www.notion.so/Responsible-Disclosure-Policy-421a6a3be1714d388ebbadba7eebbdc8)

