-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
39 lines (25 loc) · 869 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
FROM golang:1.23-alpine AS builder
LABEL stage=gobuilder \
mainatiner=https://github.com/xgzlucario/rotom
ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
ARG BUILD_TIME
WORKDIR /build
# 挂载本地缓存加速
VOLUME ["/go/pkg/mod", "/go/cache"]
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -ldflags="-s -w -X main.buildTime=${BUILD_TIME}" -o rotom .
FROM alpine:latest
ENV TZ Asia/Shanghai
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache ca-certificates tzdata && \
update-ca-certificates
RUN apk --no-cache add redis bash
VOLUME /data
WORKDIR /data
COPY --from=builder /build/rotom /data/rotom
COPY rotom.toml /etc/rotom/rotom.toml
EXPOSE 6379
CMD ["./rotom", "-conf", "/etc/rotom/rotom.toml"]