This repository has been archived by the owner on Dec 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**What** - Update the Dockerfile to support multiarch builds via buildx - Add Github Action workflow for build and test - Add Github Action workflow to publish the images Signed-off-by: Lucas Roesler <[email protected]>
- Loading branch information
1 parent
856fbba
commit d3d282a
Showing
14 changed files
with
254 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: [ '*' ] | ||
pull_request: | ||
branches: [ '*' ] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
go-version: [1.13.x] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Get Owner name | ||
id: get_owner_name | ||
run: echo ::set-output name=OWNER_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print tolower($1)}' | sed -e "s/:refs//") | ||
- name: Get Repository name | ||
id: get_repo_name | ||
run: echo ::set-output name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print tolower($2)}' | sed -e "s/:refs//") | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Build x86_64 container into library | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: false | ||
platforms: linux/amd64 | ||
target: ship | ||
build-args: | | ||
VERSION=latest-dev | ||
GIT_COMMIT=${{ github.sha }} | ||
NS=${{ steps.get_owner_name.outputs.OWNER_NAME }} | ||
REPO=${{ steps.get_repo_name.outputs.REPOSITORY_NAME }} | ||
load: true | ||
# note that the image tags for build/test need to match the value in the contrib/docker-compose.yml | ||
tags: ghcr.io/openfaas/faas-swarm:latest-dev | ||
- name: Install faas-cli | ||
run: ./contrib/get_tools.sh | ||
- name: Init Swarm | ||
run: docker swarm init | ||
- name: Deploy OpenFaaS | ||
run: cd contrib && docker stack deploy func --compose-file docker-compose.yml | ||
env: | ||
BASIC_AUTH: "false" | ||
- name: Wait for startup to finish | ||
run : sleep 15 | ||
- name: Debug service state | ||
run: docker service ps func_faas-swarm func_gateway | ||
- name: Debug service logs | ||
run: docker service logs func_faas-swarm | ||
- name: Debug gateway logs | ||
run: docker service logs func_gateway | ||
- name: Authenticate faas-cli | ||
run: cd contrib && cat ci-auth-pass.txt | faas-cli login --username admin --password-stdin | ||
- name: Deploy function | ||
run: faas-cli deploy --image=functions/alpine:latest --fprocess=cat --name "echo" | ||
- name: Verify deployment | ||
run: ./contrib/ci-verify-fnc-deployment.sh | ||
- name: Test invoke the function | ||
run: faas-cli invoke echo <<< "foobar" | grep "foobar" | ||
- name: Remove the function | ||
run: faas-cli rm echo | ||
- name: Stop test cluster | ||
run: docker stack rm func | ||
- name: Build multi-arch containers for validation only | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
outputs: "type=image,push=false" | ||
platforms: linux/amd64,linux/arm/v7,linux/arm64 | ||
tags: ghcr.io/openfaas/faas-swarm:${{ github.sha }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
uses: actions/checkout@master | ||
with: | ||
fetch-depth: 1 | ||
- name: Get tags | ||
id: get_tag | ||
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} | ||
- name: Set Username/Repo and ImagePrefix as ENV vars | ||
run: | | ||
echo "USER_REPO"=$(echo "$GITHUB_REPOSITORY" | awk '{print tolower($1)}' | sed -e "s/:refs//") >> $GITHUB_ENV && \ | ||
echo "IMAGE_PREFIX"=$(echo "ghcr.io/$GITHUB_REPOSITORY" | awk '{print tolower($1)}' | sed -e "s/:refs//") >> $GITHUB_ENV | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to Github Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Build and Push container images | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/arm/v7,linux/arm64 | ||
target: ship | ||
build-args: | | ||
VERSION=${{ steps.get_tag.outputs.TAG }} | ||
GIT_COMMIT=${{ github.sha }} | ||
REPO_URL=https://github.com/${{ env.USER_REPO }} | ||
push: true | ||
# tag names need to match the repo so that they can be safely pushed, even in forks. | ||
tags: | | ||
${{ env.IMAGE_PREFIX }}:${{ github.sha }} | ||
${{ env.IMAGE_PREFIX }}:${{ steps.get_tag.outputs.TAG }} | ||
${{ env.IMAGE_PREFIX }}:latest |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.