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