forked from alexei-led/pumba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRockerfile
98 lines (78 loc) · 3.12 KB
/
Rockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# =======================
# Pumba Go builder
# =======================
FROM golang:1.7.3-alpine
MAINTAINER Alexei Ledenev <[email protected]>
# Golang build cache
MOUNT /go/pkg/linux_amd64 /go/src
# install required packages
RUN apk --no-cache add git bash curl openssl ca-certificates
# install glide package manager
ENV GLIDE_VERSION v0.12.3
RUN curl -Ls https://github.com/Masterminds/glide/releases/download/$GLIDE_VERSION/glide-$GLIDE_VERSION-linux-amd64.tar.gz | tar xz -C /tmp \
&& mv /tmp/linux-amd64/glide /usr/bin/
# gox - Go cross compile tool
# github-release - Github Release and upload artifacts
# goveralls - Go integration for Coveralls.io
# cover - Go code coverage tool
# go-junit-report - convert Go test into junit.xml format
RUN go get -v github.com/mitchellh/gox && \
go get -v github.com/aktau/github-release && \
go get -v github.com/mattn/goveralls && \
go get -v golang.org/x/tools/cmd/cover && \
go get -v github.com/jstemmer/go-junit-report
# prepare work directory
ENV PUMBADIR /go/src/github.com/gaia-adm/pumba
RUN mkdir -p $PUMBADIR
WORKDIR $PUMBADIR
# add source files
COPY . .
# mount vendor directory to reuse between builds
MOUNT /go/src/github.com/gaia-adm/pumba/.glide
ENV GLIDE_HOME /go/src/github.com/gaia-adm/pumba/.glide
# run code level test and get code coverage
{{ if .test }}
MOUNT .cover:/go/src/github.com/gaia-adm/pumba/.cover
RUN script/coverage.sh
{{ end }}
# compile Pumba: set git commit and branch through variables
# GitCommit=$(git rev-parse HEAD 2>/dev/null)
# GitBranch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
ENV GITCOMMIT {{ .GitCommit }}
ENV GITBRANCH {{ .GitBranch }}
{{ if .cross }}
RUN script/gox_build.sh
{{ else }}
RUN script/go_build.sh
{{ end }}
# export Pumba binary
EXPORT dist/bin/pumba
# tag builder image
TAG pumba/builder:local
# =======================
# package Pumba
# =======================
FROM alpine:3.4
MAINTAINER Alexei Ledenev <[email protected]>
LABEL com.gaiaadm.pumba=true
RUN addgroup pumba && adduser -s /bin/bash -D -G pumba pumba
ENV GOSU_VERSION 1.10
RUN apk add --no-cache --virtual .gosu-deps dpkg gnupg openssl ca-certificates wget \
&& arch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$arch" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$arch.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver-options http-proxy=$http_proxy --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true \
&& apk del .gosu-deps
IMPORT pumba /usr/bin/pumba
COPY docker_entrypoint.sh /
RUN chmod +x /docker_entrypoint.sh
ENTRYPOINT ["/docker_entrypoint.sh"]
CMD ["pumba", "--help"]
LABEL org.label-schema.vcs-ref={{ .GitCommit }} \
org.label-schema.vcs-url="https://github.com/gaia-adm/pumba"
TAG pumba/pumba:local