This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 88
/
Rockerfile
68 lines (47 loc) · 1.7 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
{{ $commit := (or .Env.GIT_COMMIT "") }}
{{ $branch := (or .Env.GIT_BRANCH "none") }}
{{ $version:= (or .Version "local") }}
FROM golang:1.8.3-alpine
# Golang build cache
MOUNT /go/pkg/linux_amd64 /usr/local/go/pkg/linux_amd64
ADD . /go/src/github.com/grammarly/rocker
WORKDIR /go/src/github.com/grammarly/rocker
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO15VENDOREXPERIMENT=1
RUN go install \
-a -v -installsuffix cgo \
-ldflags "-X main.Version={{$version}} -X main.GitCommit={{$commit}} -X main.GitBranch={{$branch}} -X main.BuildTime=$(TZ=GMT date '+%Y-%m-%d_%H:%M_GMT')"
{{ if .test }}
MOUNT /var/run/docker.sock:/var/run/docker.sock
MOUNT ~/.docker:/root/.docker
RUN apk --update add make git bash docker
{{ if .TestArgs }}
ENV TESTARGS="{{ .TestArgs }}"
{{ end }}
ATTACH ["bash"]
RUN make test
RUN make test_integration
{{ end }}
EXPORT /go/bin/rocker
#========
FROM alpine:3.8
RUN apk --update add git bash
RUN set -ex; \
apk add --update --no-cache --virtual .fetch-deps curl tar ; \
if ! curl -fL -o /docker.tgz "https://get.docker.com/builds/Linux/x86_64/docker-1.9.1.tgz"; then \
echo >&2 "error: failed to download 'docker-18.06.0-ce' from 'stable' for 'x86_64'"; \
exit 1; \
fi; \
\
tar --extract --file /docker.tgz; \
rm /docker.tgz; \
apk del .fetch-deps;
RUN mkdir -p /opt/rocker/bin
IMPORT rocker /opt/rocker/bin
VOLUME ["/opt/rocker/bin"]
WORKDIR /context
ENV PATH=/opt/rocker/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
CMD ["/opt/rocker/bin/rocker"]
PUSH dockerhub.grammarly.io/rocker:{{ $branch }}
{{ if and (ne $version "local") (eq $branch "master") }}
PUSH dockerhub.grammarly.io/rocker:{{ $version }}
{{ end }}