forked from UBAutograding/leviathan
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
49 lines (35 loc) · 1.16 KB
/
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
42
43
44
45
46
47
48
49
FROM golang:1.24-alpine AS builder
# Build arguments
ARG VERSION=dev
ARG COMMIT_INFO=unknown
ARG BUILD_DATE=unknown
ARG BRANCH=unknown
# for sqlite
RUN apk update && apk add --no-cache gcc musl-dev
ENV CGO_ENABLED=1
WORKDIR /app
COPY src/go.mod .
COPY src/go.sum .
RUN go mod download
COPY ./src .
# arg substitution, do not put it higher than this for caching
# https://stackoverflow.com/questions/44438637/arg-substitution-in-run-command-not-working-for-dockerfile
ENV VERSION=${VERSION}
ENV COMMIT_INFO=${COMMIT_INFO}
ENV BUILD_DATE=${BUILD_DATE}
ENV BRANCH=${BRANCH}
# build optimized binary without debugging symbols
RUN go build -ldflags "-s -w \
-X github.com/makeopensource/leviathan/common.Version=${VERSION} \
-X github.com/makeopensource/leviathan/common.CommitInfo=${COMMIT_INFO} \
-X github.com/makeopensource/leviathan/common.BuildDate=${BUILD_DATE} \
-X github.com/makeopensource/leviathan/common.Branch=${BRANCH}" \
-o leviathan
FROM alpine:latest
WORKDIR /app/
COPY --from=builder /app/leviathan .
ENV LEVIATHAN_IS_DOCKER=true
# default level info when running in docker
ENV LEVIATHAN_LOG_LEVEL=info
EXPOSE 9221
CMD ["./leviathan"]