forked from flant/shell-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-alpine3.9
45 lines (38 loc) · 1.39 KB
/
Dockerfile-alpine3.9
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
# build libjq
FROM alpine:3.9 AS libjq
RUN apk --no-cache add git ca-certificates && \
git clone https://github.com/flant/libjq-go /libjq-go && \
cd /libjq-go && \
git submodule update --init --recursive && \
/libjq-go/scripts/install-libjq-dependencies-alpine.sh && \
/libjq-go/scripts/build-libjq-static.sh /libjq-go /libjq
# build shell-operator binary
FROM golang:1.12-alpine3.9 AS shell-operator
ARG appVersion=latest
RUN apk --no-cache add git ca-certificates gcc libc-dev
# Cache-friendly download of go dependencies.
ADD go.mod go.sum /src/shell-operator/
WORKDIR /src/shell-operator
RUN go mod download
COPY --from=libjq /libjq /libjq
ADD . /src/shell-operator
RUN CGO_ENABLED=1 \
CGO_CFLAGS="-I/libjq/include" \
CGO_LDFLAGS="-L/libjq/lib" \
GOOS=linux \
go build -ldflags="-s -w -X 'github.com/flant/shell-operator/pkg/app.Version=$appVersion'" \
-o shell-operator \
./cmd/shell-operator
# build final image
FROM alpine:3.9
RUN apk --no-cache add ca-certificates jq bash sed tini && \
wget https://storage.googleapis.com/kubernetes-release/release/v1.17.4/bin/linux/amd64/kubectl -O /bin/kubectl && \
chmod +x /bin/kubectl && \
mkdir /hooks
ADD frameworks /
COPY --from=shell-operator /src/shell-operator /
WORKDIR /
ENV SHELL_OPERATOR_HOOKS_DIR /hooks
ENV LOG_TYPE json
ENTRYPOINT ["/sbin/tini", "--", "/shell-operator"]
CMD ["start"]