-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
41 lines (30 loc) · 948 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
FROM golang:1.17-alpine AS build-env
ARG VERSION
ARG COMMIT_HASH
ARG CI
ENV GOFLAGS="-mod=vendor"
ENV CGO_ENABLED=0
WORKDIR /build
ADD . /build
RUN apk add --update --no-cache build-base make git libc-dev
RUN \
if [ -z "$CI" ] ; then \
echo "runs outside of CI"; \
VERSION=$(git rev-parse --abbrev-ref HEAD); \
COMMIT_HASH=$(git rev-parse --short HEAD); \
fi && \
DATE=$(date +%FT%T%z); \
LDFLAGS="-s -w -X main.Version=${VERSION} -X main.CommitHash=${COMMIT_HASH} -X main.CompileDate=${DATE}"; \
go build -o /go/bin/pad -ldflags "${LDFLAGS}" && \
/go/bin/pad --version
FROM alpine:3.15
WORKDIR /app
COPY --from=build-env /go/bin/pad /app
COPY --from=build-env /build/static/ /app/static/
COPY --from=build-env /build/templates/ /app/templates/
ENV PAD_HOST "0.0.0.0"
ENV PAD_PORT "8080"
ENV BOLT_PATH "/app/db"
ENV PAD_SECRET "true_random_salt"
EXPOSE ${PAD_PORT}
ENTRYPOINT ["/app/pad"]