mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-10-30 17:37:50 +00:00
update version generation code
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
**/.git
|
|
||||||
databunker.db*
|
databunker.db*
|
||||||
databunker
|
databunker
|
||||||
Dockerfile
|
Dockerfile
|
||||||
./data
|
./data
|
||||||
.*
|
|
||||||
*.md
|
*.md
|
||||||
.env
|
.env
|
||||||
data/*
|
data/*
|
||||||
|
|||||||
2
BUILD.md
2
BUILD.md
@@ -14,7 +14,7 @@ To generate the ```securitybunker/databunker``` container, use the following com
|
|||||||
|
|
||||||
```
|
```
|
||||||
VERSION=$(cat ./version.txt)
|
VERSION=$(cat ./version.txt)
|
||||||
docker build -t securitybunker/databunker:$VERSION --build-arg VERSION=$VERSION .
|
docker build -t securitybunker/databunker:$VERSION .
|
||||||
```
|
```
|
||||||
|
|
||||||
## Pushing Container
|
## Pushing Container
|
||||||
|
|||||||
29
Dockerfile
29
Dockerfile
@@ -1,23 +1,18 @@
|
|||||||
############################
|
##############################
|
||||||
# STEP 1 build executable binary
|
# STEP 1 build executable file
|
||||||
############################
|
##############################
|
||||||
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
|
||||||
WORKDIR $GOPATH/src/securitybunker/databunker/src/
|
WORKDIR /go/src/securitybunker/databunker/src/
|
||||||
COPY src/go.mod ./deps
|
COPY src/go.mod ./deps
|
||||||
RUN cat ./deps | grep -v storage > ./go.mod && go mod download
|
RUN cat ./deps | grep -v storage > ./go.mod && go mod download
|
||||||
COPY . $GOPATH/src/securitybunker/databunker/
|
COPY . /go/src/securitybunker/databunker/
|
||||||
|
WORKDIR /go/src/securitybunker/databunker/
|
||||||
#RUN echo "tidy " && go get -u && go mod tidy && cat ./go.mod
|
#RUN echo "tidy " && go get -u && go mod tidy && cat ./go.mod
|
||||||
# Fetch dependencies.
|
RUN ./build.sh
|
||||||
# Using go get.
|
#################################
|
||||||
RUN go get -d -v && \
|
# STEP 2 create a small container
|
||||||
packr && \
|
#################################
|
||||||
go build -ldflags="-s -w -X main.version=${VERSION}" -o /go/bin/databunker && \
|
|
||||||
packr clean
|
|
||||||
############################
|
|
||||||
# STEP 2 build a small image
|
|
||||||
############################
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=builder /bin/sh /bin/busybox /usr/bin/openssl /bin/
|
COPY --from=builder /bin/sh /bin/busybox /usr/bin/openssl /bin/
|
||||||
COPY --from=builder /lib/ld* /lib/libssl.* /lib/libcrypto.* /lib/
|
COPY --from=builder /lib/ld* /lib/libssl.* /lib/libcrypto.* /lib/
|
||||||
@@ -36,7 +31,7 @@ RUN /bin/busybox mkdir -p /databunker/data && \
|
|||||||
addgroup -S appgroup && adduser --no-create-home -S appuser -G appgroup && \
|
addgroup -S appgroup && adduser --no-create-home -S appuser -G appgroup && \
|
||||||
chown appuser:appgroup /databunker/data
|
chown appuser:appgroup /databunker/data
|
||||||
USER appuser
|
USER appuser
|
||||||
COPY --from=builder /go/bin/databunker /go/src/securitybunker/databunker/run.sh /go/src/securitybunker/databunker/health-check.sh /databunker/bin/
|
COPY --from=builder /go/src/securitybunker/databunker/databunker /go/src/securitybunker/databunker/run.sh /go/src/securitybunker/databunker/health-check.sh /databunker/bin/
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
HEALTHCHECK --interval=5s --timeout=3s --start-period=33s --retries=3 CMD /databunker/bin/health-check.sh
|
HEALTHCHECK --interval=5s --timeout=3s --start-period=33s --retries=3 CMD /databunker/bin/health-check.sh
|
||||||
ENTRYPOINT ["/bin/sh", "/databunker/bin/run.sh"]
|
ENTRYPOINT ["/bin/sh", "/databunker/bin/run.sh"]
|
||||||
|
|||||||
24
build.sh
24
build.sh
@@ -1,27 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
VERSION=$(cat ./version.txt)
|
VERSION=$(cat ./version.txt)
|
||||||
|
HASH=$(git rev-parse --short=12 HEAD)
|
||||||
if [[ ! -x "~/go/bin/packr" && ! -x "packr" ]]; then
|
TIMESTAMP=$(date +%Y%m%d%H%M%S) # Current timestamp
|
||||||
go install github.com/gobuffalo/packr/packr@latest
|
FULL_VERSION=$VERSION-$TIMESTAMP-$HASH
|
||||||
fi
|
|
||||||
|
|
||||||
cd src
|
cd src
|
||||||
go get -d -v
|
go get -d -v
|
||||||
if [ -x "~/go/bin/packr" ]; then
|
go build -v -ldflags="-s -w -X main.version=$FULL_VERSION" -o ../databunker
|
||||||
~/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 ..
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
VERSION=$(cat ./version.txt)
|
VERSION=$(cat ./version.txt)
|
||||||
docker build -t securitybunker/databunker:$VERSION --build-arg VERSION=$VERSION .
|
docker build -t securitybunker/databunker:$VERSION .
|
||||||
docker tag securitybunker/databunker:$VERSION securitybunker/databunker:latest
|
docker tag securitybunker/databunker:$VERSION securitybunker/databunker:latest
|
||||||
docker-compose -f docker-compose-pgsql.yml down || true
|
docker-compose -f docker-compose-pgsql.yml down || true
|
||||||
docker-compose -f docker-compose-pgsql.yml up -d
|
docker-compose -f docker-compose-pgsql.yml up -d
|
||||||
|
|||||||
Reference in New Issue
Block a user