diff --git a/guestbook-go/Dockerfile b/guestbook-go/Dockerfile index a58ebae3..087fd6bc 100644 --- a/guestbook-go/Dockerfile +++ b/guestbook-go/Dockerfile @@ -12,13 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM busybox:ubuntu-14.04 - -ADD ./guestbook_bin /app/guestbook -ADD ./public/index.html /app/public/index.html -ADD ./public/script.js /app/public/script.js -ADD ./public/style.css /app/public/style.css - +FROM golang:1.10.0 +RUN go get github.com/codegangsta/negroni \ + github.com/gorilla/mux \ + github.com/xyproto/simpleredis WORKDIR /app -CMD ["./guestbook"] +ADD ./main.go . +RUN CGO_ENABLED=0 GOOS=linux go build -o main . + +FROM scratch +WORKDIR /app +COPY --from=0 /app/main . +COPY ./public/index.html public/index.html +COPY ./public/script.js public/script.js +COPY ./public/style.css public/style.css +CMD ["/app/main"] EXPOSE 3000 diff --git a/guestbook-go/Makefile b/guestbook-go/Makefile index ce17d07e..891fcde8 100644 --- a/guestbook-go/Makefile +++ b/guestbook-go/Makefile @@ -23,9 +23,7 @@ release: clean build push clean # builds a docker image that builds the app and packages it into a minimal docker image build: - @cp ../../bazel-bin/examples/guestbook-go/guestbook-go guestbook_bin - docker build --pull --rm --force-rm -t ${REGISTRY}/guestbook-builder . - docker run --rm ${REGISTRY}/guestbook-builder | docker build --pull -t "${REGISTRY}/guestbook:${VERSION}" - + docker build -t ${REGISTRY}/guestbook:${VERSION} . # push the image to an registry push: @@ -33,9 +31,6 @@ push: # remove previous images and containers clean: - rm -f guestbook_bin - docker rm -f ${REGISTRY}/guestbook-builder 2> /dev/null || true - docker rmi -f ${REGISTRY}/guestbook-builder || true - docker rmi -f "${REGISTRY}/guestbook:${VERSION}" || true + docker rm -f ${REGISTRY}/guestbook:${VERSION} 2> /dev/null || true .PHONY: release clean build push