Skip to content

Commit

Permalink
Just better
Browse files Browse the repository at this point in the history
  • Loading branch information
COMTOP1 committed Oct 9, 2024
1 parent d9b6a9b commit 24976b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ COPY *.go ./

RUN apk update && apk upgrade

RUN echo $COMP_SITE_CERT_PEM | awk '{gsub(/\\n/,"\n")}1' > cert.pem
RUN echo $COMP_SITE_KEY_PEM | awk '{gsub(/\\n/,"\n")}1' > key.pem

# Set build variables
RUN echo -n "-X 'main.Version=$COMP_SITE_VERSION_ARG" > ./ldflags && \
tr -d \\n < ./ldflags > ./temp && mv ./temp ./ldflags && \
echo -n "' -X 'main.Commit=$COMP_SITE_COMMIT_ARG" >> ./ldflags && \
tr -d \\n < ./ldflags > ./temp && mv ./temp ./ldflags && \
echo -n "' -X 'main.cert=$COMP_SITE_CERT_PEM" >> ./ldflags && \
tr -d \\n < ./ldflags > ./temp && mv ./temp ./ldflags && \
echo -n "' -X 'main.key=$COMP_SITE_KEY_PEM" >> ./ldflags && \
tr -d \\n < ./ldflags > ./temp && mv ./temp ./ldflags && \
echo -n "'" >> ./ldflags

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$(cat ./ldflags)" -o /bin/computing
Expand Down
17 changes: 10 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ import (
//go:embed public/*
var embeddedFiles embed.FS

//go:embed cert.pem

Check failure on line 14 in main.go

View workflow job for this annotation

GitHub Actions / lint

pattern cert.pem: no matching files found (typecheck)
var cert []byte

//go:embed key.pem
var key []byte

var (
Commit = "unknown"
Version = "unknown"

cert = ""
key = ""
)

func main() {
if cert == "" || key == "" {
log.Fatalf("missing required cert and key")
if len(cert) == 0 || len(key) == 0 {
log.Fatalf("missing required cert or key")
}

link1, err := link.New()
Expand All @@ -41,8 +44,8 @@ func main() {
Team: team1,
Commit: Commit,
Version: Version,
cert: []byte(cert),
key: []byte(key),
cert: cert,
key: key,
})

log.Printf("YSTV Computing site: %s, commit: %s, version: %s\n", addr, Commit, Version)
Expand Down

0 comments on commit 24976b0

Please sign in to comment.