Skip to content

Commit 4077892

Browse files
authored
Merge pull request #23 from HilkopterBob/devel
Devel
2 parents 5c7f3a5 + 01140a9 commit 4077892

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

.github/workflows/build-docker-container.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: ci
1+
name: docker-build
22

33
on:
4-
push:
5-
branches: ["binary-release", "master", "devel"]
4+
release:
5+
types: [published]
66

77
jobs:
88
docker:
@@ -20,3 +20,5 @@ jobs:
2020
with:
2121
push: true
2222
tags: hilkopterbob/packagelock:latest
23+
build-args: |
24+
APP_VERSION=${{ github.event.release.tag_name }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: unstable-docker-build
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
docker:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Set up Docker Buildx
11+
uses: docker/setup-buildx-action@v3
12+
- name: Login to Docker Hub
13+
uses: docker/login-action@v3
14+
with:
15+
username: ${{ secrets.DOCKER_USERNAME }}
16+
password: ${{ secrets.DOCKER_TOKEN }}
17+
- name: Build and push
18+
uses: docker/build-push-action@v6
19+
with:
20+
push: true
21+
tags: hilkopterbob/packagelock:unstable-${{ github.head_ref || github.ref_name }}

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ RUN go mod download
1616

1717

1818
# Build
19-
20-
RUN CGO_ENABLED=0 GOOS=linux go build -o /packagelock
19+
ARG APP_VERSION="v0.1.0+hotfixes"
20+
RUN \
21+
CGO_ENABLED=0 GOOS=linux go build -ldflags "-X 'main.AppVersion=$APP_VERSION'" -o /packagelock
2122

2223
# Optional:
2324
# To bind to a TCP port, runtime parameters must be supplied to the docker command.

config/conf-init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type ConfigProvider interface {
2020
ReadConfig(in io.Reader) error
2121
AllSettings() map[string]any
2222
GetString(string string) string
23+
SetDefault(key string, value any)
2324
}
2425

2526
// TODO: How to test?

main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ import (
1515
"github.com/spf13/viper"
1616
)
1717

18-
// Data structs
18+
// Linker Injections
19+
// Version injection with Docker Build & ldflags
20+
// Do not modify, init or change in code!
21+
var AppVersion string
1922

2023
// TODO: support for multiple network adapters.
2124

2225
func main() {
2326
Config := config.StartViper(viper.New())
27+
28+
if AppVersion != "" {
29+
Config.SetDefault("general.app-version", AppVersion)
30+
}
31+
2432
fmt.Println(Config.AllSettings())
2533

2634
// Channel to signal the restart

0 commit comments

Comments
 (0)