-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
31 lines (28 loc) · 960 Bytes
/
Dockerfile
File metadata and controls
31 lines (28 loc) · 960 Bytes
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
FROM golang:1.23.6-alpine AS builder
RUN apk add --no-cache git
WORKDIR /app
COPY go.mod ./
COPY *.go ./
COPY templates/ templates/
COPY static/ static/
COPY data/ data/
ARG COMMIT_HASH
ARG BUILD_TIME
ARG BUILD_LOG_URL
RUN FINAL_HASH="${COMMIT_HASH}"; \
if [ -z "$FINAL_HASH" ]; then \
FINAL_HASH=$(git clone --depth=1 https://github.com/uSwapExchange/zero.git /tmp/repo 2>/dev/null && cd /tmp/repo && git rev-parse HEAD || echo "unknown"); \
rm -rf /tmp/repo; \
fi && \
FINAL_TIME="${BUILD_TIME}"; \
if [ -z "$FINAL_TIME" ]; then \
FINAL_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ"); \
fi && \
CGO_ENABLED=0 GOOS=linux go build \
-ldflags "-s -w -X main.commitHash=${FINAL_HASH} -X main.buildTime=${FINAL_TIME} -X main.buildLogURL=${BUILD_LOG_URL}" \
-o /zero
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /zero /zero
EXPOSE 3000
ENTRYPOINT ["/zero"]