Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install code-server on Coder
#!/bin/bash
VERSION=${VERSION:-2.1523-vsc1.38.1}
WORK_DIR=/home/ubuntu/projects
USER_ID=1000
GROUP_ID=1000
PORT=8888
TARBALL_URL=https://github.com/cdr/code-server/releases/download/$VERSION/code-server$VERSION-linux-x86_64.tar.gz
curl -L $TARBALL_URL | tar xfz - -C /usr/local/
EXEC_PATH=/usr/local/code-server$VERSION-linux-x86_64/code-server
mkdir -p $WORK_DIR
chown $USER_ID:$GROUP_ID $WORK_DIR
cat << EOT > /etc/systemd/system/code-server.service
[Unit]
Description=VSCode in a browser
After=network.target
[Service]
Type=simple
ExecStart=$EXEC_PATH --host 0.0.0.0 --port $PORT --locale ja-JP $WORK_DIR
WorkingDirectory=$WORK_DIR
ExecStop=/sbin/start-stop-daemon --stop -x $EXEC_PATH
Restart=on-failure
User=$USER_ID
[Install]
WantedBy=multi-user.target
EOT
systemctl daemon-reload
systemctl enable code-server.service
systemctl start code-server.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.