Skip to content

Commit

Permalink
Merge pull request #130 from CEHR2005/main
Browse files Browse the repository at this point in the history
add codespaces support
  • Loading branch information
Konard authored Sep 11, 2023
2 parents 520f6df + 42bea71 commit 06660ba
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "Ubuntu",
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers-contrib/features/npm-package:1": {},
"ghcr.io/wxw-matt/devcontainer-features/command_runner:0": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers-contrib/features/bash-command:1": {}
},
"forwardPorts": [
3007,
4000,
3006,
8080
],
"onCreateCommand": {
"add_prepare_command": ["chmod", "+x", ".devcontainer/prepare-codespace.sh"],
"prepare": [".devcontainer/prepare-codespace.sh"]
},
"postStartCommand": {
"add_prepare_command": ["chmod", "+x", ".devcontainer/start-codespace.sh"],
"prepare": [".devcontainer/start-codespace.sh"]
},
"portsAttributes": {
"3006": {
"label": "Deep.Links"
},
"3007": {
"label": "Deep.Case"
},
"8080": {
"label": "Hasura"
}
}
}
3 changes: 3 additions & 0 deletions .devcontainer/prepare-codespace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

{ npm i -g npm; npm ci; npm run codespaces-init; docker pull deepf/deeplinks:main; docker run -v $(pwd)/packages/deeplinks:/deeplinks --rm --name links --entrypoint "sh" deepf/deeplinks:main -c "cp -r /snapshots/* /deeplinks/snapshots/ && chown -R 33333:33333 /deeplinks/snapshots/"; (cd packages/deeplinks && npm run snapshot:last); npm install -g concurrently; npm run gitpod-engine; npm cache clean --force; };
3 changes: 3 additions & 0 deletions .devcontainer/start-codespace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

(cd packages/deeplinks; if git merge-base --is-ancestor origin/main main; then echo ''; else ( echo 'NEED TO PULL DEEPLINKS!'; git checkout main; git pull; cd ../../; npm run apply-deeplinks); fi) && (cd packages/deepcase-app; if (git merge-base --is-ancestor origin/main main); then echo ''; else ( echo 'NEED TO PULL DEEPCASE!'; git checkout main; git pull; npm ci); fi) && npm run codespaces-start;
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"childScript": "cross-env-shell \"echo Hello $GREET\"",
"gulp": "gulp",
"test": "(cd packages/deeplinks; npm run test)",
"codespaces-prepare": "npm run gitpod-prepare",
"gitpod-prepare": "npm run git-shh-to-https && sudo apt update && (yes | sudo apt install screen) && (yes | sudo apt install rsync) && (yes | sudo apt install net-tools) && screen -S docker -d -m sudo docker-up",
"packages": "(npx gulp packages:get) && (npx gulp packages:ci)",
"packages-ci": "(cd packages && for d in */; do (cd $d && npm ci); done)",
Expand All @@ -31,6 +32,10 @@
"electron-build-core": "(cross-env npm_config_yes=true NEXT_PUBLIC_ENGINES=1 NEXT_PUBLIC_HIDEPATH=1 MIGRATIONS_ID_TYPE_SQL=bigint MIGRATIONS_ID_TYPE_GQL=bigint MIGRATIONS_HASURA_PATH=localhost:8080 MIGRATIONS_HASURA_SSL=0 MIGRATIONS_HASURA_SECRET=myadminsecretkey NEXT_PUBLIC_DEEPLINKS_SERVER=http://localhost:3007 NEXT_PUBLIC_GQL_PATH=localhost:3006/gql NEXT_PUBLIC_GQL_SSL=0 DEEPLINKS_HASURA_PATH=localhost:8080 DEEPLINKS_HASURA_SSL=0 MIGRATIONS_DEEPLINKS_APP_URL=http://host.docker.internal:3007 NEXT_PUBLIC_DEEPLINKS_URL=MIGRATIONS_DEEPLINKS_URL=http://host.docker.internal:3006 NEXT_PUBLIC_DEEPLINKS_URL=http://localhost:3006 DEEPLINKS_PUBLIC_URL=http://localhost:3006 npm run deepcase-build)",
"electron-build-pack": "cd packages/deepcase-app/electron && npm run electron:pack",
"electron-build-pack-demo": "cd packages/deepcase-app/electron && CSC_IDENTITY_AUTO_DISCOVERY=false npm run electron:pack-demo",
"codespaces-codespaces-name": "export CODESPACE_NAME=$(jq -r \".CODESPACE_NAME\" /workspaces/.codespaces/shared/environment-variables.json)",
"codespaces-variables": "npm run codespaces-codespaces-name",
"codespaces-init": "npm run codespaces-variables && npm run codespaces-prepare && npm ci && npm run packages && npm run apply-deeplinks && npm run apply-hasura",
"codespaces-start": "export NEXT_PUBLIC_ENGINES=0; export NEXT_PUBLIC_HIDEPATH=1; export npm_config_yes=true; export JWT_SECRET=\"{\\\"type\\\":\\\"HS256\\\",\\\"key\\\":\\\"3EK6FD+o0+c7tzBNVfjpMkNDi2yARAAKzQlk8O2IKoxQu4nF7EdAh8s3TwpHwrdWT6R\\\"}\" export MIGRATIONS_ID_TYPE_SQL=bigint; export MIGRATIONS_ID_TYPE_GQL=bigint; export MIGRATIONS_HASURA_PATH=localhost:8080; export DEEPLINKS_HASURA_PATH=localhost:8080; export MIGRATIONS_HASURA_SSL=1; export MIGRATIONS_HASURA_SECRET=myadminsecretkey; export DEEPLINKS_HASURA_SECRET=myadminsecretkey; export NEXT_PUBLIC_DEEPLINKS_SERVER=https://$(echo \"https://${CODESPACE_NAME}-3007.app.github.dev\" | awk -F[/:] '{print $4}'); export NEXT_PUBLIC_GQL_PATH=$(echo \"https://${CODESPACE_NAME}-3006.app.github.dev\" | awk -F[/:] '{print $4}')/gql; export NEXT_PUBLIC_GQL_SSL=1 DEEPLINKS_HASURA_PATH=localhost:8080; export MIGRATIONS_DEEPLINKS_APP_URL=$(echo \"https://${CODESPACE_NAME}-3007.app.github.dev\"); export MIGRATIONS_DEEPLINKS_URL=$(echo \"https://${CODESPACE_NAME}-3006.app.github.dev\"); export DEEPLINKS_PUBLIC_URL=$(echo \"https://${CODESPACE_NAME}-3006.app.github.dev\"); export NEXT_PUBLIC_DEEPLINKS_URL=$(echo \"https://${CODESPACE_NAME}-3006.app.github.dev\"); export DOCKER_DEEPLINKS_URL=http://host.docker.internal:3006; export DEEPLINKS_ROUTE_HANDLERS_HOST=host.docker.internal; concurrently \"npm run deepcase\" \"npm run deeplinks\" \"npm run gitpod-engine\" \"npm run sdk\" \"sleep 120 && npm run codespaces-hasura-reattach\"",
"gitpod-init": "npm run gitpod-prepare && npm ci && npm run packages && npm run apply-deeplinks && npm run apply-hasura",
"gitpod-start": "export NEXT_PUBLIC_ENGINES=0; export NEXT_PUBLIC_HIDEPATH=1; export npm_config_yes=true; export JWT_SECRET=\"{\\\"type\\\":\\\"HS256\\\",\\\"key\\\":\\\"3EK6FD+o0+c7tzBNVfjpMkNDi2yARAAKzQlk8O2IKoxQu4nF7EdAh8s3TwpHwrdWT6R\\\"}\" export MIGRATIONS_ID_TYPE_SQL=bigint; export MIGRATIONS_ID_TYPE_GQL=bigint; export MIGRATIONS_HASURA_PATH=$(echo $(gp url 8080) | awk -F[/:] '{print $4}'); export MIGRATIONS_HASURA_SSL=1; export MIGRATIONS_HASURA_SECRET=myadminsecretkey; export DEEPLINKS_HASURA_SECRET=myadminsecretkey; export NEXT_PUBLIC_DEEPLINKS_SERVER=https://$(echo $(gp url 3007) | awk -F[/:] '{print $4}'); export NEXT_PUBLIC_GQL_PATH=$(echo $(gp url 3006) | awk -F[/:] '{print $4}')/gql; export NEXT_PUBLIC_GQL_SSL=1 DEEPLINKS_HASURA_PATH=localhost:8080; export DEEPLINKS_HASURA_SSL=0; export MIGRATIONS_DEEPLINKS_APP_URL=$(gp url 3007); export MIGRATIONS_DEEPLINKS_URL=$(gp url 3006); export DEEPLINKS_PUBLIC_URL=$(gp url 3006); export NEXT_PUBLIC_DEEPLINKS_URL=$(gp url 3006); export DOCKER_DEEPLINKS_URL=http://host.docker.internal:3006; export DEEPLINKS_ROUTE_HANDLERS_HOST=host.docker.internal; concurrently \"npm run deepcase\" \"npm run deeplinks\" \"npm run gitpod-engine\" \"npm run sdk\" \"sleep 120 && npm run gitpod-hasura-reattach\"",
"gitpod-engine": "cd packages/deeplinks && npm run start-engine-docker",
Expand Down Expand Up @@ -73,7 +78,8 @@
"gitpod-recreate": "npm run gitpod-unmigrate; npm run docker-clear; npm run rm-migrates; npm run gitpod-engine; npm run gitpod-migrate;",
"local-reinit": "npm run docker-clear; npm run rm-migrates; npm run local-engine;",
"gitpod-reinit": "npm run docker-clear; npm run rm-migrates; npm run gitpod-engine;",
"gitpod-hasura-reattach": "export REATTACH_HASURA_SECRET=myadminsecretkey; export REATTACH_HASURA_PATH=$(echo $(gp url 8080) | awk -F[/:] '{print $4}'); export REATTACH_HASURA_SSL=1; export REATTACH_DEEPLINKS_PATH=$(echo $(gp url 3006) | awk -F[/:] '{print $4}'); npx gulp gitpod:hasura:reattach"
"gitpod-hasura-reattach": "export REATTACH_HASURA_SECRET=myadminsecretkey; export REATTACH_HASURA_PATH=$(echo $(gp url 8080) | awk -F[/:] '{print $4}'); export REATTACH_HASURA_SSL=1; export REATTACH_DEEPLINKS_PATH=$(echo $(gp url 3006) | awk -F[/:] '{print $4}'); npx gulp gitpod:hasura:reattach",
"codespaces-hasura-reattach": "export REATTACH_HASURA_SECRET=myadminsecretkey; export REATTACH_HASURA_PATH=localhost:8080; export REATTACH_HASURA_SSL=0; export REATTACH_DEEPLINKS_PATH=host.docker.internal:3006; npx gulp gitpod:hasura:reattach"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 06660ba

Please sign in to comment.