Skip to content

Commit

Permalink
ci: build docker (#135)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Nov 7, 2019
1 parent 7a95196 commit acbabd7
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
after_success:
- bash <(curl -s https://codecov.io/bash)
- codeclimate-test-reporter < coverage.txt
# - stage: docker
# script:
# - docker build .
- stage: docker
script:
- docker build .
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ENV PATH $VOLANTMQ_WORK_DIR/bin:$PATH
# build server
RUN \
GO111MODULE=off go get -v github.com/VolantMQ/volantmq/cmd/volantmq \
&& cd $GOPATH/src/github.com/VolantMQ/volantmq \
&& cd $GOPATH/src/github.com/VolantMQ/volantmq/cmd/volantmq \
&& GO111MODULE=on go mod tidy \
&& go build $VOLANTMQ_BUILD_FLAGS -o $VOLANTMQ_WORK_DIR/bin/volantmq

Expand Down
12 changes: 12 additions & 0 deletions dockerBuildLocal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

buildArgs=

if [[ ! -z "$1" ]]; then
buildArgs="-t $1"
fi

docker build -f ./local.Dockerfile ${buildArgs} .

echo "removing intermediate container"
docker rmi -f $(docker images -q --filter label=stage=intermediate)
61 changes: 61 additions & 0 deletions local.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
FROM golang:1.13.4 as builder
LABEL stage=intermediate

#compile linux only

ENV \
GOOS=linux \
VOLANTMQ_WORK_DIR=/usr/lib/volantmq \
VOLANTMQ_BUILD_FLAGS="-i" \
VOLANTMQ_PLUGINS_DIR=/usr/lib/volantmq/plugins \
GO111MODULE=on

RUN mkdir -p $VOLANTMQ_WORK_DIR/bin
RUN mkdir -p $VOLANTMQ_WORK_DIR/conf
RUN mkdir -p $VOLANTMQ_PLUGINS_DIR

# Create environment directory
ENV PATH $VOLANTMQ_WORK_DIR/bin:$PATH

COPY . $GOPATH/src/github.com/VolantMQ/volantmq

# build server
RUN \
cd $GOPATH/src/github.com/VolantMQ/volantmq/cmd/volantmq \
&& go build $VOLANTMQ_BUILD_FLAGS -o $VOLANTMQ_WORK_DIR/bin/volantmq

# build debug plugins
RUN \
GO111MODULE=off go get gitlab.com/VolantMQ/vlplugin/debug \
&& cd $GOPATH/src/gitlab.com/VolantMQ/vlplugin/debug \
&& GO111MODULE=on go mod tidy \
&& go build $VOLANTMQ_BUILD_FLAGS -buildmode=plugin -o $VOLANTMQ_WORK_DIR/plugins/debug.so

# build health plugins
RUN \
GO111MODULE=off go get gitlab.com/VolantMQ/vlplugin/health \
&& cd $GOPATH/src/gitlab.com/VolantMQ/vlplugin/health \
&& GO111MODULE=on go mod tidy \
&& go build $VOLANTMQ_BUILD_FLAGS -buildmode=plugin -o $VOLANTMQ_WORK_DIR/plugins/health.so

#build persistence plugins
RUN \
GO111MODULE=off go get gitlab.com/VolantMQ/vlplugin/persistence/bbolt \
&& cd $GOPATH/src/gitlab.com/VolantMQ/vlplugin/persistence/bbolt \
&& GO111MODULE=on go mod tidy \
&& cd plugin \
&& go build $VOLANTMQ_BUILD_FLAGS -buildmode=plugin -o $VOLANTMQ_WORK_DIR/plugins/persistence_bbolt.so

FROM ubuntu
ENV \
VOLANTMQ_WORK_DIR=/usr/lib/volantmq

COPY --from=builder $VOLANTMQ_WORK_DIR $VOLANTMQ_WORK_DIR

# Create environment directory
ENV PATH $VOLANTMQ_WORK_DIR/bin:$PATH
ENV VOLANTMQ_PLUGINS_DIR=$VOLANTMQ_WORK_DIR/plugins

# default config uses mqtt:1883
EXPOSE 1883
CMD ["volantmq"]

0 comments on commit acbabd7

Please sign in to comment.