From 47dd82e80db71954816515721764873fceb9de05 Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Thu, 23 Feb 2023 15:46:32 -0800 Subject: [PATCH] feat: Enable Codespaces with `kit` (#10532) Signed-off-by: Alex Collins Signed-off-by: Alex Collins --- .devcontainer/Dockerfile | 39 ++---------- .devcontainer/devcontainer.json | 35 ++--------- .devcontainer/pre-build.sh | 13 ++++ .devcontainer/startup.sh | 18 ------ .github/workflows/ci-build.yaml | 2 +- .gitignore | 1 + Dockerfile | 2 +- Makefile | 3 +- tasks.yaml | 104 ++++++++++++++++++++++++++++++++ ui/package.json | 4 +- 10 files changed, 134 insertions(+), 87 deletions(-) create mode 100755 .devcontainer/pre-build.sh delete mode 100644 .devcontainer/startup.sh create mode 100644 tasks.yaml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d943c48cf8bf..e68fa2fabc91 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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/ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3ef93ba144bc..c185f29e4613 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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" +} \ No newline at end of file diff --git a/.devcontainer/pre-build.sh b/.devcontainer/pre-build.sh new file mode 100755 index 000000000000..e90ad567d7c1 --- /dev/null +++ b/.devcontainer/pre-build.sh @@ -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 \ No newline at end of file diff --git a/.devcontainer/startup.sh b/.devcontainer/startup.sh deleted file mode 100644 index 2e3c1f39c4b6..000000000000 --- a/.devcontainer/startup.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -e - -sudo apt update -sudo chown $USER:docker /var/run/docker.sock -sudo chown -fR $USER:golang $GOPATH - -echo $'127.0.0.1 dex\n127.0.0.1 minio\n127.0.0.1 postgres\n127.0.0.1 mysql\n127.0.0.1 azurite' | sudo tee -a /etc/hosts - -if k3d cluster list | grep k3s-default; -then - echo "skip k3s creation, k3s-default cluster already exist" -else - k3d cluster create -fi - -until k3d cluster start --wait ; do sleep 5 ; done -k3d kubeconfig merge k3s-default --kubeconfig-merge-default --kubeconfig-switch-context diff --git a/.github/workflows/ci-build.yaml b/.github/workflows/ci-build.yaml index 9539c5266eef..2e7f45806b0d 100644 --- a/.github/workflows/ci-build.yaml +++ b/.github/workflows/ci-build.yaml @@ -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 diff --git a/.gitignore b/.gitignore index 012b8b068077..c436318d182f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Dockerfile b/Dockerfile index 139626f9716f..33ae714bf239 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Makefile b/Makefile index b844dc52c2b5..b4c39511c2fa 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/tasks.yaml b/tasks.yaml new file mode 100644 index 000000000000..c2ae3f74011c --- /dev/null +++ b/tasks.yaml @@ -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 diff --git a/ui/package.json b/ui/package.json index 7e09c9598679..bdc9e1f436fa 100644 --- a/ui/package.json +++ b/ui/package.json @@ -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" },