mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-09-13 20:00:10 +08:00
Multistage Docker build with scratch container
This commit is contained in:
parent
6c0b475c15
commit
76c0b2925f
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
||||
.git/
|
||||
tests/
|
||||
screenshot/
|
22
Dockerfile
22
Dockerfile
@ -1,10 +1,15 @@
|
||||
FROM alpine:3.4
|
||||
# Define build image which compiles binary
|
||||
FROM golang:1.9.2-alpine as build
|
||||
|
||||
RUN apk update && \
|
||||
apk add -U --no-cache \
|
||||
ca-certificates \
|
||||
openssh-client && \
|
||||
rm -rf /var/cache/apk/*
|
||||
WORKDIR /go/src/github.com/appleboy/drone-ssh
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo \
|
||||
&& cp drone-ssh /bin
|
||||
|
||||
# Define final image which consumes final artifact
|
||||
FROM scratch
|
||||
|
||||
LABEL org.label-schema.version=latest
|
||||
LABEL org.label-schema.vcs-url="https://github.com/appleboy/drone-ssh.git"
|
||||
@ -12,5 +17,8 @@ LABEL org.label-schema.name="drone-ssh"
|
||||
LABEL org.label-schema.vendor="Bo-Yi Wu"
|
||||
LABEL org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/linux/amd64/drone-ssh /bin/
|
||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
|
||||
COPY --from=build /bin/drone-ssh /bin/
|
||||
|
||||
ENTRYPOINT ["/bin/drone-ssh"]
|
||||
|
Loading…
Reference in New Issue
Block a user