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/ charts/databunker/charts/
terraform.tfstate terraform.tfstate
terraform.tfstate.backup terraform.tfstate.backup
.DS_Store .DS_Store
databunker
databunker.db* databunker.db*
databunker.yaml databunker.yaml
bql.db bql.db

View File

@@ -1,28 +1,20 @@
# Building Databunker # Building Databunker
## Build for release Use the folllowing command
```
./release.sh
```
It will generate **databunker** executable. HTML files are built inside executable.
## Debug version
``` ```
./build.sh ./build.sh
``` ```
It will generate **databunker** executable that can be run on the same box. It will generate **databunker** executable. HTML files are built inside executable.
Web UI files will be fetched from ui/ directory.
## Build container ## Build container
It will generate "securitybunker/databunker" container and save it locally. 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 ## Push container
@@ -31,7 +23,8 @@ docker build -t securitybunker/databunker:latest .
``` ```
docker login 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 # STEP 1 build executable binary
############################ ############################
ARG VERSION
FROM golang:alpine AS builder 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 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/ WORKDIR $GOPATH/src/securitybunker/databunker/src/
@@ -12,7 +13,7 @@ COPY . $GOPATH/src/securitybunker/databunker/
# Using go get. # Using go get.
RUN go get -d -v && \ RUN go get -d -v && \
packr && \ packr && \
go build -o /go/bin/databunker && \ go build -ldflags="-s -w -X main.version=${VERSION}" -o /go/bin/databunker && \
packr clean packr clean
############################ ############################
# STEP 2 build a small image # 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 cd src
go build -v -o ../databunker 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 .. 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" yaml "gopkg.in/yaml.v2"
) )
var version string
type dbcon struct { type dbcon struct {
store storage.BackendDB store storage.BackendDB
masterKey []byte masterKey []byte
@@ -338,7 +340,7 @@ func readConfFile(cfg *Config, filepath *string) error {
confFile = *filepath confFile = *filepath
} }
} }
fmt.Printf("Databunker configuration file is: %s\n", confFile) fmt.Printf("Databunker configuration file: %s\n", confFile)
f, err := os.Open(confFile) f, err := os.Open(confFile)
if err != nil { if err != nil {
return err return err
@@ -580,8 +582,14 @@ func main() {
dbPtr := flag.String("db", "databunker", "Specify database name/file") dbPtr := flag.String("db", "databunker", "Specify database name/file")
confPtr := flag.String("conf", "", "Configuration file name to use") 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.") 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() flag.Parse()
if *versionPtr {
fmt.Printf("Databunker version: %s\n", version)
os.Exit(0)
}
var cfg Config var cfg Config
readEnv(&cfg) readEnv(&cfg)
readConfFile(&cfg, confPtr) readConfFile(&cfg, confPtr)

1
version.txt Normal file
View File

@@ -0,0 +1 @@
0.8.2