Fix #224
This commit is contained in:
2
.github/workflows/buildx-branch.yml
vendored
2
.github/workflows/buildx-branch.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
|||||||
--progress plain \
|
--progress plain \
|
||||||
--platform=linux/amd64 \
|
--platform=linux/amd64 \
|
||||||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
||||||
--build-arg VCS_REF=`git rev-parse --short HEAD` \
|
--build-arg COMMIT=`git rev-parse --short HEAD` \
|
||||||
--build-arg VERSION=${GITHUB_REF##*/} \
|
--build-arg VERSION=${GITHUB_REF##*/} \
|
||||||
-t qmcgaw/private-internet-access:${GITHUB_REF##*/} \
|
-t qmcgaw/private-internet-access:${GITHUB_REF##*/} \
|
||||||
--push \
|
--push \
|
||||||
|
|||||||
2
.github/workflows/buildx-latest.yml
vendored
2
.github/workflows/buildx-latest.yml
vendored
@@ -39,7 +39,7 @@ jobs:
|
|||||||
--progress plain \
|
--progress plain \
|
||||||
--platform=linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6 \
|
--platform=linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6 \
|
||||||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
||||||
--build-arg VCS_REF=`git rev-parse --short HEAD` \
|
--build-arg COMMIT=`git rev-parse --short HEAD` \
|
||||||
--build-arg VERSION=latest \
|
--build-arg VERSION=latest \
|
||||||
-t qmcgaw/private-internet-access:latest \
|
-t qmcgaw/private-internet-access:latest \
|
||||||
--push \
|
--push \
|
||||||
|
|||||||
2
.github/workflows/buildx-release.yml
vendored
2
.github/workflows/buildx-release.yml
vendored
@@ -39,7 +39,7 @@ jobs:
|
|||||||
--progress plain \
|
--progress plain \
|
||||||
--platform=linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6 \
|
--platform=linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6 \
|
||||||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
||||||
--build-arg VCS_REF=`git rev-parse --short HEAD` \
|
--build-arg COMMIT=`git rev-parse --short HEAD` \
|
||||||
--build-arg VERSION=${GITHUB_REF##*/} \
|
--build-arg VERSION=${GITHUB_REF##*/} \
|
||||||
-t qmcgaw/private-internet-access:${GITHUB_REF##*/} \
|
-t qmcgaw/private-internet-access:${GITHUB_REF##*/} \
|
||||||
--push \
|
--push \
|
||||||
|
|||||||
20
Dockerfile
20
Dockerfile
@@ -10,24 +10,28 @@ WORKDIR /tmp/gobuild
|
|||||||
COPY .golangci.yml .
|
COPY .golangci.yml .
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download 2>&1
|
RUN go mod download 2>&1
|
||||||
|
ARG VERSION=unknown
|
||||||
|
ARG BUILD_DATE="an unknown date"
|
||||||
|
ARG COMMIT=unknown
|
||||||
COPY cmd/gluetun/main.go .
|
COPY cmd/gluetun/main.go .
|
||||||
COPY internal/ ./internal/
|
COPY internal/ ./internal/
|
||||||
RUN go test ./...
|
RUN go test ./...
|
||||||
RUN golangci-lint run --timeout=10m
|
RUN golangci-lint run --timeout=10m
|
||||||
RUN go build -trimpath -ldflags="-s -w" -o entrypoint main.go
|
RUN go build -trimpath -ldflags="-s -w \
|
||||||
|
-X 'main.version=$VERSION' \
|
||||||
|
-X 'main.buildDate=$BUILD_DATE' \
|
||||||
|
-X 'main.commit=$COMMIT' \
|
||||||
|
" -o entrypoint main.go
|
||||||
|
|
||||||
FROM alpine:${ALPINE_VERSION}
|
FROM alpine:${ALPINE_VERSION}
|
||||||
ARG VERSION
|
ARG VERSION=unknown
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE="an unknown date"
|
||||||
ARG VCS_REF
|
ARG COMMIT=unknown
|
||||||
ENV VERSION=$VERSION \
|
|
||||||
BUILD_DATE=$BUILD_DATE \
|
|
||||||
VCS_REF=$VCS_REF
|
|
||||||
LABEL \
|
LABEL \
|
||||||
org.opencontainers.image.authors="quentin.mcgaw@gmail.com" \
|
org.opencontainers.image.authors="quentin.mcgaw@gmail.com" \
|
||||||
org.opencontainers.image.created=$BUILD_DATE \
|
org.opencontainers.image.created=$BUILD_DATE \
|
||||||
org.opencontainers.image.version=$VERSION \
|
org.opencontainers.image.version=$VERSION \
|
||||||
org.opencontainers.image.revision=$VCS_REF \
|
org.opencontainers.image.revision=$COMMIT \
|
||||||
org.opencontainers.image.url="https://github.com/qdm12/gluetun" \
|
org.opencontainers.image.url="https://github.com/qdm12/gluetun" \
|
||||||
org.opencontainers.image.documentation="https://github.com/qdm12/gluetun" \
|
org.opencontainers.image.documentation="https://github.com/qdm12/gluetun" \
|
||||||
org.opencontainers.image.source="https://github.com/qdm12/gluetun" \
|
org.opencontainers.image.source="https://github.com/qdm12/gluetun" \
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ import (
|
|||||||
"github.com/qdm12/golibs/network"
|
"github.com/qdm12/golibs/network"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:gochecknoglobals
|
||||||
|
var (
|
||||||
|
version = "unknown"
|
||||||
|
commit = "unknown"
|
||||||
|
buildDate = "an unknown date"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
os.Exit(_main(ctx, os.Args))
|
os.Exit(_main(ctx, os.Args))
|
||||||
@@ -73,10 +80,7 @@ func _main(background context.Context, args []string) int { //nolint:gocognit,go
|
|||||||
streamMerger := command.NewStreamMerger()
|
streamMerger := command.NewStreamMerger()
|
||||||
|
|
||||||
paramsReader := params.NewReader(logger, fileManager)
|
paramsReader := params.NewReader(logger, fileManager)
|
||||||
fmt.Println(gluetunLogging.Splash(
|
fmt.Println(gluetunLogging.Splash(version, commit, buildDate))
|
||||||
paramsReader.GetVersion(),
|
|
||||||
paramsReader.GetVcsRef(),
|
|
||||||
paramsReader.GetBuildDate()))
|
|
||||||
|
|
||||||
printVersions(ctx, logger, map[string]func(ctx context.Context) (string, error){
|
printVersions(ctx, logger, map[string]func(ctx context.Context) (string, error){
|
||||||
"OpenVPN": ovpnConf.Version,
|
"OpenVPN": ovpnConf.Version,
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Splash returns the welcome spash message
|
// Splash returns the welcome spash message
|
||||||
func Splash(version, vcsRef, buildDate string) string {
|
func Splash(version, commit, buildDate string) string {
|
||||||
lines := title()
|
lines := title()
|
||||||
lines = append(lines, "")
|
lines = append(lines, "")
|
||||||
lines = append(lines, fmt.Sprintf("Running version %s built on %s (commit %s)", version, buildDate, vcsRef))
|
lines = append(lines, fmt.Sprintf("Running version %s built on %s (commit %s)", version, buildDate, commit))
|
||||||
lines = append(lines, "")
|
lines = append(lines, "")
|
||||||
lines = append(lines, announcement()...)
|
lines = append(lines, announcement()...)
|
||||||
lines = append(lines, "")
|
lines = append(lines, "")
|
||||||
|
|||||||
@@ -108,11 +108,6 @@ type Reader interface {
|
|||||||
|
|
||||||
// Public IP getters
|
// Public IP getters
|
||||||
GetPublicIPPeriod() (period time.Duration, err error)
|
GetPublicIPPeriod() (period time.Duration, err error)
|
||||||
|
|
||||||
// Version getters
|
|
||||||
GetVersion() string
|
|
||||||
GetBuildDate() string
|
|
||||||
GetVcsRef() string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type reader struct {
|
type reader struct {
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package params
|
|
||||||
|
|
||||||
import (
|
|
||||||
libparams "github.com/qdm12/golibs/params"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (r *reader) GetVersion() string {
|
|
||||||
version, _ := r.envParams.GetEnv("VERSION", libparams.Default("?"), libparams.CaseSensitiveValue())
|
|
||||||
return version
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *reader) GetBuildDate() string {
|
|
||||||
buildDate, _ := r.envParams.GetEnv("BUILD_DATE", libparams.Default("?"), libparams.CaseSensitiveValue())
|
|
||||||
return buildDate
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *reader) GetVcsRef() string {
|
|
||||||
buildDate, _ := r.envParams.GetEnv("VCS_REF", libparams.Default("?"), libparams.CaseSensitiveValue())
|
|
||||||
return buildDate
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user