Skip to content
Permalink
Browse files

Updated github actions to build sequentially

  • Loading branch information
antoniomika committed Nov 9, 2019
1 parent 1352769 commit a7c2829548fb552fedc3c0b8311de86964a314a4
Showing with 33 additions and 12 deletions.
  1. +28 −11 .github/workflows/docker.yml
  2. +5 −1 Dockerfile
@@ -8,23 +8,40 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Register multiarch for Docker
run: docker run --privileged linuxkit/binfmt:v0.7
run: |
docker run --privileged linuxkit/binfmt:v0.7
- name: Install buildx
run: mkdir -p ~/.docker/cli-plugins && wget https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64 -O ~/.docker/cli-plugins/docker-buildx && chmod a+x ~/.docker/cli-plugins/docker-buildx
run: |
mkdir -p ~/.docker/cli-plugins
wget https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64 \
-O ~/.docker/cli-plugins/docker-buildx
chmod a+x ~/.docker/cli-plugins/docker-buildx
- name: Setup buildkit
run: docker buildx create --name builder && docker buildx use builder && docker buildx inspect --bootstrap && docker buildx ls
run: |
docker buildx create --name builder
docker buildx use builder
docker buildx inspect --bootstrap
docker buildx ls
- name: Login to GitHub Docker Registry
env:
DOCKER_USERNAME: ${{ secrets.GITHUB_DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_DOCKER_PASSWORD }}
run: echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
- name: Build and push the Docker images
run: docker buildx build --push --platform linux/arm/v7,linux/arm64,linux/amd64 -t $GITHUB_REPOSITORY:$GITHUB_SHA .
- name: Build and push the versioned Docker images
if: startsWith(github.ref, 'refs/tags/v')
run: |
export REF="${GITHUB_REF//refs\/tags\/}"
docker buildx build --push --platform linux/arm/v7,linux/arm64,linux/amd64 -t $GITHUB_REPOSITORY:$REF .
- name: Build and push the latest Docker images
if: github.event.base_ref == 'refs/heads/master'
run: docker buildx build --push --platform linux/arm/v7,linux/arm64,linux/amd64 -t $GITHUB_REPOSITORY:latest .
OTHER_TAGS=""
REF="master"
if [[ $GITHUB_REF =~ ^refs\/tags\/v.*$ ]]
then
REF="${GITHUB_REF//refs\/tags\/}"
OTHER_TAGS="$OTHER_TAGS -t $GITHUB_REPOSITORY:$REF -t $GITHUB_REPOSITORY:latest"
fi
docker buildx build \
--push \
--platform linux/arm/v7,linux/arm64,linux/amd64 \
--build-arg VERSION=$REF \
--build-arg COMMIT=$GITHUB_SHA \
--build-arg DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
-t $GITHUB_REPOSITORY:$GITHUB_SHA \
$OTHER_TAGS .
@@ -15,7 +15,11 @@ RUN go mod download

COPY . .

RUN go install
ARG VERSION=dev
ARG COMMIT=none
ARG DATE=unknown

RUN go install -ldflags="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}"
RUN go test -i ./...

FROM scratch

0 comments on commit a7c2829

Please sign in to comment.
You can’t perform that action at this time.