-
Notifications
You must be signed in to change notification settings - Fork 48
/
SCHEDULER.Dockerfile
63 lines (43 loc) · 1.61 KB
/
SCHEDULER.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Builder image
FROM golang:1.17-alpine as builder
RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.4/main/" > /etc/apk/repositories && \
apk add --no-cache \
wget \
git
RUN mkdir -p /home/build && \
mkdir -p /home/scheduler
ARG build_dir=/home/build
ARG scheduler_dir=/home/scheduler
ENV ServiceName=gf.bridgx.scheduler
WORKDIR $build_dir
COPY . .
# Cache dependencies
ENV GO111MODULE on
ENV GOPROXY https://goproxy.cn,direct
COPY go.mod go.mod
COPY go.sum go.sum
#RUN go mod download
RUN mkdir -p output/conf output/bin
# detect mysql start
COPY wait-for-scheduler.sh output/bin/wait-for-scheduler.sh
RUN find conf/ -type f ! -name "*_local.*" | xargs -I{} cp {} output/conf/
RUN cp scripts/run_scheduler.sh output/
RUN CGO_ENABLED=0 GO111MODULE=on go build -o output/bin/${ServiceName} ./cmd/scheduler
RUN cp -rf output/* $scheduler_dir
# --------------------------------------------------------------------------------- #
# Executable image
FROM alpine:3.14
RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.4/main/" > /etc/apk/repositories
RUN apk --no-cache add tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone
ENV TZ Asia/Shanghai
RUN apk add --no-cache bash
ENV ServiceName=gf.bridgx.scheduler
ENV SpecifiedConfig=prod
COPY --from=builder /home/scheduler /home/tiger/scheduler
RUN addgroup -S tiger && adduser -S tiger -G tiger
WORKDIR /home/tiger/scheduler
RUN chown -R tiger:tiger /home/tiger && chmod +x run_scheduler.sh && chmod +x bin/wait-for-scheduler.sh
USER tiger
CMD ["/bin/sh","/home/tiger/scheduler/run_scheduler.sh"]