diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index fce407f..06cb43b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,13 +1,14 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node { - "name": "Node.js & TypeScript", + "name": "Localib Dev", "image": "mcr.microsoft.com/devcontainers/typescript-node:18-bullseye", "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {} }, "postCreateCommand": "./.devcontainer/postCreateCommand.sh", "postStartCommand": "./.devcontainer/postStartCommand.sh", - "postAttachCommand": "./.devcontainer/postAttachCommand.sh", - "forwardPorts": [3000] + "postAttachCommand": ["npm", "run", "serve"], + "forwardPorts": [3000], + "remoteUser": "root" } diff --git a/.devcontainer/postAttachCommand.sh b/.devcontainer/postAttachCommand.sh deleted file mode 100755 index 5aecb89..0000000 --- a/.devcontainer/postAttachCommand.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/bash -npm start diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index 10f369f..dd97448 100755 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -1,4 +1,4 @@ #! /bin/bash docker-compose -f .github/docker-compose.yml pull docker-compose -f .github/docker-compose.yml build -npm install +npm ci diff --git a/.devcontainer/postStartCommand.sh b/.devcontainer/postStartCommand.sh index 72abfdb..f98e42e 100755 --- a/.devcontainer/postStartCommand.sh +++ b/.devcontainer/postStartCommand.sh @@ -1,4 +1,12 @@ #! /bin/bash -echo "PUBLIC_URL=https://${CODESPACE_NAME}-3000.preview.app.github.dev" > .env.development.local +if [ ! -z ${GITPOD_HOST+x} ]; then + ACCESS_URL="https://8100-${GITPOD_WORKSPACE_ID}.${GITPOD_WORKSPACE_CLUSTER_HOST}" +elif [ ! -z ${CODESPACE_NAME+x} ]; then + ACCESS_URL="https://${CODESPACE_NAME}-8100.preview.app.github.dev" +else + ACCESS_URL="http://localhost:8100" +fi + +echo "PUBLIC_URL=${ACCESS_URL}" > .env.development.local echo "REACT_APP_VERSION=\$npm_package_version" >> .env.development.local cp .env.development.local .env.production.local