Skip to content

Instantly share code, notes, and snippets.

@Ralim

Ralim/Dockerfile Secret

Created January 12, 2023 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ralim/e6de7face05746134d1173414c77716d to your computer and use it in GitHub Desktop.
Save Ralim/e6de7face05746134d1173414c77716d to your computer and use it in GitHub Desktop.
Docker files for K8S kubespray
version: "3"
services:
k8s-setup:
stdin_open: true
tty: true
build:
context: .
command: /bin/bash
volumes:
- ./src:/home/pleb/src/src
- /tmp:/tmp
FROM ubuntu:22.04
RUN apt-get update && apt-get upgrade -y && apt-get -y install python3 python3-pip git curl wget nano bash sshpass
RUN mkdir -p /home/pleb
# Create an app user so our program doesn't run as root.
RUN groupadd -r pleb &&\
useradd -g pleb -d /home/pleb -s /sbin/nologin -c "Docker" pleb
# Set the home directory to our pleb user's home.
ENV HOME=/home/pleb
ENV APP_HOME=/home/pleb/src
## SETTING UP THE APP ##
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
RUN chown -R pleb:pleb $HOME
USER pleb
# Pull in kubespray
RUN git clone https://github.com/kubernetes-incubator/kubespray.git --recursive && cd kubespray && git pull && git reset --hard v2.20.0
RUN cd kubespray && pip install --user -r requirements.txt
RUN cd kubespray && sed -i 's/- python-apt/- python3-apt\n - open-iscsi/g' roles/kubernetes/preinstall/vars/debian.yml
RUN cd kubespray && sed -i 's/- aufs-tools/- nfs-common/g' roles/kubernetes/preinstall/vars/debian.yml
COPY --chown=pleb:pleb ./src /home/pleb/src/src
ENV PATH="$HOME/.local/bin:$PATH"
# Default into our src folder
WORKDIR $APP_HOME/src
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment