-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added pipeline for building docker image
- Loading branch information
1 parent
d8c3a2a
commit be5eb82
Showing
4 changed files
with
89 additions
and
42 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Mover | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
|
||
linter: | ||
timeout-minutes: 30 | ||
runs-on: ubuntu-latest | ||
env: | ||
GO_VERSION: 1.15 | ||
GOLINT_VERSION: 1.51.2 | ||
|
||
steps: | ||
- name: Checking out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setting up Go environment | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '^${{ env.GO_VERSION }}' | ||
cache: true | ||
cache-dependency-path: go.sum | ||
|
||
- name: Download gomod dependencies | ||
run: go mod download -x | ||
|
||
- name: Run linters | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v${{ env.GOLINT_VERSION }} | ||
args: -v -c .golangci.yml --timeout 10m | ||
# skip-cache: true | ||
# skip-pkg-cache: true | ||
# skip-build-cache: true | ||
|
||
build: | ||
timeout-minutes: 30 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checking out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to GCR | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ vars.REGISTRY }} | ||
username: _json_key | ||
password: ${{ secrets.GCR_JSON_KEY }} | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ulule | ||
password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build app and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
tags: ${{ vars.REGISTRY }}/mover:${{ github.sha }},${{ vars.REGISTRY }}/mover:latest | ||
cache-from: type=registry,ref=${{ vars.REGISTRY }}/mover:cache | ||
cache-to: type=registry,ref=${{ vars.REGISTRY }}/mover:cache,mode=max |
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,18 @@ | ||
# syntax=docker/dockerfile:1 | ||
FROM golang:1.15-alpine AS mover-builder | ||
|
||
ARG GO111MODULE=on | ||
ARG CGO_ENABLED=0 | ||
|
||
WORKDIR /go/src/github.com/ulule/mover | ||
|
||
COPY --link . . | ||
|
||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
go build -o mover ./cmd/mover/ | ||
|
||
FROM scratch | ||
|
||
COPY --from=mover-builder /go/src/github.com/ulule/mover/mover /mover | ||
|
||
ENTRYPOINT ["/mover"] |