Skip to content

Instantly share code, notes, and snippets.

@huseyinbabal
Created September 27, 2023 11:29
Show Gist options
  • Save huseyinbabal/289042af583210544bb4ac5a2989b8ea to your computer and use it in GitHub Desktop.
Save huseyinbabal/289042af583210544bb4ac5a2989b8ea to your computer and use it in GitHub Desktop.
kubectl, krew, nodejs docker image

Dockerfile

# Use the official Docker image as a parent image
FROM docker:latest

# Install dependencies
RUN apk add --no-cache \
    curl \
    git \
    bash \
    nodejs \
    npm

# Install kubectl
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
    && chmod +x kubectl \
    && mv kubectl /usr/local/bin/

# Install Krew
RUN ( set -x; cd "$(mktemp -d)" && \
    curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/krew.tar.gz" && \
    tar zxvf krew.tar.gz && \
    KREW=./krew-"$(uname | tr '[:upper:]' '[:lower:]')_amd64" && \
    "$KREW" install krew )

# Add Krew to the PATH
ENV PATH="${PATH}:/root/.krew/bin"

# Verify installations
RUN docker --version
RUN kubectl version --client
RUN node --version
RUN npm --version

# Your application code or other setup steps can go here...

CMD [ "bash" ]

Build

docker build -t myimage .
docker run -it --rm myimage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment