From 99f2d07b9ba35d13b77ab01decf53dbad5905bb0 Mon Sep 17 00:00:00 2001 From: Drew Yang Date: Tue, 17 May 2022 10:51:53 -0500 Subject: [PATCH] update images --- .gitignore | 4 ++- dist/alpine/Dockerfile | 13 ++++---- dist/alpine/docker-compose.yml | 12 +++----- dist/debian/Dockerfile | 56 ++++++++++++++++++++++++++++++++++ dist/debian/docker-compose.yml | 16 ++++++++++ 5 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 dist/debian/Dockerfile create mode 100644 dist/debian/docker-compose.yml diff --git a/.gitignore b/.gitignore index 600d2d3..1f93157 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -.vscode \ No newline at end of file +.vscode +.env +.DS_Store diff --git a/dist/alpine/Dockerfile b/dist/alpine/Dockerfile index 364078d..259b0fb 100644 --- a/dist/alpine/Dockerfile +++ b/dist/alpine/Dockerfile @@ -2,16 +2,15 @@ FROM python:3.8-alpine3.12 as k8s_build ARG KOPS_VERSION ARG HELM_VERSION RUN \ - mkdir /main && \ + set -x; > /etc/inittab && mkdir /main && \ apk update && \ # export functions, for download, json parsing, ssh keygen, api keygen - apk add --no-cache bash curl jq openssh openssl && \ + apk add --no-cache bash curl jq openssh openssl util-linux bind-tools && \ # for aws cli, yaml parsing pip install awscli --upgrade --user --no-cache-dir && \ - # YQ (last verified was 3.4.0) - curl -L $(echo "https://github.com/mikefarah/yq/releases/download/\ - $(curl https://api.github.com/repos/mikefarah/yq/releases/latest | jq -r '.tag_name')/\ - yq_linux_amd64" | tr -d '\n' | tr -d '\t') -o /usr/local/bin/yq && \ + # YQ (v4 needs migration) + curl -L "https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64" \ + -o /usr/local/bin/yq && \ chmod +x /usr/local/bin/yq && \ # KOPS curl -L $(echo "https://github.com/kubernetes/kops/releases/download/${KOPS_VERSION}\ @@ -54,4 +53,4 @@ ENV PATH "/root/.local/bin:$PATH" WORKDIR /main VOLUME /main SHELL ["/bin/bash", "-lc"] -CMD ["/bin/bash"] \ No newline at end of file +CMD ["/bin/bash"] diff --git a/dist/alpine/docker-compose.yml b/dist/alpine/docker-compose.yml index 1182ed1..5985ced 100644 --- a/dist/alpine/docker-compose.yml +++ b/dist/alpine/docker-compose.yml @@ -1,18 +1,16 @@ version: '2.4' services: app: - build: # Uncomment to enable local build + build: + # Uncomment to enable local build context: ../.. dockerfile: ./dist/alpine/Dockerfile args: - KOPS_VERSION - HELM_VERSION - image: vathes/k8s-admin:kops${KOPS_VERSION}-helm${HELM_VERSION}-alpine - command: + image: registry.vathes.com/vathes/k8s-admin:kops${KOPS_VERSION}-helm${HELM_VERSION}-alpine + command: - bash - -c - > - echo "$$0 running..."; - echo "PATH: '$$PATH'"; - tail -f /dev/null; - \ No newline at end of file + echo "$$0 running..."; echo "PATH: '$$PATH'"; tail -f /dev/null; diff --git a/dist/debian/Dockerfile b/dist/debian/Dockerfile new file mode 100644 index 0000000..a0f7cac --- /dev/null +++ b/dist/debian/Dockerfile @@ -0,0 +1,56 @@ +FROM python:3.8-bullseye as k8s_build +ARG KOPS_VERSION +ARG HELM_VERSION +RUN \ + set -x; > /etc/inittab && mkdir /main && \ + apt update && \ + # export functions, for download, json parsing, ssh keygen, api keygen + apt add --no-cache bash curl jq openssh openssl util-linux bind-tools && \ + # for aws cli, yaml parsing + pip install awscli --upgrade --user --no-cache-dir && \ + # YQ (v4 needs migration) + curl -L "https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64" \ + -o /usr/local/bin/yq && \ + chmod +x /usr/local/bin/yq && \ + # KOPS + curl -L $(echo "https://github.com/kubernetes/kops/releases/download/${KOPS_VERSION}\ + /kops-linux-amd64" | tr -d '\n' | tr -d '\t') -o /usr/local/bin/kops && \ + chmod +x /usr/local/bin/kops && \ + # KUBECTL + mkdir ${HOME}/.kube && \ + curl -L $(echo "https://storage.googleapis.com/kubernetes-release/release/\ + $(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)\ + /bin/linux/amd64/kubectl" | tr -d '\n' | tr -d '\t') -o /usr/local/bin/kubectl && \ + chmod +x /usr/local/bin/kubectl && \ + # HELM + curl -L https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz \ + -o /tmp/helm.tar.gz && \ + tar -zxvf /tmp/helm.tar.gz --strip-components=1 -C /usr/local/bin/ linux-amd64/helm && \ + rm /tmp/helm.tar.gz && \ + chmod +x /usr/local/bin/helm && \ + [ ! "${HELM_VERSION}" == "v2.14.1" ] || helm init --history-max 200 --client-only && \ + [ ! "${HELM_VERSION}" == "v3.3.0" ] || helm repo add stable \ + https://kubernetes-charts.storage.googleapis.com/ && \ + ## ------- OPTIONAL ------- + # AWS IAM AUTHENTICATOR CLIENT + curl -L $(echo "https://github.com/kubernetes-sigs/aws-iam-authenticator/releases\ + /download/v0.5.1/aws-iam-authenticator_0.5.1_linux_amd64" | tr -d '\n' | tr -d '\t') \ + -o /usr/local/bin/aws-iam-authenticator && \ + chmod +x /usr/local/bin/aws-iam-authenticator && \ + # BASH Shell Prompt + echo "export PATH=/root/.local/bin:${PATH}" > /etc/profile.d/env.sh && \ + echo $(echo 'export PS1="\[\e[32;1m\]\u\[\e[m\]@\[\e[34;1m\]\H\[\e[m\]:\ + \[\e[33;1m\]\w\[\e[m\]$ "' | tr -d '\n' | tr -d '\t') > /root/.bashrc +ENV PATH "/root/.local/bin:$PATH" + +# #Squashed Final Image +FROM scratch +COPY --from=k8s_build / / +LABEL maintainerName="Raphael Guzman" \ + maintainerEmail="raphael@vathes.com" \ + maintainerCompany="DataJoint" +ENV PATH "/root/.local/bin:$PATH" +WORKDIR /main +VOLUME /main +SHELL ["/bin/bash", "-lc"] +CMD ["/bin/bash"] diff --git a/dist/debian/docker-compose.yml b/dist/debian/docker-compose.yml new file mode 100644 index 0000000..358173f --- /dev/null +++ b/dist/debian/docker-compose.yml @@ -0,0 +1,16 @@ +version: '2.4' +services: + app: + build: + # Uncomment to enable local build + context: ../.. + dockerfile: ./dist/alpine/Dockerfile + args: + - KOPS_VERSION + - HELM_VERSION + image: registry.vathes.com/vathes/k8s-admin:kops${KOPS_VERSION}-helm${HELM_VERSION}-debian + command: + - bash + - -c + - > + echo "$$0 running..."; echo "PATH: '$$PATH'"; tail -f /dev/null;