forked from cayleygraph/cayley
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
66 lines (48 loc) · 1.94 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
FROM golang:1.13 as builder
# Install packr
RUN go get -u github.com/gobuffalo/packr/v2/packr2
# Create filesystem for minimal image
WORKDIR /fs
RUN mkdir -p etc/ssl/certs lib/x86_64-linux-gnu tmp bin data; \
# Copy CA Certificates
cp /etc/ssl/certs/ca-certificates.crt etc/ssl/certs/ca-certificates.crt; \
# Copy C standard library
cp /lib/x86_64-linux-gnu/libc-* lib/x86_64-linux-gnu/
# Set up workdir for compiling
WORKDIR /src
# Copy dependencies and install first
COPY go.mod go.sum ./
RUN go mod download
# Copy UI download script and execute
COPY cmd/download_ui_demo/ ./cmd/download_ui_demo/
RUN go run cmd/download_ui_demo/download_ui_demo.go
# Add all the other files
ADD . .
# Run packr to generate .go files that pack the static files into bytes that can be bundled into the Go binary.
RUN packr2
# Pass a Git short SHA as build information to be used for displaying version
RUN SHORT_SHA=$(git rev-parse --short=12 HEAD); \
go build \
-ldflags="-linkmode external -extldflags -static -X github.com/epik-protocol/epik-gateway-backend/version.GitHash=$SHORT_SHA" \
-a \
-installsuffix cgo \
-o /fs/bin/gateway \
-v \
./cmd/gateway
# Move persisted configuration into filesystem
RUN mv configurations/persisted.json /fs/etc/epikgateway.json
WORKDIR /fs
# Initialize bolt indexes file
RUN ./bin/gateway init --config etc/epikgateway.json
FROM scratch
# Copy filesystem as root
COPY --from=builder /fs /
# Define volume for configuration and data persistence. If you're using a
# backend like bolt, make sure the file is saved to this directory.
VOLUME [ "/data" ]
EXPOSE 64210
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "gateway", "health" ]
# Adding everything to entrypoint allows us to init, load and serve only with
# arguments passed to docker run. For example:
# `docker run epik-protocol/gateway --init -i /data/my_data.nq`
ENTRYPOINT ["gateway", "http", "--host=:64210"]