ATAC icon indicating copy to clipboard operation
ATAC copied to clipboard

feat: continuous deployment for docker image

Open alan910127 opened this issue 1 year ago • 0 comments

Closes #96

Usage

The workflow is currently configured to be build-only mode. To enable pushing the image to Docker Hub, you'll need to:

  1. Set the DOCKERHUB_USERNAME and DOCKERHUB_TOKEN variables in the repository secrets.
  2. Set the PUSH_IMAGE variable to true (or remove it entirely) in .github/workflows/build-docker.yml.

Once configured, the workflow will automatically push the image to Docker Hub when:

  1. The main branch is updated, or
  2. A release is published.

Changes

  • Added a Dockerfile that builds the app using cargo-chef to optimize Docker build caching. On a clean build (e.g., the first time this workflow runs or when dependencies are updated), it takes around 15-20 minutes to complete. If dependencies are cached, the build time reduces to ~5 minutes.
  • Integrated cargo-zigbuild to build a multi-platform image supporting both linux/amd64 and linux/arm64. It should be straightforward to add other targets to the build process.

Limitations

  • The final build command cargo zigbuild --release ... seems to execute every time, and I'm not sure why this happens.
  • The cargo-chef Docker image currently supports only linux/amd64 and linux/arm64. To support other platforms, the Dockerfile needs to be adjusted, by using a different base image and adding cargo install cargo-chef.

Let me know if the docker usage should be included in README, I'll try to add it! :smiley:

alan910127 avatar Aug 18 '24 20:08 alan910127