GithubHelp home page GithubHelp logo

victorlin / github-actions-docker-build Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 10 KB

Automatically build a Docker image on GitHub Actions, hosted on GitHub Container Registry

Dockerfile 6.45% Shell 93.55%

github-actions-docker-build's Introduction

github-actions-docker-build

Automatically build a Docker image on GitHub Actions, hosted on GitHub Container Registry

1. Setup

Fork this repository, or add all its contents into an existing repository. You will need a GitHub account to continue.

2. Customize the image

The Dockerfile defines the Docker image. Refer to Docker Docs for examples on how to make changes to this file.

Once the Dockerfile has been updated on GitHub, it will automatically trigger a build of the image on GitHub Container Registry as an image tagged with the repository's name and owner.

Note

The first push in a repository may fail due to lack of GitHub permissions on a package that hasn't been created yet. Subsequent pushes should succeed.

3. Customize the automatic build

Trigger

The automatic build is defined in docker.yml, a GitHub Actions workflow. By default, it is set to run:

  1. on pushes to the main branch that change certain files
  2. on manual invocation from the workflow webpage (repository > Actions > docker)

You can tweak this to use other workflow triggers.

Platform

By default, the build is done only for the native platform of the GitHub runner, linux/amd64. If you want to build for other platforms, you can pass --platform to ./build --platform or more directly by modifying the docker buildx build command within that script. If doing this, you may need to enable emulation by uncommenting the line for docker/setup-qemu-action@v3 in docker.yml.

Note that building for non-native platforms introduces complications and can slow the build process. See the Docker's official guide for more information: Building multi-platform images

Common issues

Error when pulling/running: docker: no matching manifest …

This happens when the image was built for a platform that differs from the machine you are running Docker on. For example, this would happen if the image is built for linux/amd64 and you are using a Mac running on Apple silicon (M1/M2/etc.). Some ways to address this:

  1. Build the image for your machine's platform using emulation (instructions). Typically this means a slower and more error-prone build process but faster run times.
  2. Pull the image with the image's intended platform explicitly (e.g. docker pull --platform=linux/amd64) and run using emulation. Typically this means a faster build process but slower run times.
  3. Build the image locally. Typically this is the fastest combination of build and run times, but the build process can be error-prone and it isn't automated via GitHub Actions.

docker pull permission denied

If you repository is public, log out and try again.

docker logout ghcr.io

If your repository is private, log in, follow prompts, and try again.

docker login ghcr.io

References

Based on work in https://github.com/nextstrain/docker-base.

github-actions-docker-build's People

Contributors

victorlin avatar

Watchers

 avatar

github-actions-docker-build's Issues

Build for native use on Apple silicon

By default, the build is done only for the GitHub runner ubuntu-latest's platform linux/amd64. It can be built for arm64 using --platform linux/arm64 however that uses emulation and can be extremely slow depending on the build steps.

Consider using the macos-14 runner which runs on Apple silicon. This would provide a native build and allow native use on other Apple silicon devices.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.