Skip to content

Commit

Permalink
Convert Gateway to Github Actions
Browse files Browse the repository at this point in the history
Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
  • Loading branch information
Waterdrips authored and alexellis committed Dec 10, 2020
1 parent 4ced7ca commit a558307
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 336 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,127 @@
name: build

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
# Auth
# Watchdog containers
# Watchdog bins + shas

jobs:

# Run the CI tests
build-test:
strategy:
matrix:
go-version: [1.13.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Run CI
run: make build test-ci

build-gateway:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.13.x]
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::latest-dev
- name: Get Repo Owner
id: get_repo_owner
run: echo ::set-output name=repo_owner::$(echo ${{ github.event.repository.owner.login }} | tr '[:upper:]' '[:lower:]')
- name: Build Gateway
uses: docker/build-push-action@v2
with:
context: .
file: ./gateway/Dockerfile
outputs: "type=image,push=false"
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: |
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ steps.get_tag.outputs.TAG }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ github.sha }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:latest
build-watchdog:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.13.x]
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::latest-dev
- name: Get Repo Owner
id: get_repo_owner
run: echo ::set-output name=repo_owner::$(echo ${{ github.event.repository.owner.login }} | tr '[:upper:]' '[:lower:]')
- name: Build Watchdog
uses: docker/build-push-action@v2
with:
context: .
file: ./gateway/Dockerfile
outputs: "type=image,push=false"
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: |
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ steps.get_tag.outputs.TAG }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ github.sha }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:latest
build-auth-containers:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.13.x]
svc: [
basic-auth
]
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::latest-dev
- name: Get Repo Owner
id: get_repo_owner
run: echo ::set-output name=repo_owner::$(echo ${{ github.event.repository.owner.login }} | tr '[:upper:]' '[:lower:]')
- name: Build ${{ matrix.svc }}
uses: docker/build-push-action@v2
with:
context: ./auth/${{ matrix.svc }}
file: ./auth/${{ matrix.svc }}/Dockerfile
outputs: "type=image,push=false"
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: |
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:${{ steps.get_tag.outputs.TAG }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:${{ github.sha }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:latest
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

21 changes: 5 additions & 16 deletions Makefile
@@ -1,29 +1,18 @@
TAG?=latest
NS?=openfaas

.PHONY: build
build:
./build.sh

.PHONY: build-gateway
build-gateway:
(cd gateway; ./build.sh latest-dev)
(cd gateway; docker buildx build --platform linux/amd64 -t $NS/gateway:latest-dev .)

.PHONY: test-ci
test-ci:
./contrib/ci.sh

.PHONY: ci-armhf-build
ci-armhf-build:
(cd gateway; ./build.sh $(TAG) ; cd ../auth/basic-auth ; ./build.sh $(TAG))

.PHONY: ci-armhf-push
ci-armhf-push:
(cd gateway; ./push.sh $(TAG) ; cd ../auth/basic-auth ; ./push.sh $(TAG))

.PHONY: ci-arm64-build
ci-arm64-build:
(cd gateway; ./build.sh $(TAG) ; cd ../auth/basic-auth ; ./build.sh $(TAG))

.PHONY: ci-arm64-push
ci-arm64-push:
(cd gateway; ./push.sh $(TAG) ; cd ../auth/basic-auth ; ./push.sh $(TAG))
.PHONY: binaries
binaries:
echo TODO
18 changes: 11 additions & 7 deletions auth/basic-auth/Dockerfile
@@ -1,25 +1,29 @@
FROM teamserverless/license-check:0.3.6 as license-check
FROM --platform=${BUILDPLATFORM:-linux/amd64} teamserverless/license-check:0.3.6 as license-check

FROM golang:1.13-alpine3.11 as build
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.13 as build

ENV GO111MODULE=off
ENV CGO_ENABLED=0

RUN apk add --no-cache curl ca-certificates
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

COPY --from=license-check /license-check /usr/bin/

WORKDIR /go/src/handler
COPY . .

# Run a gofmt and exclude all vendored code.

RUN license-check -path ./ --verbose=false "OpenFaaS Authors" "OpenFaaS Author(s)" \
&& test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))" \
&& CGO_ENABLED=0 GOOS=linux \
RUN license-check -path ./ --verbose=false "OpenFaaS Authors" "OpenFaaS Author(s)"
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH } test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH } \
go build --ldflags "-s -w" -a -installsuffix cgo -o handler . && \
go test $(go list ./... | grep -v /vendor/) -cover

FROM alpine:3.11 as ship
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12 as ship
# Add non-root user
RUN addgroup -S app && adduser -S -g app app \
&& mkdir -p /home/app \
Expand Down
38 changes: 0 additions & 38 deletions auth/basic-auth/Dockerfile.arm64

This file was deleted.

4 changes: 2 additions & 2 deletions build.sh
@@ -1,8 +1,8 @@
#!/bin/bash
set -e

if [ ! -s "$TRAVIS_TAG" ] ; then
echo "This build will be published under the tag: ${TRAVIS_TAG}"
if [ ! -s "$TAG" ] ; then
echo "This build will be published under the tag: ${TAG}"
fi

(cd gateway && ./build.sh)
Expand Down
15 changes: 0 additions & 15 deletions ci/registryLogin.sh

This file was deleted.

0 comments on commit a558307

Please sign in to comment.