forked from uber/cadence
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
130 lines (84 loc) · 3.55 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
ARG TARGET=server
# Can be used in case a proxy is necessary
ARG GOPROXY
# Build tcheck binary
FROM golang:1.17-alpine3.15 AS tcheck
WORKDIR /go/src/github.com/uber/tcheck
COPY go.* ./
RUN go build -mod=readonly -o /go/bin/tcheck github.com/uber/tcheck
# Build Cadence binaries
FROM golang:1.17-alpine3.13 AS builder
ARG RELEASE_VERSION
RUN apk add --update --no-cache ca-certificates make git curl mercurial unzip
WORKDIR /cadence
# Making sure that dependency is not touched
ENV GOFLAGS="-mod=readonly"
# Copy go mod dependencies and build cache
COPY go.* ./
RUN go mod download
COPY . .
RUN rm -fr .bin .build
ENV CADENCE_RELEASE_VERSION=$RELEASE_VERSION
# bypass codegen, use committed files. must be run separately, before building things.
RUN make .fake-codegen
RUN CGO_ENABLED=0 make copyright cadence-cassandra-tool cadence-sql-tool cadence cadence-server cadence-bench cadence-canary
# Download dockerize
FROM alpine:3.15 AS dockerize
RUN apk add --no-cache openssl
ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& echo "**** fix for host id mapping error ****" \
&& chown root:root /usr/local/bin/dockerize
# Alpine base image
FROM alpine:3.11 AS alpine
RUN apk add --update --no-cache ca-certificates tzdata bash curl
# set up nsswitch.conf for Go's "netgo" implementation
# https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-424546457
RUN test ! -e /etc/nsswitch.conf && echo 'hosts: files dns' > /etc/nsswitch.conf
SHELL ["/bin/bash", "-c"]
# Cadence server
FROM alpine AS cadence-server
ENV CADENCE_HOME /etc/cadence
RUN mkdir -p /etc/cadence
COPY --from=tcheck /go/bin/tcheck /usr/local/bin
COPY --from=dockerize /usr/local/bin/dockerize /usr/local/bin
COPY --from=builder /cadence/cadence-cassandra-tool /usr/local/bin
COPY --from=builder /cadence/cadence-sql-tool /usr/local/bin
COPY --from=builder /cadence/cadence /usr/local/bin
COPY --from=builder /cadence/cadence-server /usr/local/bin
COPY --from=builder /cadence/schema /etc/cadence/schema
COPY docker/entrypoint.sh /docker-entrypoint.sh
COPY config/dynamicconfig /etc/cadence/config/dynamicconfig
COPY config/credentials /etc/cadence/config/credentials
COPY docker/config_template.yaml /etc/cadence/config
COPY docker/start-cadence.sh /start-cadence.sh
WORKDIR /etc/cadence
ENV SERVICES="history,matching,frontend,worker"
EXPOSE 7933 7934 7935 7939
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD /start-cadence.sh
# All-in-one Cadence server
FROM cadence-server AS cadence-auto-setup
RUN apk add --update --no-cache ca-certificates py3-pip mysql-client
RUN pip3 install cqlsh && cqlsh --version
COPY docker/start.sh /start.sh
CMD /start.sh
# Cadence CLI
FROM alpine AS cadence-cli
COPY --from=tcheck /go/bin/tcheck /usr/local/bin
COPY --from=builder /cadence/cadence /usr/local/bin
ENTRYPOINT ["cadence"]
# Cadence Canary
FROM alpine AS cadence-canary
COPY --from=builder /cadence/cadence-canary /usr/local/bin
COPY --from=builder /cadence/cadence /usr/local/bin
CMD ["/usr/local/bin/cadence-canary", "--root", "/etc/cadence-canary", "start"]
# Cadence Bench
FROM alpine AS cadence-bench
COPY --from=builder /cadence/cadence-bench /usr/local/bin
COPY --from=builder /cadence/cadence /usr/local/bin
CMD ["/usr/local/bin/cadence-bench", "--root", "/etc/cadence-bench", "start"]
# Final image
FROM cadence-${TARGET}