Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
Use Dockerfile for devcontainers + prebuild (#817)
Browse files Browse the repository at this point in the history
* Added Dockerfile and added build to devcontainer

* Changed codespace image to k3d-rust

* Updated remoteUser and Dockerfile

* Changed name in devcontainer

* Added eof newline in Dockerfile
  • Loading branch information
rcaseymsft authored Sep 21, 2022
1 parent 751cc66 commit 0ae86a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 82 deletions.
87 changes: 9 additions & 78 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,81 +1,12 @@
FROM mcr.microsoft.com/vscode/devcontainers/universal:1
# this image is built and updated weekly
# https://github.com/cse-labs/codespaces-images

# We intentionally use multiple layers small so that startup is faster with parallel pull
#checkov:skip=CKV_DOCKER_2: No healthcheck is needed
#checkov:skip=CKV_DOCKER_3: No user is needed
#checkov:skip=CKV_DOCKER_5: Update is used in same line as upgrade
#checkov:skip=CKV_DOCKER_7: Alright to use "latest" tag

# install packages
RUN export DEBIAN_FRONTEND=noninteractive && \
sudo apt-get update
RUN sudo apt-get -y install --no-install-recommends apt-utils dialog
RUN sudo apt-get -y install --no-install-recommends apt-transport-https ca-certificates
RUN sudo apt-get -y install --no-install-recommends curl git wget nano bash-completion
RUN sudo apt-get -y install --no-install-recommends software-properties-common make
RUN sudo apt-get -y install --no-install-recommends jq
RUN sudo apt-get -y install --no-install-recommends httpie
RUN sudo apt-get -y install --no-install-recommends iputils-ping
FROM ghcr.io/cse-labs/k3d:latest

# install k9s, github cli, jp and fluxctl
RUN sudo curl -Lo ./k9s.tar.gz https://github.com/derailed/k9s/releases/download/v0.24.2/k9s_Linux_x86_64.tar.gz && \
sudo mkdir k9s && \
sudo tar xvzf k9s.tar.gz -C ./k9s && \
sudo mv ./k9s/k9s /usr/local/bin/k9s && \
sudo rm -rf k9s.tar.gz k9s

RUN VERSION=$(curl -i https://github.com/jmespath/jp/releases/latest | grep "location: https://github.com/" | rev | cut -f 1 -d / | rev | sed 's/\r//') && \
sudo wget https://github.com/jmespath/jp/releases/download/$VERSION/jp-linux-amd64 -O /usr/local/bin/jp && \
sudo chmod +x /usr/local/bin/jp && \
sudo wget https://github.com/cli/cli/releases/download/v1.10.3/gh_1.10.3_linux_amd64.deb && \
sudo dpkg -i gh_1.10.3_linux_amd64.deb && \
sudo rm gh_1.10.3_linux_amd64.deb

RUN kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null && \
sudo curl -L https://github.com/fluxcd/flux/releases/download/1.14.2/fluxctl_linux_amd64 -o /usr/local/bin/fluxctl && \
sudo chmod +x /usr/local/bin/fluxctl && \
sudo apt-get install -f

# use multiple layers for updates
RUN sudo apt-get install -y azure-cli
RUN sudo apt-get install -y python3
RUN sudo apt-get upgrade -y

# install oh-my-bash
RUN cd $HOME && \
OSH=$HOME/.oh-my-bash && \
rm -rf $OSH && \
git clone --depth=1 https://github.com/ohmybash/oh-my-bash $OSH && \
cp $OSH/templates/bashrc.osh-template $HOME/.bashrc && \
sed "/^export OSH=/ c\\export OSH=$OSH" $HOME/.bashrc > $HOME/.bashrc-ombtemp && \
mv -f $HOME/.bashrc-ombtemp $HOME/.bashrc

# create directories, update .bashrc, config git
RUN mkdir -p $HOME/.ssh && \
mkdir -p $HOME/.kube && \
mkdir -p $HOME/bin && \
mkdir -p $HOME/.local/bin && \
mkdir -p $HOME/.k9s && \
mkdir -p $HOME/go/src && \
mkdir -p $HOME/.dotnet/tools && \
echo >> $HOME/.bashrc && \
echo 'export PATH=$PATH:$HOME/.local/bin:$HOME/.dotnet/tools' >> $HOME/.bashrc && \
echo "alias k='kubectl'" >> $HOME/.bashrc && \
echo "alias kga='kubectl get all'" >> $HOME/.bashrc && \
echo "alias kgaa='kubectl get all --all-namespaces'" >> $HOME/.bashrc && \
echo "alias kaf='kubectl apply -f'" >> $HOME/.bashrc && \
echo "alias kdelf='kubectl delete -f'" >> $HOME/.bashrc && \
echo "alias kl='kubectl logs'" >> $HOME/.bashrc && \
echo "alias kccc='kubectl config current-context'" >> $HOME/.bashrc && \
echo "alias kcgc='kubectl config get-contexts'" >> $HOME/.bashrc && \
echo "alias kj='kubectl exec -it jumpbox -- bash -l'" >> $HOME/.bashrc && \
echo "alias kje='kubectl exec -it jumpbox -- '" >> $HOME/.bashrc && \
echo >> $HOME/.bashrc && \
echo "alias ipconfig='ip -4 a show eth0 | grep inet | sed \"s/inet//g\" | sed \"s/ //g\" | cut -d / -f 1'" >> $HOME/.bashrc && \
echo >> $HOME/.bashrc && \
echo "export FLUX_FORWARD_NAMESPACE=flux-cd" >> $HOME/.bashrc && \
echo "export GO111MODULE=on" >> $HOME/.bashrc && \
echo 'export PIP=$(ipconfig | tail -n 1)' >> $HOME/.bashrc && \
echo >> $HOME/.bashrc && \
echo 'complete -F __start_kubectl k' >> $HOME/.bashrc && \
dotnet tool install -g webvalidate && \
git config --global core.whitespace blank-at-eol,blank-at-eof,space-before-tab && \
git config --global pull.rebase false && \
git config --global init.defaultbranch main && \
git config --global core.pager more
# some images require specific values
ARG USERNAME=vscode
7 changes: 3 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "ASB-Ngsa",
"image": "ghcr.io/retaildevcrews/asb:latest",
//"build": { "dockerfile": "Dockerfile" },
"name": "Ngsa",
"build": { "dockerfile": "Dockerfile" },
"runArgs": [ "--init", "--privileged" ],
"overrideCommand": false,

// Set *default* container specific settings.json values on container create.
"settings": { },

"remoteUser": "codespace",
"remoteUser": "vscode",

"forwardPorts": [],

Expand Down

0 comments on commit 0ae86a1

Please sign in to comment.