Skip to content

Commit

Permalink
Add Dockerfile and GH workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Fmar committed Jan 29, 2024
1 parent 47e327a commit 5001afd
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
28 changes: 28 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Linux Docker build
on:
push:
release:
types: [published]
jobs:
build:
env:
REGISTRY: ghcr.io
IMAGENAME: ${{ github.event.repository.name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Check out code
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.21.x
- name: Checkout code
uses: actions/checkout@v2
- name: Docker build
uses: mr-smithers-excellent/docker-build-push@v6
id: build
with:
image: ${{ env.IMAGENAME }}
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.21-alpine as builder

# Move to working directory /build
WORKDIR /build

# Copy and download dependency using go mod
COPY go.mod .
COPY go.sum .
RUN go mod download

# Copy the code into the container
COPY . .

# Build the application
RUN go build -o main cmd/server/main.go

# Start a new, final image to reduce size.
FROM alpine as final

# Copy the binaries and entrypoint from the builder image.
COPY --from=builder /build/main /bin/

ENTRYPOINT [ "/bin/main" ]

0 comments on commit 5001afd

Please sign in to comment.