forked from cayleygraph/cayley
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (50 loc) · 2.01 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
FROM golang:1.11 as builder
# Set up workdir
WORKDIR /cayley
# Restore dependencies
COPY go.mod go.sum ./
RUN go mod download
# This will be used to init cayley and as config file in the final image.
# Make sure you start every path with %PREFIX% to make it available in both
# the builder image and the final image.
RUN echo '{"store":{"backend":"bolt","address":"%PREFIX%/data/cayley.db"}}' > config.json
# Create filesystem for minimal image
RUN mkdir -p /fs/assets
RUN mkdir -p /fs/bin
RUN mkdir -p /fs/data
RUN mkdir -p /fs/etc
RUN sed 's_%PREFIX%__g' config.json > /fs/etc/cayley.json
ENV PATH /fs/bin:$PATH
# Copy CA certs from builder image to the filesystem of the cayley image
RUN mkdir -p /fs/etc/ssl/certs
RUN cp /etc/ssl/certs/ca-certificates.crt /fs/etc/ssl/certs/ca-certificates.crt
RUN mkdir -p /fs/lib/x86_64-linux-gnu
RUN cp /lib/x86_64-linux-gnu/libc-* /fs/lib/x86_64-linux-gnu/
# Add assets to target fs
COPY docs /fs/assets/docs
COPY static /fs/assets/static
COPY templates /fs/assets/templates
# Add and build static linked version of cayley
# This will show warnings that glibc is required at runtime which can be ignored
COPY . .
RUN go build \
-ldflags="-linkmode external -extldflags -static -X github.com/cayleygraph/cayley/version.GitHash=$(git rev-parse HEAD | cut -c1-12)" \
-a \
-installsuffix cgo \
-o /fs/bin/cayley \
-v \
./cmd/cayley
RUN sed 's_%PREFIX%_/fs_g' config.json > /etc/cayley.json
RUN cayley init --config /etc/cayley.json
FROM scratch
LABEL maintainer="Yannic Bonenberger" \
email="[email protected]"
# Expose the port and volume for configuration and data persistence. If you're
# using a backend like bolt, make sure the file is saved to this directory.
COPY --from=builder /fs /
VOLUME ["/data"]
EXPOSE 64210
# Adding everything to entrypoint allows us to init+load+serve
# with default containers parameters:
# i.e.: `docker run quay.io/cayleygraph/cayley --init -i /data/my_data.nq`
ENTRYPOINT ["cayley", "http", "--assets", "/assets", "--host", ":64210"]