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

Multi architecture container image #350

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Don't bring in anything into the build context

*
!bin/**
vendor

# Bring in our source code and dependency listings

!go.mod
!go.sum
!cmd/**
!pkg/**
72 changes: 72 additions & 0 deletions .github/workflows/build-docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Deploy multi-architecture Docker images for chartmuseum with buildx

on:
schedule:
- cron: '0 0 * * *' # everyday at midnight UTC
pull_request:
branches: master
push:
branches: master
tags:
- v*

jobs:
buildx:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Prepare
id: prepare
run: |
DOCKER_IMAGE=chartmuseum/chartmuseum
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
fi
TAGS="--tag ${DOCKER_IMAGE}:${VERSION} --tag ${DOCKER_IMAGE}:latest"
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg revision=$(git rev-parse --short HEAD) \
${TAGS} .
-
name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v3
-
name: Docker Buildx (build)
run: |
docker buildx build --no-cache --pull --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
-
name: Docker Login
if: success() && github.event_name != 'pull_request'
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
-
name: Docker Buildx (push)
if: success() && github.event_name != 'pull_request'
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
-
name: Docker Check Manifest
if: always() && github.event_name != 'pull_request'
run: |
docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
-
name: Clear
if: always() && github.event_name != 'pull_request'
run: |
rm -f ${HOME}/.docker/config.json
33 changes: 28 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
FROM alpine:3.12.0
RUN apk add --no-cache cifs-utils ca-certificates \
&& adduser -D -u 1000 chartmuseum
COPY bin/linux/amd64/chartmuseum /chartmuseum
USER 1000
# This will be our builder image

FROM golang:alpine

ARG version=0.12.0

ARG revision=master

COPY . /go/src/github.com/helm/chartmuseum

WORKDIR /go/src/github.com/helm/chartmuseum

RUN CGO_ENABLED=0 GO111MODULE=on go build \
-v --ldflags="-w -X main.Version=${version} -X main.Revision=${revision}" \
-o /chartmuseum \
cmd/chartmuseum/main.go


# This will be the final image

FROM alpine:latest

RUN apk add --no-cache cifs-utils ca-certificates

COPY --from=0 /chartmuseum /chartmuseum

USER 1000:1000

ENTRYPOINT ["/chartmuseum"]
7 changes: 0 additions & 7 deletions Dockerfile.arm

This file was deleted.

5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ build-armv7:
go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/linux/armv7/chartmuseum cmd/chartmuseum/main.go # linux

container-armv7: build-armv7
container-armv7:
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker build . -t chartmuseum:v$(VERSION) -f Dockerfile.arm

build-mac: export GOOS=darwin
build-mac: export GOARCH=amd64
build-mac: export CGO_ENABLED=0
Expand Down