Skip to content

Commit

Permalink
Use multi-stage build in dockerfile (cadence-workflow#1447)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark authored and samarabbas committed Feb 13, 2019
1 parent 99ca975 commit 24b6a45
Showing 1 changed file with 19 additions and 31 deletions.
50 changes: 19 additions & 31 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,60 +18,48 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

FROM debian:jessie
# Build cadence binaries
FROM golang:1.11.1 as builder

# Specify the cadence version to be built into this docker image
# See https://github.com/uber/cadence/tags
ARG git_branch
RUN if [ -z "$git_branch" ]; then echo "ERROR: git_branch NOT SET. Usage: docker build . --build-arg git_branch=YOUR_CHECKOUT_BRANCH"; exit 1; else : ; fi

# get golang 1.8.1
RUN go get -u github.com/golang/dep/cmd/dep
RUN go get -u github.com/golang/lint/golint

# get and compile cadence-server
RUN git clone https://github.com/uber/cadence.git /go/src/github.com/uber/cadence
RUN cd /go/src/github.com/uber/cadence && git checkout $git_branch && make bins_nothrift


# Final Cadence image
FROM debian:jessie

RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
gcc \
libc6-dev \
make \
pkg-config \
libev4 libev-dev \
gettext-base \
wget \
vim \
tcpdump \
netcat \
python-pip \
git-all \
&& rm -rf /var/lib/apt/lists/*

RUN pip install cqlsh

ENV GOLANG_VERSION 1.11.1
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
ENV GOLANG_DOWNLOAD_SHA256 2871270d8ff0c8c69f161aaae42f9f28739855ff5c5204752a8d92a1c9f63993

RUN set -eux; \
wget -O golang.tar.gz "$GOLANG_DOWNLOAD_URL" \
&& echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \
&& tar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz

ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"

# get and compile cadence-server
ENV CADENCE_HOME $GOPATH/src/github.com/uber/cadence

RUN go get -u github.com/golang/dep/cmd/dep
RUN go get -u github.com/golang/lint/golint

RUN git clone https://github.com/uber/cadence.git $CADENCE_HOME
RUN cd $CADENCE_HOME && git checkout $git_branch && make bins_nothrift
RUN mkdir /cadence
ENV CADENCE_HOME /cadence

EXPOSE 7933 7934 7935 7939

COPY ./start.sh $CADENCE_HOME/start.sh
COPY ./config_template.yaml $CADENCE_HOME/config/docker_template.yaml
RUN chmod a+x $CADENCE_HOME/start.sh

COPY --from=builder /go/src/github.com/uber/cadence/cadence-cassandra-tool /cadence
COPY --from=builder /go/src/github.com/uber/cadence/cadence /cadence
COPY --from=builder /go/src/github.com/uber/cadence/cadence-server /cadence

WORKDIR $CADENCE_HOME
CMD ./start.sh $CADENCE_HOME

0 comments on commit 24b6a45

Please sign in to comment.