Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add support for multi platform image builds in docker #897

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

alecthegeek
Copy link
Contributor

@alecthegeek alecthegeek commented Sep 13, 2024

Makefile changes:

  1. Add new variable for Docker user name, called DOCKER_USER, defaults to "jdkato"
  2. Add new variable for list of platforms, called DOCKER_BUILD_TARGETS
  3. Add new docker buildx commands to create and remove docker build containers
  4. Modify docker buildx build command to support DOCKER_BUILD_TARGETS and DOCKER_USER
  5. Change the way docker login is done (--password-stdin) to avoid annoying security warning
  6. Change LAST_TAG, LDFLAGS, and CURR_SHA to simply expanded variables to improve performance

Dockerfile changes

  1. Add new ARG value for Go version, called GOLANG_VER, defaults to "1.21"
  2. Remove GOOS=$TARGETOS GOARCH=$TARGETARCH and related definitions
  3. Remove "--platform=$BUILDPLATFORM" in FROM line

Assumptions:

Building and pushing Docker images is a manual process that takes place on the developer’s machine.

Integration into the GitHub actions would be desirable, but will require additional work.

Testing Notes:

Tested in a Git checkout with the command

make DOCKER_USER=<Docker Hub Username> DOCKER_PASS='<Docker Hub Token>' docker
docker container run -it --rm <Docker Hub Username>/vale --version

Tested on macOS host. it was necessary to disable Rosettta support

Related to #859

alecthegeek and others added 2 commits September 14, 2024 04:29
Makefile changes:

1. Add new variable  for Docker user name, called DOCKER_USER, defaults to "jdkato"
1. Add new variable for list of platforms, called DOCKER_BUILD_TARGETS
1. Add new docker buildx commands to create and remove docker build containers
1. Modify docker buildx build command to support DOCKER_BUILD_TARGETS and DOCKER_USER
1. Change the way docker login is done (--password-stdin) to avoid annoying security warning
1. Change LAST_TAG, LDFLAGS, and CURR_SHA to simply expanded variables to improve performance

Dockerfile changes

1. Add new ARG value for Go version, called GOLANG_VER, defaults to "1.21"
1. Remove GOOS=$TARGETOS GOARCH=$TARGETARCH and related definitions
1. Remove "--platform=$BUILDPLATFORM" in FROM line

Building and pushing Docker images is a manual process that takes place on the
developer’s machine.

Integration into the GitHub actions would be desirable, but will require additional work.

Tested in a Git checkout with the command

```sh
make DOCKER_USER=<Docker Hub Username> DOCKER_PASS='<Docker Hub Token>' docker
docker container run -it --rm <Docker Hub Username>/vale --version
```

Related to errata-ai#859
Modern best practice is to add a syntax entry to Dockerfiles

see  https://www.bretfisher.com/cloud-native-devops-36/
@jdkato jdkato merged commit f545fe2 into errata-ai:v3 Sep 26, 2024
1 check passed
@jdkato
Copy link
Member

jdkato commented Sep 26, 2024

Thanks!

@alecthegeek
Copy link
Contributor Author

You are very welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants