-
Notifications
You must be signed in to change notification settings - Fork 179
/
Dockerfile
95 lines (59 loc) · 2.91 KB
/
Dockerfile
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
## test ########################################################################
FROM golang:1.18 AS test
ARG DOCKER_ARCH=x86_64
ARG KUBECTL_ARCH=amd64
RUN curl -s https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-18.09.9.tgz | \
tar -C /usr/bin --strip-components 1 -xz
RUN curl -Ls https://storage.googleapis.com/kubernetes-release/release/v1.13.0/bin/linux/${KUBECTL_ARCH}/kubectl -o /usr/bin/kubectl && \
chmod +x /usr/bin/kubectl
RUN curl -Ls https://github.com/mattgreen/watchexec/releases/download/1.8.6/watchexec-1.8.6-x86_64-unknown-linux-gnu.tar.gz | \
tar -C /usr/bin --strip-components 1 -xz
WORKDIR /go/src/github.com/convox/rack
COPY . .
RUN go build -mod=vendor --ldflags="-s -w" $(go list -mod=vendor ./vendor/...)
## development #################################################################
FROM test AS development
# RUN curl -s https://download.docker.com/linux/static/stable/x86_64/docker-18.09.6.tgz | \
# tar -C /usr/bin --strip-components 1 -xz
# RUN curl -Ls https://storage.googleapis.com/kubernetes-release/release/v1.13.0/bin/linux/amd64/kubectl -o /usr/bin/kubectl && \
# chmod +x /usr/bin/kubectl
# RUN curl -Ls https://github.com/mattgreen/watchexec/releases/download/1.8.6/watchexec-1.8.6-x86_64-unknown-linux-gnu.tar.gz | \
# tar -C /usr/bin --strip-components 1 -xz
ENV DEVELOPMENT=true
# WORKDIR /go/src/github.com/convox/rack
# COPY vendor vendor
# RUN go install --ldflags="-s -w" ./vendor/...
# COPY . .
RUN make build
CMD ["bin/web"]
## package #####################################################################
FROM golang:1.18 AS package
RUN apt-get update && apt-get -y install upx-ucl
WORKDIR /go/src/github.com/convox/rack
COPY --from=development /go/src/github.com/convox/rack .
RUN make package build compress
## production ##################################################################
FROM ubuntu:22.04
ARG DOCKER_ARCH=x86_64
ARG KUBECTL_ARCH=amd64
RUN echo "$(uname -a)"
RUN apt-get -qq update && apt-get -qq -y install curl
ENV DOCKER_BUILDKIT=1
RUN curl -s https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-18.09.9.tgz | \
tar -C /usr/bin --strip-components 1 -xz
RUN curl -Ls https://storage.googleapis.com/kubernetes-release/release/v1.13.0/bin/linux/${KUBECTL_ARCH}/kubectl -o /usr/bin/kubectl && \
chmod +x /usr/bin/kubectl
ENV DEVELOPMENT=false
ENV GOPATH=/go
ENV PATH=$PATH:/go/bin
WORKDIR /rack
COPY --from=package /go/bin/atom /go/bin/
COPY --from=package /go/bin/build /go/bin/
COPY --from=package /go/bin/convox-env /go/bin/
COPY --from=package /go/bin/monitor /go/bin/
COPY --from=package /go/bin/rack /go/bin/
COPY --from=package /go/bin/router /go/bin/
# aws templates
COPY --from=development /go/src/github.com/convox/rack/provider/aws/formation/ provider/aws/formation/
COPY --from=development /go/src/github.com/convox/rack/provider/aws/templates/ provider/aws/templates/
CMD ["/go/bin/rack"]