A Docker image with kubectl/terraform/cloud-sdk/etc.

main
Ezekiel Grave 2021-09-15 10:03:00 -07:00
commit d3c8c94289
5 changed files with 109 additions and 0 deletions

66
Dockerfile Normal file
View File

@ -0,0 +1,66 @@
# https://hub.docker.com/r/hashicorp/terraform/tags
FROM hashicorp/terraform:latest as terraform
# https://hub.docker.com/r/google/cloud-sdk/tags
FROM google/cloud-sdk:alpine as gcloud
RUN gcloud components update \
&& gcloud components install kubectl
FROM golang:alpine as gobuilder
RUN apk add --no-cache --update git
RUN git clone --depth 1 https://github.com/abetterinternet/prio-server src/github.com/abetterinternet/prio-server
RUN cd src/github.com/abetterinternet/prio-server/deploy-tool && go build
FROM alpine:latest as builder
RUN apk add --no-cache --update bash curl gcc cmake make python3-dev libffi-dev musl-dev openssl openssl-dev \
&& ln -snf `which python3` /bin/python \
&& ln -snf `which pip3` /bin/pip
RUN addgroup -g 1000 -S clouder && adduser -u 1000 -h /home/clouder -S clouder -G clouder
RUN mkdir -p /opt/clouder/bin && chown -cR clouder:clouder /opt/clouder
RUN mkdir -p /opt/aws-cli && chown -cR clouder:clouder /opt/aws-cli
USER clouder
RUN python -mvenv /opt/aws-cli
RUN /opt/aws-cli/bin/pip install --upgrade pip setuptools wheel
RUN /opt/aws-cli/bin/pip install --upgrade --upgrade-strategy eager \
https://github.com/boto/botocore/archive/v2.zip \
https://github.com/aws/aws-cli/archive/v2.zip
ENV DESIRED_VERSION=v3.6.3
RUN curl --progress-bar -fSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 \
| HELM_INSTALL_DIR=/opt/clouder/bin USE_SUDO=false PATH="${PATH}:/opt/clouder/bin" bash
FROM alpine:latest
LABEL maintainer="Ezekiel Grave <docker@reg.ici.de.com>"
RUN apk add --no-cache --update curl make git gnupg jq ncurses openssh-client openssl python3 \
&& ln -snf `which python3` /bin/python
RUN addgroup -g 1000 -S clouder && adduser -u 1000 -h /home/clouder -S clouder -G clouder
RUN mkdir -p /opt/clouder/bin && chown -cR clouder:clouder /opt/clouder
COPY --from=terraform --chown=clouder:clouder /bin/terraform /opt/clouder/bin/terraform
COPY --from=gcloud /google-cloud-sdk /opt/google-cloud-sdk
COPY --from=gobuilder --chown=clouder:clouder /go/src/github.com/abetterinternet/prio-server/deploy-tool/deploy-tool /opt/clouder/bin/deploy-tool
COPY --from=builder --chown=clouder:clouder /opt/clouder/bin /opt/clouder/bin
COPY --from=builder --chown=clouder:clouder /opt/aws-cli /opt/aws-cli
RUN chown -cR clouder:clouder /opt/clouder \
&& chmod u+x /opt/clouder/bin/*
ENV PATH="/opt/clouder/bin:${PATH}:/opt/google-cloud-sdk/bin:/opt/aws-cli/bin"
WORKDIR /home/clouder
USER clouder
RUN helm repo add stable https://charts.helm.sh/stable
RUN gcloud config set core/disable_usage_reporting true \
&& gcloud config set component_manager/disable_update_check true \
&& gcloud config set metrics/environment github_docker_image \
&& gcloud --version
VOLUME /home/clouder
CMD ["/bin/ash"]

10
README.md Normal file
View File

@ -0,0 +1,10 @@
# Kubernetes Tools with Terraform and Cloud SDKs (gcp/aws)
**To Build**:
`$ ./run/build`
**To Review**:
`$ ./run/check-versions`
### AWS cli version
The mechanism used to install AWS CLI is a dirty trick which may break.

3
run/build Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
docker build -t "hub.ici.de.com/kubeterracloud:latest" .

25
run/check-versions Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
BIN_VER_PAIRS=(
"terraform@--version"
"kubectl@version"
"gcloud@--version"
"aws@--version"
"helm@version"
"python@--version"
"jq@--version"
"curl@--version"
"git@--version"
"openssl@version"
)
time {
for bin_ver in "${BIN_VER_PAIRS[@]}"; do
bin="${bin_ver%%@*}"
ver="${bin_ver##*@}"
echo -n "Version report from ${bin}: "
docker run --rm \
--interactive --tty "hub.ici.de.com/kubeterracloud:latest" ${bin} ${ver}\
| awk 'NR!=1 { $0="\t"$0 }{ print }'
done
}

5
run/push Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
docker login -u ezekiel hub.ici.de.com\
&& docker push "hub.ici.de.com/kubeterracloud:latest"
docker logout hub.ici.de.com