Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Multi-platform docker build (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarampampam authored Jan 15, 2021
1 parent 72e20cb commit 4498715
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 22 deletions.
1 change: 0 additions & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
docs:
- '!CHANGELOG.md'
- '**/*.md'
- '**/*.MD'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Pull Request Labeler"
name: labeler

on: [pull_request_target]

Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ jobs:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 # Action page: <https://github.com/docker/setup-buildx-action>
id: buildx

- name: Docker login in default registry
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_LOGIN }}" --password-stdin

Expand All @@ -79,20 +83,12 @@ jobs:

- name: Build image
run: |
docker build \
docker buildx build \
--platform ${{ steps.buildx.outputs.platforms }} \
--tag "tarampampam/mikrotik-hosts-parser:${{ steps.values.outputs.version }}" \
--tag "tarampampam/mikrotik-hosts-parser:latest" \
--tag "ghcr.io/tarampampam/mikrotik-hosts-parser:${{ steps.values.outputs.version }}" \
--tag "ghcr.io/tarampampam/mikrotik-hosts-parser:latest" \
--build-arg "APP_VERSION=${{ steps.values.outputs.version }}" \
--push \
.
- name: Push image into default registry
run: |
docker push "tarampampam/mikrotik-hosts-parser:${{ steps.values.outputs.version }}"
docker push "tarampampam/mikrotik-hosts-parser:latest"
- name: Push image into ghcr.io registry
run: |
docker push "ghcr.io/tarampampam/mikrotik-hosts-parser:${{ steps.values.outputs.version }}"
docker push "ghcr.io/tarampampam/mikrotik-hosts-parser:latest"
9 changes: 8 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:

- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 2 # Fixes codecov error 'Issue detecting commit SHA'

- name: Go modules Cache # Docs: <https://git.io/JfAKn#go---modules>
uses: actions/cache@v2
Expand Down Expand Up @@ -170,7 +172,12 @@ jobs:
run: echo "::set-output name=value::`echo ${GITHUB_REF##*/} | sed -e 's/^[vV ]*//'`@`echo ${GITHUB_SHA} | cut -c1-8`"

- name: Build image
run: docker build -t mikrotik-hosts-parser:local --build-arg "APP_VERSION=${{ steps.version.outputs.value }}" -f ./Dockerfile .
run: |
docker build \
-t mikrotik-hosts-parser:local \
--build-arg "APP_VERSION=${{ steps.version.outputs.value }}" \
-f ./Dockerfile \
.
- name: Try to execute
run: docker run --rm mikrotik-hosts-parser:local version
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog][keepachangelog] and this project adher
- HTTP requests log records contains request processing duration
- Panics inside HTTP handlers now will be logged and JSON-formatted string will be returned (instead empty response)
- Frontend dependencies updated
- Docker image (for release) now supports `linux/amd64` + `linux/386` platforms

### Added

Expand Down
11 changes: 3 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# syntax=docker/dockerfile:1.2

# Image page: <https://hub.docker.com/_/golang>
FROM golang:1.15.6-alpine as builder
FROM --platform=${TARGETPLATFORM:-linux/amd64} golang:1.15.6-alpine as builder

# can be passed with any prefix (like `v1.2.3@GITHASH`)
# e.g.: `docker build --build-arg "APP_VERSION=v1.2.3@GITHASH" .`
Expand All @@ -14,13 +16,6 @@ RUN set -x \

WORKDIR /src

COPY ./go.mod ./go.sum ./

# Burn modules cache
RUN set -x \
&& go mod download \
&& go mod verify

COPY . .

# arguments to pass on each go tool link invocation
Expand Down

0 comments on commit 4498715

Please sign in to comment.