1
1
# Multi-stage docker build
2
2
# Build stage
3
- FROM golang:1.18 AS builder
3
+ FROM golang:1.20 AS builder
4
4
5
5
ARG TARGETOS=linux
6
6
ARG TARGETARCH
@@ -14,27 +14,98 @@ RUN export GOOS=${TARGETOS} && \
14
14
RUN CGO_ENABLED=0 go build -o /output/experiments ./bin/experiment
15
15
RUN CGO_ENABLED=0 go build -o /output/helpers ./bin/helper
16
16
17
- FROM alpine:3.15.0 AS dep
17
+ # Packaging stage
18
+ FROM registry.access.redhat.com/ubi9/ubi:9.4
19
+
20
+ LABEL maintainer="LitmusChaos"
21
+
22
+ ARG TARGETARCH
23
+ ARG LITMUS_VERSION
18
24
19
25
# Install generally useful things
20
- RUN apk --update add \
21
- sudo \
22
- iproute2 \
23
- iptables
26
+ RUN yum install -y \
27
+ sudo \
28
+ sshpass \
29
+ procps
30
+
31
+ # tc binary
32
+ RUN yum install -y https://dl.rockylinux.org/pub/rocky/9/devel/$(uname -m)/os/Packages/i/iproute-6.2.0-6.el9_4.$(uname -m).rpm
33
+ RUN yum install -y https://dl.rockylinux.org/pub/rocky/9/devel/$(uname -m)/os/Packages/i/iproute-tc-6.2.0-6.el9_4.$(uname -m).rpm
34
+
35
+ # iptables
36
+ RUN yum install -y https://dl.rockylinux.org/pub/rocky/9/devel/$(uname -m)/os/Packages/i/iptables-libs-1.8.10-2.el9.$(uname -m).rpm
37
+ RUN yum install -y https://dl.fedoraproject.org/pub/epel/9/Everything/$(uname -m)/Packages/i/iptables-legacy-libs-1.8.10-2.2.el9.$(uname -m).rpm
38
+ RUN yum install -y https://dl.fedoraproject.org/pub/epel/9/Everything/$(uname -m)/Packages/i/iptables-legacy-1.8.10-2.2.el9.$(uname -m).rpm
24
39
40
+ # stress-ng
41
+ RUN yum install -y https://yum.oracle.com/repo/OracleLinux/OL9/appstream/$(uname -m)/getPackage/Judy-1.0.5-28.el9.$(uname -m).rpm
42
+ RUN yum install -y https://yum.oracle.com/repo/OracleLinux/OL9/appstream/$(uname -m)/getPackage/stress-ng-0.14.00-2.el9.$(uname -m).rpm
25
43
26
- # Packaging stage
27
- # Image source: https://github.com/litmuschaos/test-tools/blob/master/custom/hardened-alpine/experiment/Dockerfile
28
- # The base image is non-root (have litmus user) with default litmus directory.
29
- FROM litmuschaos/experiment-alpine
44
+ # Installing Kubectl
45
+ ENV KUBE_LATEST_VERSION= "v1.31.0"
46
+ RUN curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/${TARGETARCH}/kubectl -o /usr/bin/kubectl && \
47
+ chmod 755 /usr/bin/kubectl
30
48
31
- LABEL maintainer="LitmusChaos"
49
+ # Installing crictl binaries
50
+ RUN curl -L https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.31.1/crictl-v1.31.1-linux-${TARGETARCH}.tar.gz --output crictl-v1.31.1-linux-${TARGETARCH}.tar.gz && \
51
+ tar zxvf crictl-v1.31.1-linux-${TARGETARCH}.tar.gz -C /sbin && \
52
+ chmod 755 /sbin/crictl
53
+
54
+ # Installing promql cli binaries
55
+ RUN curl -L https://github.com/chaosnative/promql-cli/releases/download/3.0.0-beta6/promql_linux_${TARGETARCH} --output /usr/bin/promql && chmod 755 /usr/bin/promql
56
+
57
+ # Installing pause cli binaries
58
+ RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/pause-linux-${TARGETARCH} --output /usr/bin/pause && chmod 755 /usr/bin/pause
59
+
60
+ # Installing dns_interceptor cli binaries
61
+ RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/dns_interceptor --output /sbin/dns_interceptor && chmod 755 /sbin/dns_interceptor
62
+
63
+ # Installing nsutil cli binaries
64
+ RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/nsutil-linux-${TARGETARCH} --output /sbin/nsutil && chmod 755 /sbin/nsutil
32
65
33
- COPY --from=builder /output/ /litmus
34
- COPY --from=dep /usr/bin/sudo /usr/bin/sudo
35
- COPY --from=dep /usr/lib/sudo /usr/lib/sudo
36
- COPY --from=dep /sbin/tc /sbin/
37
- COPY --from=dep /sbin/iptables /sbin/
66
+ # Installing nsutil shared lib
67
+ RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/nsutil_${TARGETARCH}.so --output /usr/local/lib/nsutil.so && chmod 755 /usr/local/lib/nsutil.so
68
+
69
+ # Installing toxiproxy binaries
70
+ RUN curl -L https://litmus-http-proxy.s3.amazonaws.com/cli/cli/toxiproxy-cli-linux-${TARGETARCH}.tar.gz --output toxiproxy-cli-linux-${TARGETARCH}.tar.gz && \
71
+ tar zxvf toxiproxy-cli-linux-${TARGETARCH}.tar.gz -C /sbin/ && \
72
+ chmod 755 /sbin/toxiproxy-cli
73
+ RUN curl -L https://litmus-http-proxy.s3.amazonaws.com/server/server/toxiproxy-server-linux-${TARGETARCH}.tar.gz --output toxiproxy-server-linux-${TARGETARCH}.tar.gz && \
74
+ tar zxvf toxiproxy-server-linux-${TARGETARCH}.tar.gz -C /sbin/ && \
75
+ chmod 755 /sbin/toxiproxy-server
76
+
77
+ ENV APP_USER=litmus
78
+ ENV APP_DIR="/$APP_USER"
79
+ ENV DATA_DIR="$APP_DIR/data"
80
+
81
+ # The USERD_ID of user
82
+ ENV APP_USER_ID=2000
83
+ RUN useradd -s /bin/true -u $APP_USER_ID -m -d $APP_DIR $APP_USER
84
+
85
+ # change to 0(root) group because openshift will run container with arbitrary uid as a member of root group
86
+ RUN chgrp -R 0 "$APP_DIR" && chmod -R g=u "$APP_DIR"
87
+
88
+ # Giving sudo to all users (required for almost all experiments)
89
+ RUN echo 'ALL ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers
90
+
91
+ WORKDIR $APP_DIR
92
+
93
+ COPY --from=builder /output/ .
94
+
95
+ COPY --from=docker:27.0.3 /usr/local/bin/docker /sbin/docker
96
+ RUN chmod 755 /sbin/docker
97
+
98
+ # Set permissions and ownership for the copied binaries
99
+ RUN chmod 755 ./experiments ./helpers && \
100
+ chown ${APP_USER}:0 ./experiments ./helpers
101
+
102
+ # Set ownership for binaries in /sbin and /usr/bin
103
+ RUN chown ${APP_USER}:0 /sbin/* /usr/bin/* && \
104
+ chown root:root /usr/bin/sudo && \
105
+ chmod 4755 /usr/bin/sudo
38
106
39
107
# Copying Necessary Files
40
- COPY ./pkg/cloud/aws/common/ssm-docs/LitmusChaos-AWS-SSM-Docs.yml .
108
+ COPY ./pkg/cloud/aws/common/ssm-docs/LitmusChaos-AWS-SSM-Docs.yml ./LitmusChaos-AWS-SSM-Docs.yml
109
+ RUN chown ${APP_USER}:0 ./LitmusChaos-AWS-SSM-Docs.yml && chmod 755 ./LitmusChaos-AWS-SSM-Docs.yml
110
+
111
+ USER ${APP_USER}
0 commit comments