forked from bitpoke/mysql-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.sidecar
74 lines (53 loc) · 2.83 KB
/
Dockerfile.sidecar
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
###############################################################################
# Build the mysql-oerator related binaries
###############################################################################
FROM golang:1.16.0 as builder
# Copy in the go src
WORKDIR /go/src/github.com/presslabs/mysql-operator
COPY pkg/ pkg/
COPY cmd/ cmd/
COPY go.mod go.sum ./
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o mysql-operator github.com/presslabs/mysql-operator/cmd/mysql-operator
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o mysql-operator-sidecar github.com/presslabs/mysql-operator/cmd/mysql-operator-sidecar
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o orc-helper github.com/presslabs/mysql-operator/cmd/orc-helper
###############################################################################
# Build rclone
###############################################################################
FROM debian:stretch as rclone
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gnupg ca-certificates wget unzip
COPY hack/docker/rclone.gpg /root/rclone.gpg
RUN gpg --import /root/rclone.gpg
ENV RCLONE_VERSION=1.53.1
RUN wget -nv https://github.com/ncw/rclone/releases/download/v${RCLONE_VERSION}/rclone-v${RCLONE_VERSION}-linux-amd64.zip \
&& wget -nv https://github.com/ncw/rclone/releases/download/v${RCLONE_VERSION}/SHA256SUMS \
&& gpg --verify --output=- SHA256SUMS > sums \
&& sha256sum -c --ignore-missing sums \
&& unzip rclone-*-linux-amd64.zip \
&& mv rclone-*-linux-amd64/rclone /usr/local/bin/ \
&& chmod 755 /usr/local/bin/rclone
###############################################################################
# Docker image for sidecar containers
###############################################################################
FROM debian:buster-slim as sidecar
RUN groupadd -g 999 mysql
RUN useradd -u 999 -r -g 999 -s /sbin/nologin \
-c "Default Application User" mysql
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https ca-certificates pigz wget \
&& rm -rf /var/lib/apt/lists/*
COPY hack/docker/percona.gpg /etc/apt/trusted.gpg.d/percona.gpg
RUN echo 'deb https://repo.percona.com/apt buster main' > /etc/apt/sources.list.d/percona.list
ARG XTRABACKUP_PKG=percona-xtrabackup-24
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
percona-toolkit ${XTRABACKUP_PKG} unzip default-mysql-client
USER mysql
COPY --from=rclone /usr/local/bin/rclone /usr/local/bin/rclone
# Copy the mysql-operator-sidecar into its own image
COPY --from=builder /go/src/github.com/presslabs/mysql-operator/mysql-operator-sidecar /usr/local/bin/mysql-operator-sidecar
COPY ./hack/docker/sidecar-entrypoint.sh /usr/local/bin/sidecar-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/sidecar-entrypoint.sh"]