From 8bc61e9da63953806a2a9a686c4b14a5f9ad7fbf Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Wed, 29 Nov 2023 17:16:54 +0100 Subject: [PATCH] chore: add support for codespaces / devcontainers (#3632) Adding basic support for codespaces. --- .devcontainer/Dockerfile | 2 ++ .devcontainer/bashrc.sh | 17 ++++++++++ .devcontainer/devcontainer.json | 32 +++++++++++++++++++ .devcontainer/postCreateScript.sh | 1 + .devcontainer/welcome.txt | 53 +++++++++++++++++++++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/bashrc.sh create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/postCreateScript.sh create mode 100644 .devcontainer/welcome.txt diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..e525ec5661 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,2 @@ +ARG VARIANT="18-bullseye" +FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT} diff --git a/.devcontainer/bashrc.sh b/.devcontainer/bashrc.sh new file mode 100644 index 0000000000..4caa672b6a --- /dev/null +++ b/.devcontainer/bashrc.sh @@ -0,0 +1,17 @@ +open_workspace() { + local workspace_file=$WORKSPACE/.vscode/gh-runners.code-workspace + + if ! [ -f "$workspace_file" ]; then + echo "🔴 Missing workspace file" + return 1 + fi + + echo "🟡 Opening workspace" + if code "$workspace_file"; then + echo "🟢 Workspace opened" + return 0 + else + echo "🔴 Failed to open workspace" + return 1 + fi +} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..b2e87f057c --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,32 @@ +{ + "name": "GitHub Runners AWS", + "build": { "dockerfile": "Dockerfile" }, + "features": { + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/devcontainers/features/terraform:1": {} + }, + + "containerEnv": { + "WORKSPACE": "${containerWorkspaceFolder}" // e.g. /workspaces/my-project + }, + + "customizations": { + "vscode": { + "extensions": [ + "dbaeumer.vscode-eslint", + "editorconfig.editorconfig", + "esbenp.prettier-vscode", + "firsttris.vscode-jest-runner", + "hashicorp.hcl", + "hashicorp.terraform", + "hashicorp.terraform", + "orta.vscode-jest", + "yzhang.markdown-all-in-one" + ] + } + }, + "postCreateCommand": { + "bash_command": "bash ${containerWorkspaceFolder}/.devcontainer/postCreateScript.sh", + "welcome": "sudo cp -v .devcontainer/welcome.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt || true && sudo cp -v .devcontainer/welcome.txt /workspaces/.codespaces/shared/first-run-notice.txt || true" + } +} diff --git a/.devcontainer/postCreateScript.sh b/.devcontainer/postCreateScript.sh new file mode 100644 index 0000000000..e8ca09e317 --- /dev/null +++ b/.devcontainer/postCreateScript.sh @@ -0,0 +1 @@ +printf "source \$WORKSPACE/.devcontainer/bashrc.sh\n" >> ~/.bashrc diff --git a/.devcontainer/welcome.txt b/.devcontainer/welcome.txt new file mode 100644 index 0000000000..d8b6925fd0 --- /dev/null +++ b/.devcontainer/welcome.txt @@ -0,0 +1,53 @@ +================================================================================ +================================================================================ +=====================================================++++**+++================== +=================================================+++++=********+================ +=============================================+***+=--:-#********+=============== +==========================================+***+=--:::::-+*#*****+=============== +=======================================+*#%*=--:::::::::::-=====+=============== +=====================================+#%%##%*-:::::::::::::::::+================ +===========================++======*#%%#######=-::::::::::::::=+================ +=======================++==---::-+#%%###########+-:::::::::::-+================= +====================+==-::::::-=#%%################+=::::::::+================== +=================++=-:::::::-=#%%%####%%##**########%#*++=-:++================== +===============+=-:::-------*%%%###%%%#=:...:-*############*+=================== +=====. .-====-:--++***+++#%%###%#%%+: .-*###########+==================== +===-. --:-++**+=====+%%%###%%#%*- :*#########*====================== +=== .:==++=========*%%%#####%#%*=. .=#########*======================= +===: :: .==========+%%%%#####%%%%#+=-:::-+#########+======================== +====: :=========#%%%%#####%#**#####*##########+========================== +==== .=========%%%%%####*+=*%##############============================= +====-.... :--------=##%%%%#*==*%##############=::++========================== +========--::---------=-=#%%%#+=#%#############*=-::-*=========================== +======------------=+*=---*#++*%#############+-:::::++=========================== +=====----------=+*+=+---=++*%%%%#########**+-:::::++============================ +===----------+*+=-+*+-=+=*#+=*%%%%%%%#*+==+#=:::-*+============================= +==---------+**+-=**+===**=-=--=+***+======#+-::=+=============================== +==----------+=-=**=:=+*=--++---==========**=:-++================================ +=---------=*=-=**=::::--=*+----=-:::-===**=-=+================================== +=--------=*=-+**+::-=*+=*+-----=. ..=+==+==================================== +=-------==--***+=+**=*+*=------. -+=..===================================== +=------=--=***+**+=-+*+------==. .=+: .===================================== +=--------=*****+---++=-----===== .=: :====================================== +==------=***+=----==-----======- -======================================= +===----=*+=------=-----=========: .======================================== +====--==------------==============--============================================ +======--------================================================================== +================================================================================ +================================================================================ +================================================================================ +================================================================================ +==========================================================================-:-=++ + + +Welcome to the AWS GitHub runners: + +Load the vscode workspace to get started + +Option 1: run `open_workspace` +Option 2: open the workspace file `.vscoe/gh-runners.code-workspace` and load the workspace + +Build the lambda: +- cd lambdas +- yarn instal & yarn run dist +