forked from bitpoke/mysql-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.sidecar
71 lines (56 loc) · 3.08 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
###############################################################################
# Build the mysql-oerator related binaries
###############################################################################
FROM golang:1.13.14 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
RUN wget -nv https://github.com/ncw/rclone/releases/download/v1.48.0/rclone-v1.48.0-linux-amd64.zip \
&& wget -nv https://github.com/ncw/rclone/releases/download/v1.48.0/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:stretch-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 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 stretch main' > /etc/apt/sources.list.d/percona.list
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
percona-toolkit percona-xtrabackup-24 unzip \
&& wget https://github.com/maxbube/mydumper/releases/download/v0.9.5/mydumper_0.9.5-2.stretch_amd64.deb \
&& dpkg -i mydumper_0.9.5-2.stretch_amd64.deb \
&& rm -rf mydumper_0.9.5-2.stretch_amd64.deb /var/lib/apt/lists/* \
&& mkdir -p /usr/share/src \
&& wget https://github.com/maxbube/mydumper/archive/v0.9.5.tar.gz -O /usr/share/src/mydumper-v0.9.5.tar.gz
USER mysql
# Copy the mysql-operator-sidecar into its own image
COPY ./hack/docker/sidecar-entrypoint.sh /usr/local/bin/sidecar-entrypoint.sh
COPY --from=builder /go/src/github.com/presslabs/mysql-operator/mysql-operator-sidecar /usr/local/bin/mysql-operator-sidecar
COPY --from=rclone /usr/local/bin/rclone /usr/local/bin/rclone
ENTRYPOINT ["/usr/local/bin/sidecar-entrypoint.sh"]