Skip to content

Commit

Permalink
Updated to build via GitHub Actions and convert to a multi-arch build
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Ison <[email protected]>
  • Loading branch information
CodeCutterUK authored and alexellis committed Nov 10, 2020
1 parent eefea88 commit 349aa8b
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 36 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/docker-tagged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Docker Tagged Build

on:
push:
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest

- name: Login to GHCR
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io

- name: Build image and push to container registies
id: docker_build
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: ghcr.io/openfaas/nats-connector:${{ steps.get_tag.outputs.TAG }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
35 changes: 35 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Docker Build

on:
push:
branches:
- "*"
push_request:
branches:
- "*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest

- name: Build
id: docker_build
uses: docker/build-push-action@v2
with:
push: false
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: ghcr.io/openfaas/nats-connector:latest-dev
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM golang:1.13 as build
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.13 as build

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

ENV GO111MODULE=on
ENV CGO_ENABLED=0
Expand All @@ -16,9 +21,9 @@ COPY main.go .
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"

RUN go test -mod=vendor -v ./...
RUN CGO_ENABLED=0 GOOS=linux go build -mod=vendor -a -ldflags "-s -w" -installsuffix cgo -o /usr/bin/connector
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=vendor -a -ldflags "-s -w" -installsuffix cgo -o /usr/bin/connector

FROM alpine:3.12 as ship
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12 as ship
RUN apk add --no-cache ca-certificates

COPY --from=build /usr/bin/connector /usr/bin/connector
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# nats-connector

[![Build Status](https://travis-ci.com/openfaas-incubator/nats-connector.svg?branch=master)](https://travis-ci.com/openfaas-incubator/nats-connector)
[![Docker Build Status](https://github.com/openfaas-incubator/nats-connector/workflows/docker/badge.svg)](https://github.com/openfaas-incubator/nats-connector/actions)
[![Go Report Card](https://goreportcard.com/badge/github.com/openfaas-incubator/nats-connector)](https://goreportcard.com/report/github.com/openfaas-incubator/nats-connector)
[![GoDoc](https://godoc.org/github.com/openfaas-incubator/nats-connector?status.svg)](https://godoc.org/github.com/openfaas-incubator/nats-connector)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Expand Down

0 comments on commit 349aa8b

Please sign in to comment.