Skip to content

Commit

Permalink
fixes to dockerfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
schwarzlichtbezirk committed Feb 17, 2024
1 parent 4982a81 commit 8af06a1
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 42 deletions.
22 changes: 15 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##

# Use image with golang last version as builder.
FROM golang:1.20-bullseye AS build
FROM golang:1.22-bullseye AS build

# See https://stackoverflow.com/questions/64462922/docker-multi-stage-build-go-image-x509-certificate-signed-by-unknown-authorit
RUN apt-get update && apt-get install -y ca-certificates openssl
Expand All @@ -24,13 +24,17 @@ RUN openssl s_client -showcerts -connect proxy.golang.org:443 </dev/null 2>/dev/
RUN update-ca-certificates

# Make project root folder as current dir.
WORKDIR $GOPATH/src/github.com/schwarzlichtbezirk/hms
WORKDIR /go/src/github.com/schwarzlichtbezirk/hms
# Copy only go.mod and go.sum to prevent downloads all dependencies again on any code changes.
COPY go.* .
COPY go.mod go.sum ./
# Download all dependencies pointed at go.mod file.
RUN go mod download
# Copy all files and subfolders in current state as is.
COPY . .
COPY ./cmd ./cmd
COPY ./config ./config
COPY ./server ./server
COPY ./confdata /go/bin/config

# Set executable rights to all shell-scripts.
RUN chmod +x task/*.sh
Expand All @@ -43,7 +47,11 @@ RUN task/wpk-app.sh
RUN task/wpk-edge.sh

# Compile project for Linux amd64.
RUN task/build-linux.x64.sh
RUN \
buildvers=$(git describe --tags) && \
buildtime=$(go run ./task/timenow.go) && \
go env -w GOOS=linux GOARCH=amd64 CGO_ENABLED=1 && \
go build -o /go/bin/hms_linux_x64 -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=$buildvers' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=$buildtime'" ./

##
## Deploy stage
Expand All @@ -55,11 +63,11 @@ FROM scratch
# Copy compiled executable and packages to new image destination.
COPY --from=build /go/bin/hms* /go/bin/
# Copy configuration files.
COPY --from=build /go/bin/config/* /go/bin/config/
COPY --from=build /go/bin/config /go/bin/config

# Open REST listen port.
EXPOSE 80 8080
EXPOSE 80 8804

# Run application with full path representation.
# Without shell to get signal for graceful shutdown.
ENTRYPOINT ["/go/bin/hms.linux.x64.exe"]
ENTRYPOINT ["/go/bin/hms_linux_x64", "web"]
2 changes: 1 addition & 1 deletion frontend/build/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<script src="/plug/popper.min.js?2.11.8"></script>
<script src="/plug/bootstrap.min.js?5.3.2"></script>
<!-- Vue.js release version -->
<script src="/plug/vue.global.prod.js?3.3.8"></script>
<script src="/plug/vue.global.prod.js?3.4.19"></script>
<!-- application bundle: leaflet, sha256 -->
<script src="/relm/app.bundle.js?0.10.0"></script>
<!-- page bundle -->
Expand Down
2 changes: 1 addition & 1 deletion frontend/build/stat.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<script src="/plug/popper.min.js?2.11.8"></script>
<script src="/plug/bootstrap.min.js?5.3.2"></script>
<!-- Vue.js release version -->
<script src="/plug/vue.global.prod.js?3.3.8"></script>
<script src="/plug/vue.global.prod.js?3.4.19"></script>
<!-- page bundle -->
<script src="/relm/stat.bundle.js?0.10.1"></script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion frontend/devmode/devmode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This file is included only for developer mode linkage

const buildvers = "0.11.0";
const builddate = "2023.11.15";
const builddate = "2024.02.17";
console.info("version: %s, builton: %s", buildvers, builddate);
console.info("starts in developer mode");

Expand Down
4 changes: 2 additions & 2 deletions frontend/devmode/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@
<script src="/plug/popper.min.js?2.11.8"></script>
<script src="/plug/bootstrap.min.js?5.3.2"></script>
<!-- Vue.js development version, includes helpful console warnings -->
<script src="/plug/vue.global.js?3.3.8"></script>
<script src="/plug/vue.global.js?3.4.19"></script>
<!-- Leaflet API -->
<script src="/plug/leaflet.js?1.9.4"></script>
<script src="/plug/leaflet.markercluster.js?1.5.3"></script>
<!-- miscellaneous -->
<script src="/plug/sha256.min.js?0.9.0"></script>
<script src="/plug/sha256.min.js?0.11.0"></script>

<!-- common functionality used in all components -->
<script src="/devm/devmode.js?0.11.0"></script>
Expand Down
4 changes: 2 additions & 2 deletions frontend/devmode/relmode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

// This file is included for release mode linkage

const buildvers = "0.10.2";
const builddate = "2023.05.10";
const buildvers = "0.11.0";
const builddate = "2024.02.17";
const devmode = false;

const traceajax = () => undefined;
Expand Down
2 changes: 1 addition & 1 deletion frontend/devmode/stat.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<script src="/plug/popper.min.js?2.11.8"></script>
<script src="/plug/bootstrap.min.js?5.3.2"></script>
<!-- Vue.js development version, includes helpful console warnings -->
<script src="/plug/vue.global.js?3.3.8"></script>
<script src="/plug/vue.global.js?3.4.19"></script>

<!-- common functionality used in all components -->
<script src="/devm/devmode.js?0.10.3"></script>
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ require (
github.com/ugorji/go/codec v1.2.12 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo=
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE=
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
Expand Down Expand Up @@ -261,8 +261,8 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
Expand Down
2 changes: 1 addition & 1 deletion task/build-linux-x64.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ for /F "tokens=*" %%g in ('git describe --tags') do (set buildvers=%%g)
for /F "tokens=*" %%g in ('go run %~dp0/timenow.go') do (set buildtime=%%g)

go env -w GOOS=linux GOARCH=amd64 CGO_ENABLED=1
go build -o %GOPATH%/bin/hms_linux_x64 -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=%buildvers%' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=%buildtime%'" %wd%
go build -o "%GOPATH%/bin/hms_linux_x64" -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=%buildvers%' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=%buildtime%'" %wd%
6 changes: 3 additions & 3 deletions task/build-linux-x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
wd=$(realpath -s "$(dirname "$0")/..")

mkdir -p "$GOPATH/bin/cache"
cp -ruv "$wd/confdata" "$GOPATH/bin/config"
cp -ruv "$wd/confdata/"* "$GOPATH/bin/config"

buildvers=$(git describe --tags)
buildtime=$(go run "$(dirname "$0")/timenow.go") # $(date -u +'%FT%TZ')
buildtime=$(go run "$wd/task/timenow.go") # $(date -u +'%FT%TZ')

go env -w GOOS=linux GOARCH=amd64 CGO_ENABLED=1
go build -o $GOPATH/bin/hms_linux_x64 -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=$buildvers' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=$buildtime'" $wd
go build -o "$GOPATH/bin/hms_linux_x64" -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=$buildvers' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=$buildtime'" $wd
2 changes: 1 addition & 1 deletion task/build-win-x64.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ for /F "tokens=*" %%g in ('git describe --tags') do (set buildvers=%%g)
for /F "tokens=*" %%g in ('go run %~dp0/timenow.go') do (set buildtime=%%g)

go env -w GOOS=windows GOARCH=amd64 CGO_ENABLED=1
go build -o %GOPATH%/bin/hms_win_x64.exe -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=%buildvers%' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=%buildtime%'" %wd%
go build -o "%GOPATH%/bin/hms_win_x64.exe" -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=%buildvers%' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=%buildtime%'" %wd%
6 changes: 3 additions & 3 deletions task/build-win-x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
wd=$(realpath -s "$(dirname "$0")/..")

mkdir -p "$GOPATH/bin/cache"
cp -ruv "$wd/confdata" "$GOPATH/bin/config"
cp -ruv "$wd/confdata/"* "$GOPATH/bin/config"

buildvers=$(git describe --tags)
buildtime=$(go run "$(dirname "$0")/timenow.go") # $(date -u +'%FT%TZ')
buildtime=$(go run "$wd/task/timenow.go") # $(date -u +'%FT%TZ')

go env -w GOOS=windows GOARCH=amd64 CGO_ENABLED=1
go build -o $GOPATH/bin/hms_win_x64.exe -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=$buildvers' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=$buildtime'" $wd
go build -o "$GOPATH/bin/hms_win_x64.exe" -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=$buildvers' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=$buildtime'" $wd
2 changes: 1 addition & 1 deletion task/build-win-x86.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ for /F "tokens=*" %%g in ('git describe --tags') do (set buildvers=%%g)
for /F "tokens=*" %%g in ('go run %~dp0/timenow.go') do (set buildtime=%%g)

go env -w GOOS=windows GOARCH=386 CGO_ENABLED=1
go build -o %GOPATH%/bin/hms_win_x86.exe -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=%buildvers%' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=%buildtime%'" %wd%
go build -o "%GOPATH%/bin/hms_win_x86.exe" -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=%buildvers%' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=%buildtime%'" %wd%
6 changes: 3 additions & 3 deletions task/build-win-x86.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
wd=$(realpath -s "$(dirname "$0")/..")

mkdir -p "$GOPATH/bin/cache"
cp -ruv "$wd/confdata" "$GOPATH/bin/config"
cp -ruv "$wd/confdata/"* "$GOPATH/bin/config"

buildvers=$(git describe --tags)
buildtime=$(go run "$(dirname "$0")/timenow.go") # $(date -u +'%FT%TZ')
buildtime=$(go run "$wd/task/timenow.go") # $(date -u +'%FT%TZ')

go env -w GOOS=windows GOARCH=386 CGO_ENABLED=1
go build -o $GOPATH/bin/hms_win_x86.exe -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=$buildvers' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=$buildtime'" $wd
go build -o "$GOPATH/bin/hms_win_x86.exe" -v -ldflags="-linkmode external -extldflags -static -X 'github.com/schwarzlichtbezirk/hms/config.BuildVers=$buildvers' -X 'github.com/schwarzlichtbezirk/hms/config.BuildTime=$buildtime'" $wd
8 changes: 4 additions & 4 deletions task/deploy-plugins.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ set vers=2.11.8
curl https://cdnjs.cloudflare.com/ajax/libs/popper.js/%vers%/umd/popper.min.js --output %plugdir%/popper.min.js
curl https://cdnjs.cloudflare.com/ajax/libs/popper.js/%vers%/umd/popper.min.js.map --output %plugdir%/popper.min.js.map

rem Vue 3.3.8
rem Vue 3.4.19
rem https://cdnjs.com/libraries/vue
rem https://unpkg.com/vue@next
set vers=3.3.8
set vers=3.4.19
curl https://unpkg.com/vue@%vers%/dist/vue.global.js --output %plugdir%/vue.global.js
curl https://unpkg.com/vue@%vers%/dist/vue.global.prod.js --output %plugdir%/vue.global.prod.js

Expand All @@ -44,9 +44,9 @@ curl https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/%vers%/leaflet
curl https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/%vers%/MarkerCluster.css --output %plugdir%/MarkerCluster.css
curl https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/%vers%/MarkerCluster.Default.css --output %plugdir%/MarkerCluster.Default.css

rem sha256 0.9.0
rem sha256 0.11.0
rem https://cdnjs.com/libraries/js-sha256
set vers=0.9.0
set vers=0.11.0
curl https://cdnjs.cloudflare.com/ajax/libs/js-sha256/%vers%/sha256.min.js --output %plugdir%/sha256.min.js

rem normalize 8.0.1
Expand Down
8 changes: 4 additions & 4 deletions task/deploy-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ vers="2.11.8"
curl https://cdnjs.cloudflare.com/ajax/libs/popper.js/$vers/umd/popper.min.js --output $plugdir/popper.min.js
curl https://cdnjs.cloudflare.com/ajax/libs/popper.js/$vers/umd/popper.min.js.map --output $plugdir/popper.min.js.map

# Vue 3.3.8
# Vue 3.4.19
# https://cdnjs.com/libraries/vue
# https://unpkg.com/vue@next
vers="3.3.8"
vers="3.4.19"
curl https://unpkg.com/vue@$vers/dist/vue.global.js --output $plugdir/vue.global.js
curl https://unpkg.com/vue@$vers/dist/vue.global.prod.js --output $plugdir/vue.global.prod.js

Expand All @@ -45,9 +45,9 @@ curl https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/$vers/leaflet.
curl https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/$vers/MarkerCluster.css --output $plugdir/MarkerCluster.css
curl https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/$vers/MarkerCluster.Default.css --output $plugdir/MarkerCluster.Default.css

# sha256 0.9.0
# sha256 0.11.0
# https://cdnjs.com/libraries/js-sha256
vers="0.9.0"
vers="0.11.0"
curl https://cdnjs.cloudflare.com/ajax/libs/js-sha256/$vers/sha256.min.js --output $plugdir/sha256.min.js

# normalize 8.0.1
Expand Down

0 comments on commit 8af06a1

Please sign in to comment.