Giter VIP home page Giter VIP logo

automating-multi-platform-docker-container-deployments's Introduction

automating-multi-platform-docker-container-deployments

Automating Multi-Platform Docker Container Deployments in Kubernetes with ArgoCD presentation at Docker Istanbul Community Meetup Group

How to build and push multi-arch images to GitHub Container Registrt (ghcr.io)

There is an amazing command called docker init that can be used to initialize a Dockerfile with a template.

docker init

Then, you should do some modifications on the Dockerfile to make it multi-arch but instead of using QEMU to build multi-arch images, we will use Go's native cross-compilation support in which we'll be using GOOS and GOARCH variables.

FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build
...


ARG TARGETOS TARGETARCH
RUN --mount=type=cache,target=/go/pkg/mod/ \
    --mount=type=bind,target=. \
    CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /bin/server .
...

this modification will make your build process a lot faster!!! ๐Ÿš€

Then, you should build and push your image to GitHub Container Registry (ghcr.io) with the following command:

โš ๏ธ You should be running your own builder instance to be able to build multi-arch images since the Docker Daemon is not supporting multi-arch builds yet. docker buildx create --name my-own-builder --use --bootstrap

Also do not forget to replace the developerguy with your own GitHub username.

docker buildx build -t developerguy/hello-go-server:latest --platform linux/amd64,linux/arm64 . --push

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.