Browse Source

Update the Docker image for easier use of automated builds

Signed-off-by: Travis Ralston <travpc@gmail.com>
pull/233/head
Travis Ralston 7 years ago
parent
commit
d135be92f6
  1. 10
      .dockerignore
  2. 13
      Dockerfile
  3. 2
      README.md
  4. 12
      build-docker-image.sh

10
.dockerignore

@ -0,0 +1,10 @@
vendor/pkg
vendor/src
pkg
hooks
bin
# Other stuff we just don't need
.gitignore
.git
.travis.yml

13
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 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 VOLUME /data
EXPOSE 4050 EXPOSE 4050

2
README.md

@ -225,7 +225,7 @@ sensible-browser http://localhost:6060/pkg/github.com/matrix-org/go-neb
## Docker image ## 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: The image sets the following environment variables:
``` ```

12
build-docker-image.sh

@ -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 .
Loading…
Cancel
Save