github.com/cayleygraph/cayley@v0.7.7/Dockerfile (about) 1 FROM golang:1.13 as builder 2 3 # Install packr 4 RUN go get -u github.com/gobuffalo/packr/v2/packr2 5 6 # Create filesystem for minimal image 7 WORKDIR /fs 8 9 RUN mkdir -p etc/ssl/certs lib/x86_64-linux-gnu tmp bin data; \ 10 # Copy CA Certificates 11 cp /etc/ssl/certs/ca-certificates.crt etc/ssl/certs/ca-certificates.crt; \ 12 # Copy C standard library 13 cp /lib/x86_64-linux-gnu/libc-* lib/x86_64-linux-gnu/ 14 15 # Set up workdir for compiling 16 WORKDIR /src 17 18 # Copy dependencies and install first 19 COPY go.mod go.sum ./ 20 RUN go mod download 21 22 # Add all the other files 23 ADD . . 24 25 # Run packr to generate .go files that pack the static files into bytes that can be bundled into the Go binary. 26 RUN packr2 27 28 # Pass a Git short SHA as build information to be used for displaying version 29 RUN SHORT_SHA=$(git rev-parse --short=12 HEAD); \ 30 go build \ 31 -ldflags="-linkmode external -extldflags -static -X github.com/cayleygraph/cayley/version.GitHash=$SHORT_SHA" \ 32 -a \ 33 -installsuffix cgo \ 34 -o /fs/bin/cayley \ 35 -v \ 36 ./cmd/cayley 37 38 # Move persisted configuration into filesystem 39 RUN mv configurations/persisted.json /fs/etc/cayley.json 40 41 WORKDIR /fs 42 43 # Initialize bolt indexes file 44 RUN ./bin/cayley init --config etc/cayley.json 45 46 FROM scratch 47 48 # Copy filesystem as root 49 COPY --from=builder /fs / 50 51 # Define volume for configuration and data persistence. If you're using a 52 # backend like bolt, make sure the file is saved to this directory. 53 VOLUME [ "/data" ] 54 55 EXPOSE 64210 56 57 # Adding everything to entrypoint allows us to init, load and serve only with 58 # arguments passed to docker run. For example: 59 # `docker run cayleygraph/cayley --init -i /data/my_data.nq` 60 ENTRYPOINT ["cayley", "http", "--host=:64210"]