Skip to content

Commit

Permalink
feat: added pipeline for building docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
rlardy-ulule committed Aug 25, 2023
1 parent d8c3a2a commit be5eb82
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 42 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/go.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/golangci-lint.yml

This file was deleted.

71 changes: 71 additions & 0 deletions .github/workflows/mover.yml
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
18 changes: 18 additions & 0 deletions Dockerfile
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"]

0 comments on commit be5eb82

Please sign in to comment.