https://github.com/google/cayley
Tip revision: 2a6f973c547ee028e32cdf6d7df62c81397ea4e4 authored by Yannic Bonenberger on 28 September 2017, 12:41:53 UTC
Fix config.json
Fix config.json
Tip revision: 2a6f973
Dockerfile
FROM golang:latest as builder
# Set up workdir
WORKDIR /go/src/github.com/cayleygraph/cayley
# Restore vendored dependencies
RUN sh -c "curl https://glide.sh/get | sh"
COPY glide.* ./
RUN glide install
# 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":"bolt2","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="contact@yannic-bonenberger.com"
# 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
ENTRYPOINT ["cayley"]
CMD ["http", "--assets", "/assets", "--host", ":64210"]