Skip to content

Commit

Permalink
Add build docker image workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
WaybackBot committed Aug 29, 2020
1 parent 2147403 commit a911bf0
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 5 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Docker

on:
push:
tags:
- v*

jobs:
release:
name: Build and push Docker images
runs-on: ubuntu-latest
steps:
- name: Checkout default branch
uses: actions/checkout@v2

- name: Install Buildx and QEMU
run: |
export DOCKER_BUILDKIT=1
docker build --platform=local -o . git://github.com/docker/buildx
mkdir -p ~/.docker/cli-plugins
mv buildx ~/.docker/cli-plugins/docker-buildx
docker run --rm --privileged multiarch/qemu-user-static:latest --reset -p yes --credential yes
docker buildx create --use --name build --node build --driver-opt network=host
- name: Login to Docker Hub
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Build and push Docker image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_IMAGE_PLATFORM: linux/386,linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le
run: |
DOCKER_IMAGE_NAME=$(echo $DOCKER_USERNAME | tr '[:upper:]' '[:lower:]')/wayback
DOCKER_IMAGE_VERSION=${GITHUB_REF#refs/*/v}
docker buildx build \
--platform "$DOCKER_IMAGE_PLATFORM" \
--output "type=image,push=true" \
--tag "$DOCKER_IMAGE_NAME":"$DOCKER_IMAGE_VERSION" \
--tag "$DOCKER_IMAGE_NAME":latest \
--file ./Dockerfile .
2 changes: 1 addition & 1 deletion .github/workflows/snapcraft.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Snapcraft Release
name: Snapcraft

on:
push:
Expand Down
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
# STEP 1 build executable binary
############################
FROM golang:1.14-alpine AS builder
RUN apk update && apk add --no-cache build-base ca-certificates
COPY . /tmp/wayback
RUN cd /tmp/wayback && make linux-amd64 && mv ./bin/wayback-linux-amd64 /wayback

RUN apk update && apk add --no-cache build-base ca-certificates git

ARG TARGETPLATFORM
WORKDIR /go/src/github.com/wabarc/wayback

RUN git clone --progress https://github.com/wabarc/wayback.git . \
&& sh ./build/binary.sh $TARGETPLATFORM \
&& mv ./bin/wayback-* /wayback

############################
# STEP 2 build a small image
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.1
0.3.0
39 changes: 39 additions & 0 deletions build/binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
#
# Perform package builder
set -eu
#set -x

GOOS=linux
GOARCH=amd64

for arg in "$@"; do
case $arg in
*arm/v7)
GOARCH=armv7
;;
*arm64)
GOARCH=armv8
;;
*386)
GOARCH=386
;;
*ppc64le)
GOARCH=ppc64le
;;
*s390x)
GOARCH=s390x
;;
windows*)
GOOS=windows
;;
darwin*)
GOOS=darwin
;;
esac
done

TARGET="${GOOS}-${GOARCH}"

make $TARGET

0 comments on commit a911bf0

Please sign in to comment.