-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7da9826
Showing
14 changed files
with
926 additions
and
0 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 @@ | ||
build/ |
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,57 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
branches: [ main ] | ||
|
||
jobs: | ||
|
||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: '^1.18' | ||
- name: Set version env | ||
run: echo "CI_VERSION=$(cat VERSION | awk NF)" >> $GITHUB_ENV | ||
- name: Run build | ||
run: make | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Log into registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: docker.io | ||
username: virtualzone | ||
password: ${{ secrets.CI_REGISTRY_PASSWORD }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
push: true | ||
tags: | | ||
virtualzone/http-redirect:${{ env.CI_VERSION }} | ||
virtualzone/http-redirect:latest | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
- name: Create a GitHub release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ env.CI_VERSION }} | ||
name: ${{ env.CI_VERSION }} | ||
artifacts: "build/http-redirect_*" |
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,16 @@ | ||
name: Run Tests | ||
|
||
on: [pull_request, workflow_dispatch] | ||
|
||
jobs: | ||
|
||
container-job: | ||
runs-on: ubuntu-latest | ||
container: golang:1.18-alpine | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run tests | ||
working-directory: . | ||
run: go test -cover -v | ||
env: | ||
CGO_ENABLED: 0 |
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 @@ | ||
build/ |
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,14 @@ | ||
FROM golang:1.18-bullseye AS server-builder | ||
RUN export GOBIN=$HOME/work/bin | ||
WORKDIR /go/src/app | ||
ADD . . | ||
RUN echo "package main\n\nconst AppVersion = \"`cat ./VERSION | awk NF`\"" > version.go | ||
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o http-redirect . | ||
|
||
FROM gcr.io/distroless/static-debian11 | ||
COPY --from=server-builder /go/src/app/http-redirect /app/ | ||
COPY ./VERSION /app/ | ||
WORKDIR /app | ||
EXPOSE 8080 | ||
USER 65532:65532 | ||
CMD ["./http-redirect"] |
Oops, something went wrong.