Skip to content

Commit

Permalink
feat: Add docker image builds
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Aug 12, 2024
1 parent 01e0285 commit 515c687
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
README
.github
main
tailservice
*.exe
16 changes: 14 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
version: 2
updates:
- directory: /
package-ecosystem: gomod
package-ecosystem: gomod
rebase-strategy: auto
schedule:
interval: daily
interval: daily

- directory: /
package-ecosystem: docker
rebase-strategy: auto
schedule:
interval: daily

- directory: /
package-ecosystem: github-actions
rebase-strategy: auto
schedule:
interval: daily
50 changes: 49 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Release
on:
release:
types: [published]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
Expand Down Expand Up @@ -30,4 +33,49 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
overwrite: true
files: |
tailservice-${{ matrix.os }}-${{ matrix.arch }}
tailservice-${{ matrix.os }}-${{ matrix.arch }}
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

- name: set environment variables
run: |
image="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
image="$(echo $image | tr '[:upper:]' '[:lower:]')"
echo "FULL_IMAGE_NAME=${image}" >> $GITHUB_ENV
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.FULL_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.22.6 as builder

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

WORKDIR /app/
ADD . .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o tailservice main.go

FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.20.2

RUN adduser -D -u 1000 tailservice -h /app/data
VOLUME /app/data

WORKDIR /app/
COPY --from=builder /app/tailservice /app/tailservice
ENTRYPOINT ["/app/tailservice"]

0 comments on commit 515c687

Please sign in to comment.