openvscode-server
openvscode-server copied to clipboard
Add ability to set connectionToken via environment variable
It might be nice to be able to specify the connectionToken via an environment variable, like OPENVSCODE_CONNECTION_TOKEN. This will allow for a slightly better, unattended method of starting the container (especially in cases where you might be able to modify environment variables easily but not customize the cmd).
Contributions to Dockerfile should go here: https://github.com/gitpod-io/openvscode-releases/blob/main/Dockerfile It should be done in backward compatible manner.
I would say this is not a 'might be nice' but necessary.
I tested it with Dockerimage 1.62.2. If I start the docker container from shell with the parameter —connectionToken it works. If I set this parameter in a docker-compose >>> Unknown reconnection token (never seen).
Ok, so I did this in my docker-compose.yml file and it seems to work:
entrypoint: ["/bin/sh", "-c", "exec /home/openvscode-server-v1.62.2/server.sh --port 3000 --connectionToken QngfutJNAe", "--"]
and in the logs for the container:
Extension host agent listening on 3000
Web UI available at http://localhost:3000/?tkn= QngfutJNAe
[09:40:26] Extension host agent started.
Obviously you change your token to whatever you want it to be. I had to remove that \"${@}\" bit because it was causing the error:
ERROR: Invalid interpolation format for "entrypoint" option in service "openvscode-server": "exec /home/openvscode-server-v1.62.2/server.sh --port 3000 --connectionToken QngfutJNAe "${@}""
Not sure if this is the right approach, but it does work and I can use the token I manually set there.
Ok, after finding out what ${@} meant in the Dockerfiles ENTRYPOINT:
ENTRYPOINT [ "/bin/sh", "-c", "exec ${OPENVSCODE_SERVER_ROOT}/server.sh --port 3000 \"${@}\"", "--" ]
there's a much cleaner and easier way to do this in docker-compose. Just add command! Example (this is pulled directly from my docker-compose file so you may need to tweak it to your needs):
openvscode-server:
image: gitpod/openvscode-server:latest
container_name: openvscode-server
command: --connectionToken superSekretPassword123
user: '1000:1000'
volumes:
- /etc/localtime:/etc/localtime:ro
- ${DOCKER_CONF_DIR}/openvscode-server/home/workspace:/home/workspace
- /home/jimmy/Developer:/home/workspace/Developer
restart: unless-stopped
and I get:
Extension host agent listening on 3000
Web UI available at http://localhost:3000/?tkn=superSekretPassword123
[09:56:05] Extension host agent started.
Yay, EZ PZ! 🎉 😝
Thanks - Jimmy - works perfect!