From 8145903bbeebd0a49b837a3b6396e547fc1513b0 Mon Sep 17 00:00:00 2001 From: Lawrence Gripper Date: Thu, 24 Oct 2019 13:44:12 +0000 Subject: [PATCH 1/6] Update dev container to work on linux --- .devcontainer/Dockerfile | 36 +++++++++++++++++++++++++++++--- .devcontainer/devcontainer.json | 23 ++++++++++++++++---- .devcontainer/docker-compose.yml | 22 ------------------- Makefile | 3 --- go.sum | 6 ++++++ 5 files changed, 58 insertions(+), 32 deletions(-) delete mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2ae2840..7ce3300 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,11 +3,22 @@ # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. #------------------------------------------------------------------------------------------------------------- -FROM golang:1.12.5 +FROM golang:1.12.5-stretch # Avoid warnings by switching to noninteractive ENV DEBIAN_FRONTEND=noninteractive +# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux, +# this user's GID/UID must match your local user UID/GID to avoid permission issues +# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See +# https://aka.ms/vscode-remote/containers/non-root-user for details. +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +# Support docker connecting to the external docker daemon. On Nix the GID inside the container must match +# the GID of the docker group on the host. +ARG DOCKER_GROUP_ID=999 + # Configure apt, install packages and tools RUN apt-get update \ && apt-get -y install --no-install-recommends apt-utils 2>&1 \ @@ -44,10 +55,17 @@ RUN apt-get update \ github.com/golangci/golangci-lint/cmd/golangci-lint \ github.com/mgechev/revive \ github.com/derekparker/delve/cmd/dlv 2>&1 \ + # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. + && groupadd --gid $USER_GID $USERNAME \ + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ + # [Optional] Add sudo support + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME \ # Clean up && apt-get autoremove -y \ && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* RUN apt-get update \ # Install Docker CE CLI @@ -62,6 +80,9 @@ RUN apt-get update \ # Install Helm && curl -s https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash - +# Configure permissions for Docker without sudo +RUN groupadd --gid $DOCKER_GROUP_ID docker && gpasswd -a $USERNAME docker + # Verify git, process tools installed RUN apt-get -y install git procps wget nano zsh inotify-tools jq RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true @@ -73,7 +94,7 @@ ENV GO111MODULE=on # Set the default shell to bash instead of sh ENV DATABRICKS_HOST "" ENV DATABRICKS_TOKEN "" -ENV KUBECONFIG="/root/.kube/kind-config-kind" +ENV KUBECONFIG="/home/${USERNAME}/.kube/kind-config-kind" COPY ./Makefile ./ RUN make install-kind @@ -81,3 +102,12 @@ RUN make install-kubebuilder RUN make install-kustomize RUN make install-test-dependency ENV SHELL /bin/bash + +# Add useful aliases +RUN echo "alias k=kubectl" > "/home/${USERNAME}/.bash_aliases" +# Add autocomplete to kubectl +RUN echo "source <(kubectl completion bash)" > "/home/${USERNAME}/.bash_aliases" +RUN echo "source <(kubectl completion bash | sed 's/kubectl/k/g')" > "/home/${USERNAME}/.bash_aliases" + +# Configure persmissions for go directory +RUN chown -R $USER_GID /go diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f4d6935..5a85b74 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,17 +1,32 @@ // If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml. { "name": "Go", - "dockerComposeFile": "docker-compose.yml", - "service": "docker-in-docker", + "dockerFile": "./Dockerfile", "workspaceFolder": "/workspace", + "context": "..", + "workspaceMount": "src=${localWorkspaceFolder},dst=/workspace,type=bind", "postCreateCommand": "make set-kindcluster", - "shutdownAction": "stopCompose", + "runArgs": [ + // Uncomment the next line to use a non-root user. On Linux, this will prevent + // new files getting created as root, but you may need to update the USER_UID + // and USER_GID in .devcontainer/Dockerfile to match your user if not 1000. + "-u", "vscode", + + "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined", + // Mount docker socket for docker builds + "-v", "/var/run/docker.sock:/var/run/docker.sock", + "--network", "host", + "-e GO111MODULE=on", + // Mount azure + "-v", "${env:HOME}${env:USERPROFILE}/.azure:/home/vscode/.azure" + // Optionally mount k8s auth to existing cluster + // "-v", "${env:HOME}${env:USERPROFILE}/.kube:/home/vscode/.kube", + ], "extensions": [ "ms-azuretools.vscode-docker", "ms-vscode.go" ], "settings": { - "terminal.integrated.shell.linux": "zsh", "go.gopath": "/go", "go.inferGopath": true, "go.useLanguageServer": true, diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml deleted file mode 100644 index 1707c6b..0000000 --- a/.devcontainer/docker-compose.yml +++ /dev/null @@ -1,22 +0,0 @@ -version: '3' -services: - docker-in-docker: - build: - context: ../ - dockerfile: .devcontainer/Dockerfile - network_mode: "host" - volumes: - # Update this to wherever you want VS Code to mount the folder of your project - - ..:/workspace - - # This lets you avoid setting up Git again in the container - - ~/.gitconfig:/root/.gitconfig - - ~/.ssh:/root/.ssh:ro # does not work on Windows! Will need to generate in container :( - # Forwarding the socket is optional, but lets docker work inside the container if you install the Docker CLI. - # See the docker-in-docker-compose definition for details on how to install it. - - /var/run/docker.sock:/var/run/docker.sock - - # Overrides default command so things don't shut down after the process ends - useful for debugging - command: sleep infinity - env_file: - - .env \ No newline at end of file diff --git a/Makefile b/Makefile index 84d59ee..b100e23 100644 --- a/Makefile +++ b/Makefile @@ -134,9 +134,6 @@ endif kubectl cluster-info - @echo "deploying controller to cluster" - make deploy-controller - install-kind: ifeq (,$(shell which kind)) diff --git a/go.sum b/go.sum index 62bb335..9caba32 100644 --- a/go.sum +++ b/go.sum @@ -20,6 +20,7 @@ github.com/evanphx/json-patch v4.1.0+incompatible h1:K1MDoo4AZ4wU0GIU/fPmtZg7Vpz github.com/evanphx/json-patch v4.1.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M= github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -34,6 +35,7 @@ github.com/go-playground/log v6.3.0+incompatible/go.mod h1:3M1OvdKL8KYwOjJa3XM42 github.com/gobuffalo/envy v1.6.5/go.mod h1:N+GkhhZ/93bGZc6ZKhJLP6+m+tCNPKwgSpH9kaifseQ= github.com/gobuffalo/envy v1.6.15 h1:OsV5vOpHYUpP7ZLS6sem1y40/lNX1BZj+ynMiRi21lQ= github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/flect v0.1.5 h1:xpKq9ap8MbYfhuPCF0dBH854Gp9CxZjr/IocxELFflo= github.com/gobuffalo/flect v0.1.5/go.mod h1:W3K3X9ksuZfir8f/LrfVtWmCDQFfayuylOJ7sz/Fj80= github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -79,7 +81,9 @@ github.com/markbates/inflect v1.0.4 h1:5fh1gzTFhfae06u3hzHYO9xe3l3v3nW5Pwt3naLTP github.com/markbates/inflect v1.0.4/go.mod h1:1fR9+pO2KHEO9ZRtto13gDwwZaAKstQzferVeWqbgNs= github.com/matm/gocov-html v0.0.0-20160206185555-f6dd0fd0ebc7 h1:IpusRbIZ1Z5j96YpxRD7vTwpfR7Cv3vgETmilcHF5BE= github.com/matm/gocov-html v0.0.0-20160206185555-f6dd0fd0ebc7/go.mod h1:2amKdhwK7Jz2kRhLYmUH2NIOeBs6Tmhpy5UgDXhRbHc= +github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -206,6 +210,7 @@ golang.org/x/tools v0.0.0-20190709211700-7b25e351ac0e/go.mod h1:jcCCGcm9btYwXyDq golang.org/x/tools v0.0.0-20190710184609-286818132824/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= golang.org/x/tools v0.0.0-20190716021316-fefcef05abb1 h1:zgTTk+1hZ1lfGM8FQX/Y4Fcv3HZXEfnrOJ8wZPQClOQ= golang.org/x/tools v0.0.0-20190716021316-fefcef05abb1/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= +golang.org/x/tools v0.0.0-20191022213345-0bbdf54effa2 h1:PD/5/WuAFfp8HtzZpgrO61i5F/PE9IBhBJCQcJ4igdA= golang.org/x/tools v0.0.0-20191022213345-0bbdf54effa2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -259,6 +264,7 @@ sigs.k8s.io/controller-runtime v0.2.0-beta.4 h1:S1XVfRWR1MuIXZdkYx3jN8JDw+bbQxmW sigs.k8s.io/controller-runtime v0.2.0-beta.4/go.mod h1:HweyYKQ8fBuzdu2bdaeBJvsFgAi/OqBBnrVGXcqKhME= sigs.k8s.io/controller-tools v0.2.0-beta.2 h1:ucniFzEuW7PFfFDuUxacdY4Fy4q065wPguVl+BE2/t0= sigs.k8s.io/controller-tools v0.2.0-beta.2/go.mod h1:gC5UAnK1jbxWnDaqTi0yxKIsRsRwshzeRtTUGbM9vos= +sigs.k8s.io/controller-tools v0.2.0-beta.4 h1:W+coTe+nkVNclQrikwlRp6GJKwgcrHzvIQZ9kCaak5A= sigs.k8s.io/controller-tools v0.2.0-beta.4/go.mod h1:8t/X+FVWvk6TaBcsa+UKUBbn7GMtvyBKX30SGl4em6Y= sigs.k8s.io/testing_frameworks v0.1.1 h1:cP2l8fkA3O9vekpy5Ks8mmA0NW/F7yBdXf8brkWhVrs= sigs.k8s.io/testing_frameworks v0.1.1/go.mod h1:VVBKrHmJ6Ekkfz284YKhQePcdycOzNH9qL6ht1zEr/U= From 510612fde0e3d52d21395ed413702ac52f616073 Mon Sep 17 00:00:00 2001 From: Lawrence Gripper Date: Mon, 28 Oct 2019 11:49:05 +0000 Subject: [PATCH 2/6] Remove need for user. --- .devcontainer/Dockerfile | 20 +++++--------------- .devcontainer/devcontainer.json | 8 ++++---- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 7ce3300..9190396 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -55,13 +55,6 @@ RUN apt-get update \ github.com/golangci/golangci-lint/cmd/golangci-lint \ github.com/mgechev/revive \ github.com/derekparker/delve/cmd/dlv 2>&1 \ - # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. - && groupadd --gid $USER_GID $USERNAME \ - && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # [Optional] Add sudo support - && apt-get install -y sudo \ - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME \ # Clean up && apt-get autoremove -y \ && apt-get clean -y \ @@ -81,7 +74,7 @@ RUN apt-get update \ && curl -s https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash - # Configure permissions for Docker without sudo -RUN groupadd --gid $DOCKER_GROUP_ID docker && gpasswd -a $USERNAME docker +# RUN groupadd --gid $DOCKER_GROUP_ID docker && gpasswd -a $USERNAME docker # Verify git, process tools installed RUN apt-get -y install git procps wget nano zsh inotify-tools jq @@ -94,7 +87,7 @@ ENV GO111MODULE=on # Set the default shell to bash instead of sh ENV DATABRICKS_HOST "" ENV DATABRICKS_TOKEN "" -ENV KUBECONFIG="/home/${USERNAME}/.kube/kind-config-kind" +ENV KUBECONFIG="/root/.kube/kind-config-kind" COPY ./Makefile ./ RUN make install-kind @@ -104,10 +97,7 @@ RUN make install-test-dependency ENV SHELL /bin/bash # Add useful aliases -RUN echo "alias k=kubectl" > "/home/${USERNAME}/.bash_aliases" +RUN echo "alias k=kubectl" >> "/root/.bash_aliases" # Add autocomplete to kubectl -RUN echo "source <(kubectl completion bash)" > "/home/${USERNAME}/.bash_aliases" -RUN echo "source <(kubectl completion bash | sed 's/kubectl/k/g')" > "/home/${USERNAME}/.bash_aliases" - -# Configure persmissions for go directory -RUN chown -R $USER_GID /go +RUN echo "source <(kubectl completion bash)" >> "/root/.bash_aliases" +RUN echo "source <(kubectl completion bash | sed 's/kubectl/k/g')" >> "/root/.bash_aliases" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5a85b74..7a6de87 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,10 +7,10 @@ "workspaceMount": "src=${localWorkspaceFolder},dst=/workspace,type=bind", "postCreateCommand": "make set-kindcluster", "runArgs": [ - // Uncomment the next line to use a non-root user. On Linux, this will prevent - // new files getting created as root, but you may need to update the USER_UID - // and USER_GID in .devcontainer/Dockerfile to match your user if not 1000. - "-u", "vscode", + // // Uncomment the next line to use a non-root user. On Linux, this will prevent + // // new files getting created as root, but you may need to update the USER_UID + // // and USER_GID in .devcontainer/Dockerfile to match your user if not 1000. + // "-u", "vscode", "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined", // Mount docker socket for docker builds From 72c4df7eef5124e21f0bc37436659af129ebe677 Mon Sep 17 00:00:00 2001 From: Lawrence Gripper Date: Tue, 29 Oct 2019 10:46:45 +0000 Subject: [PATCH 3/6] Add git setup and kubectx --- .devcontainer/Dockerfile | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9190396..08ffcc2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -76,6 +76,9 @@ RUN apt-get update \ # Configure permissions for Docker without sudo # RUN groupadd --gid $DOCKER_GROUP_ID docker && gpasswd -a $USERNAME docker +# Enable bash completion +RUN apt-get update && apt install -y bash-completion && echo "source /etc/bash_completion" >> "/root/.bashrc" + # Verify git, process tools installed RUN apt-get -y install git procps wget nano zsh inotify-tools jq RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true @@ -97,7 +100,18 @@ RUN make install-test-dependency ENV SHELL /bin/bash # Add useful aliases -RUN echo "alias k=kubectl" >> "/root/.bash_aliases" +RUN echo "alias k=kubectl" >> "/root/.bashrc" # Add autocomplete to kubectl -RUN echo "source <(kubectl completion bash)" >> "/root/.bash_aliases" -RUN echo "source <(kubectl completion bash | sed 's/kubectl/k/g')" >> "/root/.bash_aliases" +RUN echo "source <(kubectl completion bash)" >> "/root/.bashrc" +RUN echo "source <(kubectl completion bash | sed 's/kubectl/k/g')" >> "/root/.bashrc" +# Add kubectx +RUN git clone https://github.com/ahmetb/kubectx.git /root/.kubectx \ + && COMPDIR=$(pkg-config --variable=completionsdir bash-completion) \ + && ln -sf /root/.kubectx/completion/kubens.bash $COMPDIR/kubens \ + && ln -sf /root/.kubectx/completion/kubectx.bash $COMPDIR/kubectx + +# Git command prompt +RUN git clone https://github.com/magicmonty/bash-git-prompt.git ~/.bash-git-prompt --depth=1 \ + && echo "if [ -f \"$HOME/.bash-git-prompt/gitprompt.sh\" ]; then GIT_PROMPT_ONLY_IN_REPO=1 && source $HOME/.bash-git-prompt/gitprompt.sh; fi" >> "/root/.bashrc" + +ENV PATH="/root/.kubectx:${PATH}" \ No newline at end of file From a7033333647ce2180b1e2df45068626566232080 Mon Sep 17 00:00:00 2001 From: Lawrence Gripper Date: Tue, 5 Nov 2019 00:25:16 +0000 Subject: [PATCH 4/6] Add command line history. Go and VSCode server cache. Add env file and tidy. --- .devcontainer/Dockerfile | 20 ++++++-------------- .devcontainer/devcontainer.json | 14 +++++++++----- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 08ffcc2..d8950e1 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -8,17 +8,6 @@ FROM golang:1.12.5-stretch # Avoid warnings by switching to noninteractive ENV DEBIAN_FRONTEND=noninteractive -# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux, -# this user's GID/UID must match your local user UID/GID to avoid permission issues -# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See -# https://aka.ms/vscode-remote/containers/non-root-user for details. -ARG USERNAME=vscode -ARG USER_UID=1000 -ARG USER_GID=$USER_UID -# Support docker connecting to the external docker daemon. On Nix the GID inside the container must match -# the GID of the docker group on the host. -ARG DOCKER_GROUP_ID=999 - # Configure apt, install packages and tools RUN apt-get update \ && apt-get -y install --no-install-recommends apt-utils 2>&1 \ @@ -73,9 +62,6 @@ RUN apt-get update \ # Install Helm && curl -s https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash - -# Configure permissions for Docker without sudo -# RUN groupadd --gid $DOCKER_GROUP_ID docker && gpasswd -a $USERNAME docker - # Enable bash completion RUN apt-get update && apt install -y bash-completion && echo "source /etc/bash_completion" >> "/root/.bashrc" @@ -99,6 +85,12 @@ RUN make install-kustomize RUN make install-test-dependency ENV SHELL /bin/bash +# Save command line history +RUN echo "export HISTFILE=/root/commandhistory/.bash_history" >> "/root/.bashrc" \ + && echo "export PROMPT_COMMAND='history -a'" >> "/root/.bashrc" \ + && mkdir -p /root/commandhistory \ + && touch /root/commandhistory/.bash_history + # Add useful aliases RUN echo "alias k=kubectl" >> "/root/.bashrc" # Add autocomplete to kubectl diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7a6de87..b3f67ae 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,11 +7,15 @@ "workspaceMount": "src=${localWorkspaceFolder},dst=/workspace,type=bind", "postCreateCommand": "make set-kindcluster", "runArgs": [ - // // Uncomment the next line to use a non-root user. On Linux, this will prevent - // // new files getting created as root, but you may need to update the USER_UID - // // and USER_GID in .devcontainer/Dockerfile to match your user if not 1000. - // "-u", "vscode", - + // Mount the env file + "--env-file", "${localWorkspaceFolder}/.env", + // Mount go mod cache + "-v", "dboperator-gomodcache:/go/pkg", + // Cache vscode exentsions installs and homedir + "-v", "dboperator-vscodecache:/root/.vscode-server", + // Keep command history + "-v", "dboperator-bashhistory:/root/commandhistory", + // Enable security needed for docker "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined", // Mount docker socket for docker builds "-v", "/var/run/docker.sock:/var/run/docker.sock", From 726a65798b7d5257dff050fb8cd6af0c486bed19 Mon Sep 17 00:00:00 2001 From: Lawrence Gripper Date: Fri, 29 Nov 2019 14:23:04 +0000 Subject: [PATCH 5/6] Review feedback. --- .devcontainer/devcontainer.json | 2 +- Makefile | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b3f67ae..e3f6dd4 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,7 +8,7 @@ "postCreateCommand": "make set-kindcluster", "runArgs": [ // Mount the env file - "--env-file", "${localWorkspaceFolder}/.env", + "--env-file", "${localWorkspaceFolder}/.devcontainer/.env", // Mount go mod cache "-v", "dboperator-gomodcache:/go/pkg", // Cache vscode exentsions installs and homedir diff --git a/Makefile b/Makefile index b100e23..c984737 100644 --- a/Makefile +++ b/Makefile @@ -134,6 +134,8 @@ endif kubectl cluster-info + @echo "deploying controller to cluster" + make deploy-controller install-kind: ifeq (,$(shell which kind)) From c2a9e842a6a97ad247bada2c34064a9ec67b9233 Mon Sep 17 00:00:00 2001 From: Lawrence Gripper Date: Wed, 4 Dec 2019 08:45:17 +0000 Subject: [PATCH 6/6] Remove postcreatecommand. Doc cache reset --- .devcontainer/devcontainer.json | 1 - docs/contributing.md | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e3f6dd4..b95d5d0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,6 @@ "workspaceFolder": "/workspace", "context": "..", "workspaceMount": "src=${localWorkspaceFolder},dst=/workspace,type=bind", - "postCreateCommand": "make set-kindcluster", "runArgs": [ // Mount the env file "--env-file", "${localWorkspaceFolder}/.devcontainer/.env", diff --git a/docs/contributing.md b/docs/contributing.md index 18d1146..df7c85b 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -51,6 +51,22 @@ If you are using Visual Studio Code with [Remote - Containers](https://marketpla ``` 7. Once your kind cluster has been created, you can now start testing your Azure Databicks Operator within your own local kubernetes environment! +## Advanced: DevContainer Cache + +To speedup start times for the `devcontainer` and reduce the requirement for internet connectivity when starting we cache the `.vscodeserver` and `/go/pkg` folder to docker volumes. The [VSCode docs cover this topic here](https://code.visualstudio.com/docs/remote/containers-advanced#_avoiding-extension-reinstalls-on-container-rebuild). + +The downside is that changes to the `extension` list in `devcontainer.json` won't automatically be picked up. To clear the cache run `docker volume rm dboperator-vscodecache -f`. + +You'll need to remove existing instance of the `devcontainer` before clearing the cache. Use `docker ps -a` and then locating the container with a name `vsc-azure-databricks-operator-*` and using `docker rm -f CONTAINER-NAME-HERE` to remove it. + +In `bash` the following will automate the process: + +``` + docker ps -a | grep vsc-azure-databricks | awk '{print $1}' | xargs docker rm -f + docker volume rm dboperator-vscodecache -f + docker volume rm dboperator-gomodcache -f +``` + # Building and Running the operator ## Basics @@ -58,8 +74,7 @@ The scaffolding for the project is generated using `Kubebuilder`. It is a good i See `Makefile` at the root directory of the project. By default, executing `make` will build the project and produce an executable at `./bin/manager` -For example, to quick start ->this assumes dependencies have been downloaded and existing CRDs have been installed. See next section +For example, to quick start this assumes dependencies have been downloaded and existing CRDs have been installed. See next section ``` $ git clone https://github.com/microsoft/azure-databricks-operator.git $ cd azure-databricks-operator