From 7ac95ea9e8222a6f4f8edd9db941418898770118 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 15 Aug 2017 14:20:15 +0800 Subject: [PATCH] feat: add multiple stage build for docker. --- .drone.yml | 2 -- Dockerfile | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9ddef31..106763f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,8 +25,6 @@ pipeline: - coverage all - make coverage - make build - # build binary for docker image - - make static_build when: event: [ push, tag, pull_request ] diff --git a/Dockerfile b/Dockerfile index 2971d32..c2cb762 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,7 @@ +FROM appleboy/golang-testing AS build-env +ADD . /go/src/github.com/appleboy/drone-ssh +RUN cd /go/src/github.com/appleboy/drone-ssh && make static_build + FROM alpine:3.4 RUN apk update && \ @@ -6,5 +10,5 @@ RUN apk update && \ openssh-client && \ rm -rf /var/cache/apk/* -ADD drone-ssh /bin/ +COPY --from=build-env /go/src/github.com/appleboy/drone-ssh/drone-ssh /bin ENTRYPOINT ["/bin/drone-ssh"]