forked from thorjealousy/midgard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
78 lines (58 loc) · 1.75 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
#
# Midgard
#
#
# Build
#
FROM golang:1.13 AS build
ARG pg_host
ARG rpc_host
ARG thornode_host
ENV PG_HOST=$pg_host
ENV RPC_HOST=$rpc_host
ENV THORNODE_HOST=$thornode_host
RUN env
WORKDIR /tmp/midgard
COPY . .
# Install jq to update the chain service config.
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update
RUN apt-get install -y jq apt-utils make yarn
RUN make node_modules
RUN make ${GOPATH}/bin/oapi-codegen
# Make sure swagger.json is updated
RUN make oapi-codegen-server
# Generate api document
RUN make doco
# Generate config.
RUN mkdir -p /etc/midgard
RUN cat ./cmd/midgard/config.json | jq \
--arg RPC_HOST "$RPC_HOST" \
--arg THORNODE_HOST "$THORNODE_HOST" \
--arg PG_HOST "$PG_HOST" \
'.timescale["host"] = $PG_HOST | \
.timescale["migrationsDir"] = "/var/midgard/db/migrations/" | \
.thorchain["rpc_host"] = $RPC_HOST | \
.thorchain["host"] = $THORNODE_HOST' > /etc/midgard/config.json
RUN cat /etc/midgard/config.json
# Compile.
RUN GO111MODULE=on go mod verify
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o midgard /tmp/midgard/cmd/midgard
#
# Main
#
FROM golang:alpine
ENV PATH="${PATH}:/go/bin"
RUN apk update
RUN apk add make openssl bind-tools curl
COPY --from=build /tmp/midgard/ .
# Copy the db migrations
COPY --from=build /tmp/midgard/db/ /var/midgard/db/
# Copy the compiled binaires over.
COPY --from=build /tmp/midgard/midgard /go/bin/midgard
# Copy the chain service config.
COPY --from=build /etc/midgard /etc/midgard
# Copy the chain service public folder ie generated docs
COPY --from=build /tmp/midgard/public/ /go/public/
CMD [ "midgard", "-c", "/etc/midgard/config.json" ]