sync with 4a19a3798a196ff4b9ec4514c983ffc0ad42f49b

This commit is contained in:
AnimeBytes 2020-04-23 02:05:14 +02:00
parent 2ae210f408
commit e800647dd5
2 changed files with 11 additions and 15 deletions

11
.gitignore vendored
View file

@ -20,14 +20,15 @@ _cgo_export.*
_testmain.go
# Build artifacts
.bin
chihaya.cpu
coverage.out
/bencode
/cc
/chihaya
*.exe
*.out
# Local files
config.json
*-cache.gob
*-cache.json
*-cache.*
events
# IDE

View file

@ -1,13 +1,9 @@
FROM golang:1.14-alpine AS builder
WORKDIR /app
WORKDIR /src
ARG CGO_ENABLED=0
ARG GOOS=linux
ARG GOARCH=amd64
ARG GIT_SHA=local
RUN apk add binutils
@ -20,15 +16,14 @@ RUN go mod download
COPY . .
RUN export VERSION=$(cat ./VERSION) && export DATE=$(date -Iseconds) && \
echo $VERSION-$GIT_SHA@$DATE && \
go build -o .bin/ -v -ldflags="-X 'main.GitSHA=$GIT_SHA' -X 'main.BuildDate=$DATE' -X 'main.BuildVersion=$VERSION'" ./cmd/... && \
strip .bin/*
echo $VERSION-$GIT_SHA@$DATE && mkdir /out && \
go build -o /out -v -ldflags="-X 'main.GitSHA=$GIT_SHA' -X 'main.BuildDate=$DATE' -X 'main.BuildVersion=$VERSION'" ./cmd/... && \
strip /out/*
FROM scratch AS release
WORKDIR /app
COPY --from=builder /app/.bin /
COPY --from=builder /out /
USER 1000:1000