Skip to content

Commit d9d2bda

Browse files
committed
Move to ghcr
1 parent 08ea247 commit d9d2bda

4 files changed

Lines changed: 59 additions & 47 deletions

File tree

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,55 @@
1-
name: lint-test-build-push
1+
name: build-push
22
on:
33
push:
4-
paths-ignore:
5-
- "**/*.md"
6-
- "renovate.json5"
7-
branches:
8-
- "**"
9-
tags:
10-
- "*"
11-
12-
concurrency:
13-
group: ${{ github.workflow }}-${{ github.ref }}
14-
cancel-in-progress: true
15-
16-
permissions:
17-
contents: read
4+
workflow_dispatch:
5+
186
jobs:
197
lint-test:
208
runs-on: ubuntu-24.04
219
steps:
22-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
10+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6
2311

24-
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
12+
- name: Set up Go
13+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6
2514
with:
26-
go-version: ">=1.25.0"
15+
go-version-file: "go.mod"
16+
17+
- name: go mod tidy
18+
run: |
19+
go mod tidy
20+
if ! git diff --exit-code go.mod go.sum; then
21+
echo "Error: go.mod or go.sum is not tidy. Run 'go mod tidy' locally and commit the changes."
22+
exit 1
23+
fi
2724
2825
- name: golangci-lint
29-
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
26+
uses: golangci/golangci-lint-action@e7fa5ac41e1cf5b7d48e45e42232ce7ada589601 # v9
3027
with:
3128
version: latest
3229

33-
- name: Test with the Go CLI
34-
run: go test -v -race ./...
30+
- name: Install dependencies
31+
run: go get .
32+
33+
- run: go build
34+
35+
- name: unit test
36+
run: go test -race -v ./...
37+
38+
- name: coverage
39+
run: go test -v -coverprofile=coverage.out -covermode=atomic ./...
40+
41+
- name: upload coverage to codecov
42+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5
43+
with:
44+
files: ./coverage.out
45+
fail_ci_if_error: false
46+
env:
47+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3548

36-
build-push:
49+
run:
3750
needs: [lint-test]
38-
uses: libops/actions/.github/workflows/build-push.yml@main
51+
uses: libops/.github/.github/workflows/build-push-ghcr.yaml@main
3952
permissions:
4053
contents: read
4154
packages: write
42-
id-token: write
4355
secrets: inherit

Dockerfile

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
FROM golang:1.25-alpine3.22 AS builder
1+
FROM ghcr.io/libops/go1.25:main@sha256:f43c9b34f888d2ac53e87c8e061554f826b8eb580863d7b21fd787b6f0378f8f AS builder
2+
3+
SHELL ["/bin/ash", "-o", "pipefail", "-ex", "-c"]
24

35
WORKDIR /app
4-
COPY go.* ./
5-
RUN go mod download
66

7-
COPY . .
8-
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o lightsout .
7+
COPY go.* ./
8+
RUN --mount=type=cache,target=/go/pkg/mod \
9+
go mod download
910

10-
FROM alpine:3.22
11-
RUN apk --no-cache add ca-certificates curl docker-cli
12-
WORKDIR /root/
11+
COPY *.go ./
1312

14-
COPY --from=builder /app/lightsout .
13+
RUN --mount=type=cache,target=/root/.cache/go-build \
14+
CGO_ENABLED=0 go build -ldflags="-s -w" -o /app/binary .
1515

16-
# Set default environment variables
17-
ENV PORT=8808
18-
ENV INACTIVITY_TIMEOUT=90
19-
ENV LOG_LEVEL=INFO
20-
ENV GOOGLE_PROJECT_ID=""
21-
ENV GCE_ZONE=""
22-
ENV GCE_INSTANCE=""
23-
ENV LIBOPS_KEEP_ONLINE=""
16+
FROM ghcr.io/libops/go1.25:main@sha256:f43c9b34f888d2ac53e87c8e061554f826b8eb580863d7b21fd787b6f0378f8f
2417

25-
EXPOSE 8808
18+
COPY --from=builder /app/binary /app/binary
2619

27-
CMD ["/app/lightsout"]
20+
ENV \
21+
PORT=8808 \
22+
INACTIVITY_TIMEOUT=90 \
23+
LOG_LEVEL=INFO \
24+
GCP_PROJECT= \
25+
GCP_ZONE= \
26+
GCP_INSTANCE_NAME= \
27+
LIBOPS_KEEP_ONLINE=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/libops/lightsout
22

3-
go 1.25.0
3+
go 1.25.3

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ func loadConfig() *Config {
6767
Port: getEnv("PORT", "8808"),
6868
InactivityTimeout: getDurationEnv("INACTIVITY_TIMEOUT", 90) * time.Second,
6969
LogLevel: getEnv("LOG_LEVEL", "INFO"),
70-
GoogleProjectID: getEnv("GOOGLE_PROJECT_ID", ""),
71-
GCEZone: getEnv("GCE_ZONE", ""),
72-
GCEInstance: getEnv("GCE_INSTANCE", ""),
70+
GoogleProjectID: getEnv("GCP_PROJECT", ""),
71+
GCEZone: getEnv("GCP_ZONE", ""),
72+
GCEInstance: getEnv("GCP_INSTANCE_NAME", ""),
7373
LibOpsKeepOnline: getEnv("LIBOPS_KEEP_ONLINE", ""),
7474
}
7575
}

0 commit comments

Comments
 (0)