File tree 3 files changed +10
-1
lines changed
3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 22
22
--frontend=dockerfile.v0 \
23
23
--local context=. \
24
24
--local dockerfile=. \
25
+ --opt build-arg:VERSION=$1 \
26
+ --opt build-arg:COMMIT=$CI_COMMIT_SHA \
25
27
--output type=image,name=$CI_REGISTRY_IMAGE:$1,push=true
26
28
}
27
29
Original file line number Diff line number Diff line change @@ -17,8 +17,10 @@ RUN go mod download
17
17
# Copy the source code into the container
18
18
COPY . .
19
19
20
+ ARG VERSION=dev
21
+
20
22
# Build the Go application
21
- RUN go build -o automirror .
23
+ RUN go build --ldflags "-X 'main.Version=$VERSION' -X 'main.Commit=$COMMIT'" - o automirror .
22
24
23
25
# Use a minimal base image to run the app
24
26
FROM alpine:3.21
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ import (
22
22
"gopkg.in/yaml.v3"
23
23
)
24
24
25
+ var Version string
26
+ var Commit string
27
+
25
28
type MirrorDefaults struct {
26
29
Except []string `json:"except,omitempty"`
27
30
Only []string `json:"only,omitempty"`
@@ -589,6 +592,8 @@ func main() {
589
592
return
590
593
}
591
594
595
+ ll .Info ("Starting automirror v%s (%s)" , Version , Commit )
596
+
592
597
err := loadEnv ()
593
598
if err != nil {
594
599
fmt .Println ("Error loading environment variables:" , err )
You can’t perform that action at this time.
0 commit comments