mirror of
https://github.com/elyby/accounts-profiles-endpoint.git
synced 2024-11-29 18:22:02 +05:30
Introduce docker build
This commit is contained in:
parent
87aa380a9d
commit
9cad666e9f
25
.github/workflows/build.yml
vendored
25
.github/workflows/build.yml
vendored
@ -1,6 +1,12 @@
|
||||
name: Build
|
||||
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
go_version: 1.21
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -9,10 +15,10 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go 1.21
|
||||
- name: Setup Go ${{ env.go_version }}
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 1.21
|
||||
go-version: ${{ env.go_version }}
|
||||
cache-dependency-path: go.sum
|
||||
|
||||
- name: Install dependencies
|
||||
@ -20,3 +26,16 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: go build ./...
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
push: true
|
||||
tags: ghcr.io/${{ github.repository }}:latest
|
||||
|
21
Dockerfile
Normal file
21
Dockerfile
Normal file
@ -0,0 +1,21 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM golang:1.21 AS builder
|
||||
|
||||
COPY . /build
|
||||
WORKDIR /build
|
||||
RUN go mod download
|
||||
|
||||
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
|
||||
go build \
|
||||
-trimpath \
|
||||
-ldflags="-w -s" \
|
||||
-o app \
|
||||
main.go
|
||||
|
||||
FROM scratch
|
||||
|
||||
COPY --from=builder /build/app /root/app
|
||||
|
||||
ENTRYPOINT ["/root/app"]
|
||||
EXPOSE 8080
|
Loading…
Reference in New Issue
Block a user