build: 加入 Dockerfile

This commit is contained in:
Mmx233
2022-08-14 20:55:50 +08:00
parent df87d75aca
commit 09ebaf9eae

25
Dockerfile Normal file
View File

@@ -0,0 +1,25 @@
FROM golang:alpine as builder
RUN go env -w CGO_ENABLED=0
WORKDIR /build
COPY . .
RUN go build -ldflags '-extldflags "-static"' -o runner
FROM alpine:latest
RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo 'Asia/Shanghai' >/etc/timezone && \
rm -rf /var/cache/apk/*
COPY --from=builder /build/runner /usr/bin/runner
RUN chmod +x /usr/bin/runner
WORKDIR /data
ENTRYPOINT [ "/usr/bin/runner" ]