Skip to content

Commit b6acaec

Browse files
committed
ci/cd: add container workflow
1 parent e07c13f commit b6acaec

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

.github/workflows/container.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: Build and Push Container
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
container-build-push:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Login to GitHub Container Registry
14+
uses: docker/login-action@v3
15+
with:
16+
registry: ghcr.io
17+
username: ${{ github.actor }}
18+
password: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v3
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Build and Push Container
27+
uses: docker/build-push-action@v6
28+
with:
29+
file: Containerfile
30+
push: true
31+
tags: |
32+
ghcr.io/sudomateo/yeetcode:latest
33+
ghcr.io/sudomateo/yeetcode:${{ github.sha }}
34+
platforms: |
35+
linux/amd64
36+
linux/arm64

Containerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM golang:1.24.0 AS builder
2+
3+
ARG TARGETARCH
4+
5+
WORKDIR /app
6+
COPY go.mod go.sum .
7+
RUN go mod download
8+
9+
COPY . .
10+
RUN CGO_ENABLED=0 go build -v -trimpath -ldflags='-extldflags=-static -w -s' .
11+
12+
FROM debian:bookworm-slim
13+
14+
RUN apt-get update -y && apt-get install -y ca-certificates
15+
16+
COPY --from=builder /app/yeetcode /usr/bin/yeetcode
17+
18+
CMD ["yeetcode"]

0 commit comments

Comments
 (0)