add version information

This commit is contained in:
yuli
2024-04-27 23:38:18 +03:00
parent 7b5d823634
commit 33c97deac4
7 changed files with 46 additions and 29 deletions

2
.gitignore vendored
View File

@@ -1,7 +1,9 @@
src/a_main-packr.go
charts/databunker/charts/
terraform.tfstate
terraform.tfstate.backup
.DS_Store
databunker
databunker.db*
databunker.yaml
bql.db

View File

@@ -1,28 +1,20 @@
# Building Databunker
## Build for release
```
./release.sh
```
It will generate **databunker** executable. HTML files are built inside executable.
## Debug version
Use the folllowing command
```
./build.sh
```
It will generate **databunker** executable that can be run on the same box.
Web UI files will be fetched from ui/ directory.
It will generate **databunker** executable. HTML files are built inside executable.
## Build container
It will generate "securitybunker/databunker" container and save it locally.
```
docker build -t securitybunker/databunker:latest .
VERSION=$(cat ./version.txt)
docker build -t securitybunker/databunker:$VERSION --build-arg VERSION=$VERSION .
```
## Push container
@@ -31,7 +23,8 @@ docker build -t securitybunker/databunker:latest .
```
docker login
docker push securitybunker/databunker:latest
VERSION=$(cat ./version.txt)
docker push securitybunker/databunker:$VERSION
```

View File

@@ -1,6 +1,7 @@
############################
# STEP 1 build executable binary
############################
ARG VERSION
FROM golang:alpine AS builder
RUN apk update && apk add --no-cache git gcc libc-dev openssl && go install github.com/gobuffalo/packr/packr@latest
WORKDIR $GOPATH/src/securitybunker/databunker/src/
@@ -12,7 +13,7 @@ COPY . $GOPATH/src/securitybunker/databunker/
# Using go get.
RUN go get -d -v && \
packr && \
go build -o /go/bin/databunker && \
go build -ldflags="-s -w -X main.version=${VERSION}" -o /go/bin/databunker && \
packr clean
############################
# STEP 2 build a small image

View File

@@ -1,4 +1,27 @@
# build without debug
#!/bin/bash
set -x
VERSION=$(cat ./version.txt)
if [[ ! -x "~/go/bin/packr" && ! -x "packr" ]]; then
go install github.com/gobuffalo/packr/packr@latest
fi
cd src
go build -v -o ../databunker
cd ..
go get -d -v
if [ -x "~/go/bin/packr" ]; then
~/go/bin/packr
elif [ -x "packr" ]; then
packr
fi
go build -v -ldflags="-s -w -X main.version=${VERSION}" -o ../databunker
if [ -x "~/go/bin/packr" ]; then
~/go/bin/packr clean
elif [ -x "packr" ]; then
packr clean
fi
cd ..

View File

@@ -1,11 +0,0 @@
# build without debug
packr
go build -ldflags "-w" -o databunker ./src/bunker.go ./src/qldb.go ./src/audit_db.go ./src/audit_api.go \
./src/utils.go ./src/cryptor.go \
./src/sms.go ./src/email.go \
./src/users_db.go ./src/users_api.go \
./src/userapps_db.go ./src/userapps_api.go \
./src/sessions_db.go ./src/sessions_api.go \
./src/consent_db.go ./src/consent_api.go \
./src/xtokens_db.go ./src/xtokens_api.go ./src/a_main-packr.go
packr clean

View File

@@ -33,6 +33,8 @@ import (
yaml "gopkg.in/yaml.v2"
)
var version string
type dbcon struct {
store storage.BackendDB
masterKey []byte
@@ -338,7 +340,7 @@ func readConfFile(cfg *Config, filepath *string) error {
confFile = *filepath
}
}
fmt.Printf("Databunker configuration file is: %s\n", confFile)
fmt.Printf("Databunker configuration file: %s\n", confFile)
f, err := os.Open(confFile)
if err != nil {
return err
@@ -580,8 +582,14 @@ func main() {
dbPtr := flag.String("db", "databunker", "Specify database name/file")
confPtr := flag.String("conf", "", "Configuration file name to use")
rootTokenKeyPtr := flag.String("roottoken", "", "Specify custom root token to use during database init. It must be in UUID format.")
versionPtr := flag.Bool("version", false, "Print version information")
flag.Parse()
if *versionPtr {
fmt.Printf("Databunker version: %s\n", version)
os.Exit(0)
}
var cfg Config
readEnv(&cfg)
readConfFile(&cfg, confPtr)

1
version.txt Normal file
View File

@@ -0,0 +1 @@
0.8.2