Skip to content

Commit

Permalink
feat: Enable Codespaces with kit (#10532)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alexec@users.noreply.github.com>
  • Loading branch information
alexec committed Feb 23, 2023
1 parent d75e37e commit 47dd82e
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 87 deletions.
39 changes: 4 additions & 35 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,10 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.234.0/containers/debian/.devcontainer/base.Dockerfile

ARG VARIANT="bullseye"
FROM --platform=linux/amd64 mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

ARG NEW_USERNAME=""
ARG HOME=""
ARG OLD_USERNAME="vscode"
ARG VSCODE_SCRIPT_VERSION=""
FROM mcr.microsoft.com/vscode/devcontainers/universal

ARG PROTOC_ZIP="protoc-3.14.0-linux-x86_64.zip"
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get install -y apt-transport-https ca-certificates git sudo \
# use new user instead of vscode user
&& usermod -l $NEW_USERNAME -d /home/$NEW_USERNAME -m $OLD_USERNAME \
&& groupmod -n $NEW_USERNAME $OLD_USERNAME \
&& echo $NEW_USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$NEW_USERNAME \
&& chmod 0440 /etc/sudoers.d/$NEW_USERNAME \
# kubectl
&& curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list \
&& apt-get update \
&& apt-get install -y kubectl \
# protobuf
&& curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/${PROTOC_ZIP} \

RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/${PROTOC_ZIP} \
&& unzip -o ${PROTOC_ZIP} -d /usr/local bin/protoc \
&& unzip -o ${PROTOC_ZIP} -d /usr/local 'include/*' \
&& rm -f ${PROTOC_ZIP} \
&& chmod 755 /usr/local/bin/protoc \
&& chmod -R 755 /usr/local/include/ \
# k3d
&& wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash \
# go
&& bash -ec "$(curl -fsSL "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/$VSCODE_SCRIPT_VERSION/script-library/go-debian.sh")" -- "1.18" "/usr/local/go" "$HOME/go" "automatic" "true" "false" \
# dind
&& bash -ec "$(curl -fsSL "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/$VSCODE_SCRIPT_VERSION/script-library/docker-in-docker-debian.sh")" -- "true" "automatic" "true" "20.10" "v1" \
# node
&& bash -ec "$(curl -fsSL "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/$VSCODE_SCRIPT_VERSION/script-library/node-debian.sh")" -- "/usr/local/share/nvm" "16" "automatic" "true" "true" \
# python
&& bash -ec "$(curl -fsSL "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/$VSCODE_SCRIPT_VERSION/script-library/python-debian.sh")" -- "3.9" \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
&& chmod -R 755 /usr/local/include/
35 changes: 6 additions & 29 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.234.0/containers/debian
{
"name": "Debian",
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "bullseye",
"NEW_USERNAME": "${localEnv:USER}",
"HOME": "${localEnv:HOME}",
"VSCODE_SCRIPT_VERSION": "v0.234.0"
}
},

"settings": {},

"extensions": [],

"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],

"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

"remoteUser": "${localEnv:USER}",
"features": {},

"workspaceMount": "source=${localWorkspaceFolder},target=${localEnv:HOME}/go/src/github.com/argoproj/argo-workflows,type=bind",
"workspaceFolder": "${localEnv:HOME}/go/src/github.com/argoproj/argo-workflows",

"postStartCommand": "bash -i .devcontainer/startup.sh"
}
"build": { "dockerfile": "Dockerfile" },
"hostRequirements": {"cpus": 4},
"onCreateCommand": ".devcontainer/pre-build.sh",
"workspaceMount": "source=${localWorkspaceFolder},target=${localEnv:HOME}/go/src/github.com/argoproj/argo-workflows,type=bind",
"workspaceFolder": "${localEnv:HOME}/go/src/github.com/argoproj/argo-workflows"
}
13 changes: 13 additions & 0 deletions .devcontainer/pre-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh
set -eux

# install kubernetes
wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
k3d cluster get k3s-default || k3d cluster create --wait
k3d kubeconfig merge --kubeconfig-merge-default

# install kit
curl -q https://raw.githubusercontent.com/kitproj/kit/main/install.sh | sh

# do time consuming tasks, e.g. download deps and initial build
kit build
18 changes: 0 additions & 18 deletions .devcontainer/startup.sh

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
node-version: "19"
cache: yarn
cache-dependency-path: ui/yarn.lock
- run: yarn --cwd ui install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ sdks/python/client/dist/*
# Do not commit rendered installation manifests since they are misleading to users.
manifests/install.yaml
manifests/namespace-install.yaml
/logs
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COPY . .

####################################################################################################

FROM node:16-alpine as argo-ui
FROM node:19-alpine as argo-ui

RUN apk update && apk add --no-cache git

Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ ifeq (, $(shell which clang-format))
ifeq ($(shell uname),Darwin)
brew install clang-format
else
sudo apt-get install clang-format
sudo apt update
sudo apt install clang-format
endif
endif

Expand Down
104 changes: 104 additions & 0 deletions tasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
apiVersion: kit/v1
kind: Tasks
metadata:
annotations:
help: |
Install `kit` by following https://github.com/alexec/kit#install.
Run `kit up` to start argo.
- `env PROFILE=mysql kit up` to start with MySQL.
- `env PROFILE=plugins ARGO_EXECUTOR_PLUGINS=true kit up` to start with plugins.
- `env PROFILE=sso ARGO_AUTH_MODE=sso kit up` to start with SSO.
The app will be up-and-running between 15s and 1m later (if hot compiled or cold).
Any changes made to the source code will be automatically recompiled and the app restarted, typically within a few seconds.
name: argo-workflows
spec:
tasks:
- name: go-deps
command: go mod download
mutex: deps
- name: static-files
command: make server/static/files.go STATIC_FILES=false
dependencies: go-deps
- command: go build -v ./...
name: go-build
dependencies: static-files go-deps
- name: cluster-info
command: kubectl cluster-info
- name: docker-ps
command: docker ps
- name: install
command: sh -c "make install PROFILE=$PROFILE"
env:
- PROFILE=minimal
dependencies: cluster-info go-deps
watch: manifests
- command: make ./dist/workflow-controller
dependencies: go-build
name: build-controller
- name: port-forward
command: ./hack/port-forward.sh
ports: 9000
dependencies: install
- name: controller
command: ./dist/workflow-controller
dependencies: install build-controller port-forward
env:
- ARGO_EXECUTOR_PLUGINS=false
- ARGO_NAMESPACE=argo
- ARGO_NAMESPACED=true
- ARGO_MANAGED_NAMESPACE=argo
- ARGO_LOG_LEVEL=info
- ARGO_REMOVE_PVC_PROTECTION_FINALIZER=true
- ARGO_PROGRESS_PATCH_TICK_DURATION=7s
- DEFAULT_REQUEUE_TIME=1s
- LEADER_ELECTION_IDENTITY=local
- ALWAYS_OFFLOAD_NODE_STATUS=false
- OFFLOAD_NODE_STATUS_TTL=30s
- WORKFLOW_GC_PERIOD=30s
- UPPERIO_DB_DEBUG=1
- ARCHIVED_WORKFLOW_GC_PERIOD=30s
ports: "9090"
watch: cmd/workflow-controller config errors persist pkg util workflow
- name: build-argo
command: make ./dist/argo
dependencies: go-build
env:
- STATIC_FILES=false
watch: cmd/argo config errors persist pkg util server workflow
- name: server
command: ./dist/argo server
dependencies: build-argo controller port-forward
env:
- ARGO_X_FRAME_OPTIONS=SAMEORIGIN
- ARGO_SECURE=false
- ARGO_NAMESPACE=argo
- ARGO_NAMESPACED=true
- ARGO_LOG_LEVEL=info
- ARGO_AUTH_MODE=hybrid
- ARGO_MANAGED_NAMESPACE=argo
- UPPERIO_DB_DEBUG=1
ports: "2746"
- name: ui-deps
command: yarn --cwd ui install
mutex: deps
- name: ui-build
command: yarn --cwd ui build
dependencies: ui-deps
- name: ui
command: yarn --cwd ui start
dependencies: ui-deps server
ports: "8080"
- name: executor
command: make argoexec-image
dependencies: docker-ps
watch: cmd/argoexec config errors pkg util workflow
- name: example
command: kubectl create -f examples/hello-world.yaml
dependencies: controller
- name: build
dependencies: build-controller build-argo ui-build
- name: up
dependencies: controller server executor ui example
4 changes: 2 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"src"
],
"scripts": {
"build": "rm -Rf dist && NODE_ENV=production webpack --mode production --config ./src/app/webpack.config.js",
"start": "NODE_OPTIONS=--no-experimental-fetch webpack-dev-server --config ./src/app/webpack.config.js",
"build": "rm -Rf dist && NODE_OPTIONS='--openssl-legacy-provider' NODE_ENV=production webpack --mode production --config ./src/app/webpack.config.js",
"start": "NODE_OPTIONS='--no-experimental-fetch --openssl-legacy-provider' webpack-dev-server --config ./src/app/webpack.config.js",
"lint": "tslint --fix -p ./src/app",
"test": "jest"
},
Expand Down

0 comments on commit 47dd82e

Please sign in to comment.