Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile to reduce image size #172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 46 additions & 31 deletions build/Dockerfile
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"]