Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
virtualzone committed Jun 17, 2022
0 parents commit 7da9826
Show file tree
Hide file tree
Showing 14 changed files with 926 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
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_*"
16 changes: 16 additions & 0 deletions .github/workflows/run-test.yml
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
14 changes: 14 additions & 0 deletions Dockerfile
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"]
Loading

0 comments on commit 7da9826

Please sign in to comment.