-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Dockerfile to reduce image size
- Loading branch information
1 parent
787c7aa
commit 770e065
Showing
1 changed file
with
46 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,46 @@ | ||
FROM golang:1.14.2 | ||
|
||
LABEL maintainer="LitmusChaos" | ||
|
||
RUN apt-get update && apt-get install -y git && \ | ||
apt-get install -y ssh && \ | ||
apt install ssh rsync | ||
|
||
ARG KUBECTL_VERSION=1.18.0 | ||
|
||
#setup go envs | ||
ENV GO111MODULE=off | ||
ENV GOPATH=$HOME/go | ||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin | ||
|
||
#Installing helm | ||
RUN wget https://get.helm.sh/helm-v3.4.0-linux-amd64.tar.gz && \ | ||
tar -zxvf helm-v3.4.0-linux-amd64.tar.gz && \ | ||
mv linux-amd64/helm /usr/local/bin/helm | ||
|
||
#Install kubectl | ||
ADD https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl /usr/local/bin/kubectl | ||
RUN chmod +x /usr/local/bin/kubectl | ||
|
||
#copying binaries | ||
COPY build/_output ./ | ||
COPY litmus/helm-install.sh ./ | ||
COPY build/experiment_entrypoint.sh ./ | ||
|
||
#overwrite entrypoint with test binary | ||
ENTRYPOINT ["./all-experiments"] | ||
FROM golang:alpine AS builder | ||
|
||
# Set Go environment variables | ||
ENV GO111MODULE=off | ||
ENV GOPATH=/go | ||
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin | ||
|
||
# Install dependencies and cleanup | ||
RUN apk update && \ | ||
apk add --no-cache \ | ||
git \ | ||
wget \ | ||
tar | ||
|
||
# Install Helm | ||
RUN wget https://get.helm.sh/helm-v3.4.0-linux-amd64.tar.gz && \ | ||
tar -zxvf helm-v3.4.0-linux-amd64.tar.gz && \ | ||
mv linux-amd64/helm /usr/local/bin/helm && \ | ||
rm -rf helm-v3.4.0-linux-amd64.tar.gz linux-amd64 | ||
|
||
# Install kubectl | ||
RUN wget https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl -O /usr/local/bin/kubectl && \ | ||
chmod +x /usr/local/bin/kubectl | ||
|
||
# Copy and build the binaries | ||
COPY build/_output /app/_output | ||
COPY litmus/helm-install.sh /app/ | ||
COPY build/experiment_entrypoint.sh /app/ | ||
|
||
FROM alpine:latest | ||
|
||
# Install runtime dependencies | ||
RUN apk update && \ | ||
apk add --no-cache \ | ||
openssh-client | ||
|
||
# Copy only the necessary files from the build stage | ||
COPY --from=builder /app /app | ||
COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/kubectl | ||
COPY --from=builder /usr/local/bin/helm /usr/local/bin/helm | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Override entrypoint with test binary | ||
ENTRYPOINT ["./all-experiments"] |