Skip to content
Snippets Groups Projects
Unverified Commit b9612996 authored by Mr Simon C's avatar Mr Simon C Committed by GitHub
Browse files

2034 automate port forwarding for GitHub codespaces using gh cli (#2035)

* open the server port to public on container post create

* install gh on container start

* remove port command until needed

* look for port 3001 to be available and make public

* install netcat

* run background nc task before server start

* add sleep 5 due to error clashing with server start

* remove netcat, use gh cli
parent e28c7412
No related branches found
No related tags found
No related merge requests found
......@@ -78,8 +78,8 @@
},
"updateContentCommand": "cd server && yarn && cd ../collector && PUPPETEER_DOWNLOAD_BASE_URL=https://storage.googleapis.com/chrome-for-testing-public yarn && cd ../frontend && yarn && cd .. && yarn setup:envs && yarn prisma:setup && echo \"Please run yarn dev:server, yarn dev:collector, and yarn dev:frontend in separate terminal tabs.\"",
// Use 'postCreateCommand' to run commands after the container is created.
// This configures VITE for github codespaces
"postCreateCommand": "if [ \"${CODESPACES}\" = \"true\" ]; then echo 'VITE_API_BASE=\"https://$CODESPACE_NAME-3001.$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN/api\"' > ./frontend/.env; fi",
// This configures VITE for github codespaces and installs gh cli
"postCreateCommand": "if [ \"${CODESPACES}\" = \"true\" ]; then echo 'VITE_API_BASE=\"https://$CODESPACE_NAME-3001.$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN/api\"' > ./frontend/.env && (type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) && sudo mkdir -p -m 755 /etc/apt/keyrings && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg && echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main\" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null && sudo apt update && sudo apt install gh -y; fi",
"portsAttributes": {
"3001": {
"label": "Backend",
......@@ -208,4 +208,4 @@
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
\ No newline at end of file
}
......@@ -46,7 +46,7 @@
}
}
},
"command": "cd ${workspaceFolder}/server/ && yarn dev",
"command": "if [ \"${CODESPACES}\" = \"true\" ]; then while ! gh codespace ports -c $CODESPACE_NAME | grep 3001; do sleep 1; done; gh codespace ports visibility 3001:public -c $CODESPACE_NAME; fi & cd ${workspaceFolder}/server/ && yarn dev",
"runOptions": {
"instanceLimit": 1,
"reevaluateOnRerun": true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment