Skip to content

Commit 3baea56

Browse files
committed
ci: add Dockerfile and ghcr upload workflow
1 parent 725dc8c commit 3baea56

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

.github/workflows/docker.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build and Push Docker Images
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build-and-push:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Log in to Container Registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract metadata
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38+
tags: |
39+
type=semver,pattern={{version}}
40+
type=semver,pattern={{major}}.{{minor}}
41+
type=semver,pattern={{major}}
42+
type=raw,value=latest
43+
44+
- name: Build and push
45+
uses: docker/build-push-action@v5
46+
with:
47+
context: .
48+
platforms: linux/amd64, linux/arm64
49+
push: true
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}
52+
build-args: |
53+
VERSION=${{ github.ref_name }}
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM node:16-alpine AS map-builder
2+
WORKDIR /build
3+
COPY map/package*.json ./
4+
RUN npm install
5+
COPY map/ ./
6+
RUN npm run compile
7+
8+
FROM golang:1.25.4-alpine AS go-builder
9+
WORKDIR /build
10+
COPY Companion/go.* ./
11+
RUN go mod download
12+
COPY Companion/ ./
13+
ARG VERSION=dev
14+
RUN CGO_ENABLED=0 go build -ldflags="-X 'main.Version=${VERSION}'" -o companion main.go
15+
16+
FROM alpine:latest
17+
ARG PROMETHEUS_VERSION=2.27.1
18+
ARG TARGETARCH
19+
WORKDIR /app
20+
21+
RUN apk --no-cache add curl tar && \
22+
curl -sL https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-${TARGETARCH}.tar.gz | tar xz && \
23+
mv prometheus-${PROMETHEUS_VERSION}.linux-${TARGETARCH} prometheus && \
24+
apk del curl tar
25+
26+
COPY --from=go-builder /build/companion /app/
27+
COPY --from=map-builder /build/index.html /build/map-16k.png /build/vendor /build/img /build/js /app/map/
28+
COPY Companion/prometheus.yml /app/prometheus/prometheus.yml
29+
30+
ENV FRM_LOG_STDOUT=true
31+
EXPOSE 9000
32+
33+
CMD ["/app/companion"]

0 commit comments

Comments
 (0)