Skip to content

Commit

Permalink
Dockerfile: Support multiple stage build in dlk and frontend (#28)
Browse files Browse the repository at this point in the history
* dlk: Multiple stage builds

Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com>

* frontend: Multiple stage builds

Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com>
  • Loading branch information
YujiOshima authored and gaocegege committed Apr 10, 2018
1 parent ed0d31d commit 9192cbd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 83 deletions.
61 changes: 10 additions & 51 deletions dlk/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,10 @@
# This image will setup the container for compiling and running the ksched binary
# The flowlessly solver is already set up in the location needed by ksched

# Prepare base image
FROM ubuntu:14.04
MAINTAINER Yuji Oshima <yuji.oshima0x3fd@gmail.com>
RUN apt-get update
RUN apt-get --yes --force-yes install git-all build-essential cmake libgflags2 libgflags-dev libgoogle-glog0 libgoogle-glog-dev libboost-all-dev curl wget autoconf automake libtool curl make g++ unzip

# Set up the solver binary in the location "/usr/local/bin/flowlessly/" hardcoded in the placement/solver
RUN cd /root && git clone https://github.com/hasbro17/Flowlessly.git && cd /root/Flowlessly && cmake . && make
RUN mkdir -p /usr/local/bin/flowlessly/ && cp /root/Flowlessly/build/flow_scheduler /usr/local/bin/flowlessly/

# Enivronment variables for Go
ENV PATH $PATH:/usr/local/go/bin:/root/go-workspace/bin::/usr/local/bin/flowlessly/
ENV GOPATH /root/go-workspace

# Install Go and set up workspace for compiling binary
RUN cd /root && curl -O https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz && tar -xvf go1.9.linux-amd64.tar.gz && mv go /usr/local
RUN mkdir -p /root/go-workspace/src/github.com

# Set up kubernetes in go workspace
RUN mkdir /root/go-workspace/src/k8s.io && cd /root/go-workspace/src/github.com/ && git clone https://github.com/kubernetes/kubernetes.git
#&& mv /root/go-workspace/src/github.com/kubernetes /root/go-workspace/src/k8s.io/

# Set up proto stuff
RUN cd /root && mkdir proto-bin && cd proto-bin && wget "https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0.0-linux-x86_64.zip" && unzip protoc-3.0.0-linux-x86_64.zip && cp bin/protoc /usr/local/bin/protoc

RUN : &&\
mkdir -p /root/go-workspace/src/k8s.io && \
cd /root/go-workspace/src/k8s.io && \
git clone https://github.com/kubernetes/apimachinery && \
git clone https://github.com/kubernetes/api && \
git clone https://github.com/kubernetes/client-go && \
git clone https://github.com/kubernetes/kube-openapi && \
go get github.com/go-openapi/spec && \
go get github.com/golang/glog && \
go get github.com/google/gofuzz && \
go get github.com/emicklei/go-restful && \
go get github.com/spf13/cobra && \
go get github.com/spf13/viper && \
go get github.com/labstack/echo && \
go get github.com/sirupsen/logrus && \
:

ADD dlk /root/go-workspace/src/github.com/kubeflow/hp-tuning/dlk
RUN mkdir -p /root/go-workspace/src/github.com/kubeflow/hp-tuning/dlk/bin
WORKDIR /root/go-workspace/src/github.com/kubeflow/hp-tuning/dlk
RUN go build -o bin/dlkmanager ./dlkmanager
RUN go build -o bin/dlkctl ./dlkctl
ENV PATH $PATH:/root/go-workspace/src/github.com/kubeflow/hp-tuning/dlk/bin
FROM golang:alpine AS build-env
# The GOPATH in the image is /go.
ADD . /go/src/github.com/kubeflow/hp-tuning
WORKDIR /go/src/github.com/kubeflow/hp-tuning/dlk/dlkmanager
RUN go build -o dlkmanager

FROM alpine:3.7
WORKDIR /app
COPY --from=build-env /go/src/github.com/kubeflow/hp-tuning/dlk/dlkmanager/dlkmanager /app/
ENTRYPOINT ["./dlkmanager"]
43 changes: 11 additions & 32 deletions manager/modeldb/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
FROM node:latest

EXPOSE 3000

RUN apt-get update \
&& apt-get install -y \
g++ \
make \
wget \
git \
&& apt-get clean

WORKDIR /root

# Install Thrift 0.10.0
RUN wget -q http://archive.apache.org/dist/thrift/0.10.0/thrift-0.10.0.tar.gz && \
tar -xzf thrift-0.10.0.tar.gz && \
cd thrift-0.10.0 && \
./configure --without-python && \
make && \
ln -n ~/thrift-0.10.0/compiler/cpp/thrift /usr/local/bin/thrift

RUN cd / && git clone https://github.com/mitdbg/modeldb

FROM thrift:0.11 AS build-env
RUN apt-get update && apt-get install -y git
RUN git clone https://github.com/mitdbg/modeldb
ADD manager/modeldb/frontend /modeldb/frontend

WORKDIR /modeldb/frontend

RUN npm install

RUN mkdir -p './thrift' && \
thrift -r -out './thrift' -gen js:node '../thrift/ModelDB.thrift' && \
npm install
ENTRYPOINT ["/modeldb/dockerbuild/wait_for_backend.sh"]
CMD ["backend"]
thrift -r -out './thrift' -gen js:node '../thrift/ModelDB.thrift'

FROM node:alpine
COPY --from=build-env /modeldb /modeldb
WORKDIR /modeldb/frontend
RUN npm install
EXPOSE 3000
ENTRYPOINT ["sh","/modeldb/dockerbuild/wait_for_backend.sh"]

0 comments on commit 9192cbd

Please sign in to comment.