-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Duplicate classic-watchdog make and docker files
**What** - Replicate the build process from classic-watchdog. The makefile will now cross-compile the binary on the local host and the Dockerfile will simply copy the required binary instead of building it inside docker Signed-off-by: Lucas Roesler <[email protected]>
- Loading branch information
1 parent
6ede08a
commit 881aba1
Showing
5 changed files
with
46 additions
and
191 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
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 |
---|---|---|
|
@@ -7,67 +7,43 @@ on: | |
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go-version: [ 1.15.x ] | ||
os: [ ubuntu-latest ] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- | ||
uses: actions/checkout@master | ||
- uses: actions/checkout@master | ||
with: | ||
fetch-depth: 1 | ||
- | ||
name: Docker meta | ||
id: meta | ||
uses: crazy-max/ghaction-docker-meta@v1 | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
images: "ghcr.io/${{ github.repository }}" | ||
- | ||
name: Set up QEMU | ||
go-version: ${{ matrix.go-version }} | ||
- name: Make all | ||
run: make all | ||
- 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 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- | ||
name: Docker Login | ||
- name: Docker Login | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- | ||
name: Build binaries | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile.redist | ||
platforms: linux/amd64 | ||
build-args: | | ||
VERSION=${{ steps.meta.outputs.version }} | ||
GIT_COMMIT=${{ github.sha }} | ||
load: true | ||
push: false | ||
# tag doesn't matter because we will never push this | ||
tags: redist/throwaway:latest | ||
- | ||
name: Copy binaries to host | ||
run: ./ci/copy_redist.sh redist/throwaway | ||
- | ||
name: Create SHA of binaries | ||
run: ./ci/hashgen.sh | ||
- | ||
name: Docker Build and Push | ||
registry: ghcr.io | ||
- name: Docker Build and Push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
context: ./ | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/arm/v7,linux/arm64 | ||
target: release | ||
build-args: | | ||
VERSION=${{ steps.meta.outputs.version }} | ||
GIT_COMMIT=${{ github.sha }} | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
- | ||
name: Upload binaries and their SHA to Github Release | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
tags: ghcr.io/openfaas/of-watchdog:${{ steps.get_tag.outputs.TAG }} | ||
- name: Upload release binaries | ||
uses: alexellis/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
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 |
---|---|---|
@@ -1,54 +1,14 @@ | ||
ARG goversion=1.15 | ||
FROM scratch as cache | ||
|
||
FROM teamserverless/license-check:0.3.9 as license-check | ||
COPY bin . | ||
|
||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:$goversion as builder | ||
FROM scratch as ship | ||
|
||
ARG TARGETPLATFORM | ||
ARG BUILDPLATFORM | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
ARG GIT_COMMIT="000000" | ||
ARG VERSION="dev" | ||
COPY --from=cache /fwatchdog-$TARGETARCH ./fwatchdog | ||
|
||
COPY --from=license-check /license-check /usr/bin/ | ||
|
||
ARG CGO_ENABLED=0 | ||
ARG GO111MODULE="on" | ||
ENV GOFLAGS=-mod=vendor | ||
ARG GOPROXY="" | ||
|
||
WORKDIR /app | ||
COPY vendor vendor | ||
COPY config config | ||
COPY executor executor | ||
COPY metrics metrics | ||
COPY version.go . | ||
COPY main.go . | ||
COPY go.mod . | ||
COPY go.sum . | ||
|
||
RUN license-check -path /app --verbose=false "Alex Ellis" "OpenFaaS Author(s)" | ||
RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") | ||
RUN go test -v ./... | ||
|
||
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 \ | ||
go build --ldflags "-s -w \ | ||
-X github.com/openfaas/of-watchdog/main.GitCommit=${GIT_COMMIT} \ | ||
-X github.com/openfaas/of-watchdog/main.Version=${VERSION}" \ | ||
-a -installsuffix cgo -o fwatchdog | ||
|
||
|
||
FROM scratch as release | ||
|
||
LABEL org.label-schema.license="MIT" \ | ||
org.label-schema.vcs-url="https://github.com/openfaas/of-watchdog" \ | ||
org.label-schema.vcs-type="Git" \ | ||
org.label-schema.name="openfaas/of-watchdog" \ | ||
org.label-schema.vendor="openfaas" \ | ||
org.label-schema.docker.schema-version="1.0" | ||
|
||
COPY --from=builder /app/fwatchdog /fwatchdog | ||
|
||
ENTRYPOINT ["/fwatchdog"] | ||
ENTRYPOINT ["/fwatchdog"] |
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