Skip to content

Commit

Permalink
Merge branch 'proposalDockerfile'
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed May 3, 2019
2 parents 8a2681b + 4bcab3c commit 78d3ee4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 20 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/.idea
/bin
/pkg
/logs

media-repo*.yaml
homeserver.yaml

vendor/pkg
vendor/src

# Binaries for programs and plugins
*.exe
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/
49 changes: 29 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
FROM docker.io/alpine
COPY . /tmp/src
# ---- Stage 0 ----
# Builds media_repo and import_synapse
FROM golang:1.11-alpine AS builder

# Install build dependencies
RUN apk add --no-cache git musl-dev \
&& go get github.com/constabulary/gb/...

WORKDIR /opt

COPY ./vendor /opt/vendor
COPY ./src /opt/src
RUN GOPATH=`pwd`/vendor gb vendor restore

RUN GOPATH=`pwd`:`pwd`/vendor go build -v -o /opt/bin/media_repo ./src/github.com/turt2live/matrix-media-repo/cmd/media_repo/ \
&& GOPATH=`pwd`:`pwd`/vendor go build -v -o /opt/bin/import_synapse ./src/github.com/turt2live/matrix-media-repo/cmd/import_synapse/

# ---- Stage 1 ----
# Final runtime stage.
FROM alpine

RUN apk add --no-cache \
su-exec \
ca-certificates \
&& apk add --no-cache \
-t build-deps \
go \
git \
musl-dev \
&& cd /tmp/src \
&& GOPATH=`pwd` go get github.com/constabulary/gb/... \
&& PATH=$PATH:`pwd`/bin gb vendor restore \
&& GOPATH=`pwd`:`pwd`/vendor go build -o bin/media_repo ./src/github.com/turt2live/matrix-media-repo/cmd/media_repo/ \
&& GOPATH=`pwd`:`pwd`/vendor go build -o bin/import_synapse ./src/github.com/turt2live/matrix-media-repo/cmd/import_synapse/ \
&& cp bin/media_repo bin/import_synapse docker/run.sh /usr/local/bin \
&& cp config.sample.yaml /etc/media-repo.yaml.sample \
&& cp -R migrations /var/lib/media-repo-migrations \
&& cd / \
&& rm -rf /tmp/* \
&& apk del build-deps
su-exec \
ca-certificates

COPY --from=builder /opt/bin/media_repo /opt/bin/import_synapse /usr/local/bin/

COPY ./config.sample.yaml /etc/media-repo.yaml.sample
COPY ./migrations /var/lib/media-repo-migrations
COPY ./docker/run.sh /usr/local/bin/

CMD /usr/local/bin/run.sh
VOLUME ["/data", "/media"]
Expand Down

0 comments on commit 78d3ee4

Please sign in to comment.