Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
build: add initial docker push workflow (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
rndmh3ro authored Oct 6, 2022
1 parent 544b070 commit a3c51d5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,46 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
run: bash ./scripts/brew_push_formula.sh ${{ github.event.inputs.release_version }}

docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build and export to Docker
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: |
allero/allero-cli:${{ github.event.inputs.release_version }}
allero/allero-cli:latest
-
name: Test
run: |
docker run --rm allero/allero-cli:${{ github.event.inputs.release_version }}
-
name: Login to DockerHub
uses: docker/login-action@v1
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
build-args: cli-version=${{ github.event.inputs.release_version }}
tags: |
allero/allero-cli:${{ github.event.inputs.release_version }}
allero/allero-cli:latest
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM golang:1.19-alpine AS builder
RUN apk --no-cache add curl gcc g++

ARG cli-version

WORKDIR /go/src/app
COPY . .

RUN curl -H "Authorization: token $GITHUB_TOKEN" --silent "https://api.github.com/repos/allero-io/allero-wip/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' > cli-version
RUN go get -d -v ./...
RUN go build -tags main -ldflags="-X github.com/allero-io/allero/cmd.CliVersion=$(cat cli-version)" -v
RUN go build -tags main -ldflags="-X github.com/allero-io/allero/cmd.CliVersion=${cli-version}" -v

FROM alpine:3.14
COPY --from=builder /go/src/app/allero /
ENTRYPOINT ["/allero"]
ENTRYPOINT ["/allero"]

0 comments on commit a3c51d5

Please sign in to comment.