Skip to content

Commit

Permalink
Dockerfile: Use multiple stage builds (#23)
Browse files Browse the repository at this point in the history
* suggestion: Support multiple stage builds

Signed-off-by: Ce Gao <gaoce@caicloud.io>

* docs: Add requiremnet for docker build

Signed-off-by: Ce Gao <gaoce@caicloud.io>

* manifests: Remove the args and use entrypoint

Signed-off-by: Ce Gao <gaoce@caicloud.io>

* Dockerfile: Replace shell format with exec format

Signed-off-by: Ce Gao <gaoce@caicloud.io>
  • Loading branch information
gaocegege authored Apr 9, 2018
1 parent 830e2a7 commit ed0d31d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 33 deletions.
4 changes: 4 additions & 0 deletions docs/developer-guide.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Developer Guide

## Requirements

- Docker (17.05 or later.)

## Build from source code

You can build all images from source.
Expand Down
2 changes: 0 additions & 2 deletions manifests/vizier/suggestion/grid/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ spec:
containers:
- name: vizier-suggestion-grid
image: katib/suggestion-grid
args:
- './grid'
ports:
- name: api
containerPort: 6789
Expand Down
2 changes: 0 additions & 2 deletions manifests/vizier/suggestion/hyperband/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ spec:
containers:
- name: vizier-suggestion-hyperband
image: katib/suggestion-hyperband
args:
- './hyperband'
ports:
- name: api
containerPort: 6789
Expand Down
2 changes: 0 additions & 2 deletions manifests/vizier/suggestion/random/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ spec:
containers:
- name: vizier-suggestion-random
image: katib/suggestion-random
args:
- './random'
ports:
- name: api
containerPort: 6789
Expand Down
18 changes: 9 additions & 9 deletions suggestion/grid/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang
RUN : && \
go get google.golang.org/grpc && \
:
ADD api $GOPATH/src/github.com/kubeflow/hp-tuning/api
ADD db $GOPATH/src/github.com/kubeflow/hp-tuning/db
ADD manager $GOPATH/src/github.com/kubeflow/hp-tuning/manager
ADD suggestion $GOPATH/src/github.com/kubeflow/hp-tuning/suggestion
WORKDIR $GOPATH/src/github.com/kubeflow/hp-tuning/suggestion/grid
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/suggestion/grid
RUN go build -o grid

FROM alpine:3.7
WORKDIR /app
COPY --from=build-env /go/src/github.com/kubeflow/hp-tuning/suggestion/grid /app/
ENTRYPOINT ["./grid"]
18 changes: 9 additions & 9 deletions suggestion/hyperband/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang
RUN : && \
go get google.golang.org/grpc && \
:
ADD api $GOPATH/src/github.com/kubeflow/hp-tuning/api
ADD db $GOPATH/src/github.com/kubeflow/hp-tuning/db
ADD manager $GOPATH/src/github.com/kubeflow/hp-tuning/manager
ADD suggestion $GOPATH/src/github.com/kubeflow/hp-tuning/suggestion
WORKDIR $GOPATH/src/github.com/kubeflow/hp-tuning/suggestion/hyperband
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/suggestion/hyperband
RUN go build -o hyperband

FROM alpine:3.7
WORKDIR /app
COPY --from=build-env /go/src/github.com/kubeflow/hp-tuning/suggestion/hyperband /app/
ENTRYPOINT ["./hyperband"]
18 changes: 9 additions & 9 deletions suggestion/random/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang
RUN : && \
go get google.golang.org/grpc && \
:
ADD api $GOPATH/src/github.com/kubeflow/hp-tuning/api
ADD db $GOPATH/src/github.com/kubeflow/hp-tuning/db
ADD manager $GOPATH/src/github.com/kubeflow/hp-tuning/manager
ADD suggestion $GOPATH/src/github.com/kubeflow/hp-tuning/suggestion
WORKDIR $GOPATH/src/github.com/kubeflow/hp-tuning/suggestion/random
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/suggestion/random
RUN go build -o random

FROM alpine:3.7
WORKDIR /app
COPY --from=build-env /go/src/github.com/kubeflow/hp-tuning/suggestion/random /app/
ENTRYPOINT ["./random"]

0 comments on commit ed0d31d

Please sign in to comment.