From d135be92f6093c04425fbcacdb65016f4d6040f5 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 6 Jun 2018 15:47:12 -0600 Subject: [PATCH] Update the Docker image for easier use of automated builds Signed-off-by: Travis Ralston --- .dockerignore | 10 ++++++++++ Dockerfile | 13 ++++++++++++- README.md | 2 +- build-docker-image.sh | 12 ------------ 4 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 .dockerignore delete mode 100755 build-docker-image.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5df1656 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +vendor/pkg +vendor/src +pkg +hooks +bin + +# Other stuff we just don't need +.gitignore +.git +.travis.yml diff --git a/Dockerfile b/Dockerfile index e45e881..7731c2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,18 @@ 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 +COPY . /tmp/go-neb +WORKDIR /tmp/go-neb +ENV GOPATH=/tmp/go-neb/vendor/src:/tmp/go-neb/vendor:/tmp/go-neb +RUN apk add --no-cache -t build-deps git gcc musl-dev go \ + && go get -u github.com/constabulary/gb/... \ + && export PATH="/tmp/go-neb/vendor/src/bin:${PATH}" \ + && gb vendor restore \ + && gb build -f github.com/matrix-org/go-neb \ + && mv bin/go-neb /go-neb \ + && cd / \ + && rm -rf /tmp/* \ + && apk del build-deps VOLUME /data EXPOSE 4050 diff --git a/README.md b/README.md index 4f48f7d..ae81e08 100644 --- a/README.md +++ b/README.md @@ -225,7 +225,7 @@ 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. +There is a `Dockerfile` in the root of the repository which copies the local source files and builds go-neb. The image sets the following environment variables: ``` diff --git a/build-docker-image.sh b/build-docker-image.sh deleted file mode 100755 index d5a3495..0000000 --- a/build-docker-image.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/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 .