-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Dockerfile
58 lines (42 loc) · 1.65 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
FROM golang:1.22 AS builder
ARG VERSION=v0.8.x-dev
# 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
# Add all the other files
ADD . .
# Pass a Git short SHA as build information to be used for displaying version
RUN GIT_SHA=$(git rev-parse --short=12 HEAD); \
go build \
-ldflags="-linkmode external -extldflags -static -X github.com/cayleygraph/cayley/version.Version=$VERSION -X github.com/cayleygraph/cayley/version.GitHash=$GIT_SHA" \
-a \
-installsuffix cgo \
-o /fs/bin/cayley \
-v \
./cmd/cayley
# Move persisted configuration into filesystem
RUN mv configurations/persisted.json /fs/etc/cayley.json
WORKDIR /fs
# Initialize bolt indexes file
RUN ./bin/cayley init --config etc/cayley.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 [ "cayley", "health" ]
# Adding everything to entrypoint allows us to init, load and serve only with
# arguments passed to docker run. For example:
# `docker run cayleygraph/cayley --init -i /data/my_data.nq`
ENTRYPOINT ["cayley", "http", "--host=:64210"]