Skip to content

Commit 13c8113

Browse files
Greg Maslowskiclaude
andcommitted
Add CI and multi-arch image publishing to GHCR
- CI workflow: go vet + build on push/PR. - Docker workflow: build and push linux/amd64,arm64 to ghcr.io on main (:latest, :sha-<commit>) and on vX.Y.Z tags (:X.Y.Z, :X.Y, :X). - Dockerfile cross-compiles per target arch for fast multi-arch builds. - README: badges and published-image usage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7af5594 commit 13c8113

4 files changed

Lines changed: 93 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-go@v5
17+
with:
18+
go-version: "1.22"
19+
cache: true
20+
- run: go vet ./...
21+
- run: go build ./...

.github/workflows/docker.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Docker
2+
3+
# Publishes a multi-arch image to GHCR.
4+
# - push to main -> :latest and :sha-<commit>
5+
# - push a tag vX.Y.Z -> :X.Y.Z, :X.Y, :X (semantic version images)
6+
on:
7+
push:
8+
branches: [main]
9+
tags: ["v*.*.*"]
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
jobs:
16+
image:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: docker/setup-qemu-action@v3
22+
- uses: docker/setup-buildx-action@v3
23+
24+
- name: Log in to GHCR
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Derive tags and labels
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: ghcr.io/${{ github.repository }}
36+
tags: |
37+
type=raw,value=latest,enable={{is_default_branch}}
38+
type=sha
39+
type=semver,pattern={{version}}
40+
type=semver,pattern={{major}}.{{minor}}
41+
type=semver,pattern={{major}}
42+
43+
- name: Build and push
44+
uses: docker/build-push-action@v6
45+
with:
46+
context: .
47+
platforms: linux/amd64,linux/arm64
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
cache-from: type=gha
52+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# build
2-
FROM golang:1.22-alpine AS build
1+
# build (cross-compile from the native builder arch to the target arch)
2+
FROM --platform=$BUILDPLATFORM golang:1.22-alpine AS build
3+
ARG TARGETOS TARGETARCH
34
WORKDIR /src
45
RUN apk add --no-cache git
56
COPY . .
6-
RUN go mod tidy && CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/teslamate-dash .
7+
RUN go mod tidy && CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
8+
go build -trimpath -ldflags="-s -w" -o /out/teslamate-dash .
79

810
# run (distroless, non-root, static)
911
FROM gcr.io/distroless/static-debian12:nonroot

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# TeslaMate Dash
22

3+
[![CI](https://github.com/gmaslowski/teslamate-dash/actions/workflows/ci.yml/badge.svg)](https://github.com/gmaslowski/teslamate-dash/actions/workflows/ci.yml)
4+
[![Docker](https://github.com/gmaslowski/teslamate-dash/actions/workflows/docker.yml/badge.svg)](https://github.com/gmaslowski/teslamate-dash/actions/workflows/docker.yml)
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6+
37
A small, self-hosted, **read-only dashboard for [TeslaMate](https://github.com/teslamate-org/teslamate)**.
48
It connects to your existing TeslaMate Postgres database and renders a clean, map-first view of your
59
driving and charging history. One static Go binary, one container, no second database, and nothing is
@@ -39,6 +43,17 @@ Or with Go (1.22+):
3943
go run . # demo mode when no DATABASE_HOST/TC_DSN is set
4044
```
4145

46+
### Published image
47+
48+
Multi-arch images (linux/amd64 and linux/arm64) are published to GHCR on every release:
49+
50+
```bash
51+
docker run --rm -p 4001:4001 ghcr.io/gmaslowski/teslamate-dash:latest
52+
# or pin a version: ghcr.io/gmaslowski/teslamate-dash:0.1.0
53+
```
54+
55+
Tags: `latest` (tip of `main`), `X.Y.Z` / `X.Y` / `X` (semver from git tags), and `sha-<commit>`.
56+
4257
## Connect to your TeslaMate database
4358

4459
Run it on the same Docker network as TeslaMate so it can reach Postgres. It reuses TeslaMate's

0 commit comments

Comments
 (0)