From c34b32647add24b70725d72991467a1efd5c7579 Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Sun, 2 Jul 2017 21:36:17 +0200 Subject: [PATCH 1/2] Add Dockerfile and docker image build script --- Dockerfile | 10 ++++++++++ build-docker-image.sh | 12 ++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Dockerfile create mode 100755 build-docker-image.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e45e881 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine:3.6 + +ENV BIND_ADDRESS=:4050 DATABASE_TYPE=sqlite3 DATABASE_URL=/data/go-neb.db?_busy_timeout=5000 + +COPY bin/go-neb /go-neb + +VOLUME /data +EXPOSE 4050 + +ENTRYPOINT ["/go-neb"] diff --git a/build-docker-image.sh b/build-docker-image.sh new file mode 100755 index 0000000..d5a3495 --- /dev/null +++ b/build-docker-image.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +docker run \ + --rm \ + -v "$PWD":/usr/src/myapp \ + -w /usr/src/myapp \ + golang:1.8-alpine \ + sh -c 'apk add --no-cache git gcc musl-dev && go get -u github.com/constabulary/gb/... && gb build -f github.com/matrix-org/go-neb' + +docker build -t ${IMAGE_PREFIX}go-neb:latest . From 2d581581bc0fbb2dc3f6a51240554624937e58d5 Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Sun, 2 Jul 2017 21:43:09 +0200 Subject: [PATCH 2/2] README.md: Add notes on docker image --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 18e6ca8..47e0ba3 100644 --- a/README.md +++ b/README.md @@ -222,3 +222,16 @@ GOPATH=$GOPATH:$(pwd) godoc -v -http=localhost:6060 & # Open up the documentation for go-neb in a browser. sensible-browser http://localhost:6060/pkg/github.com/matrix-org/go-neb ``` + +## Docker image + +There is a `Dockerfile` in the root of the repository and a `build-docker-image.sh` script that uses an alpine-based golang container to build `go-neb` (note that this will overwrite host-built binaries in `pkg/` and `bin/`) and then builds the docker image using that binary. + +The image sets the following environment variables: +``` +BIND_ADDRESS=:4050 +DATABASE_TYPE=sqlite3 +DATABASE_URL=/data/go-neb.db?_busy_timeout=5000 +``` + +The image exposes port `4050` and a volume at `/data`. The `BASE_URL` environment variable needs to be set, a volume should be mounted at `/data` and port `4050` should be appropriately mapped as desired.