/code-server-azure-webapp

Visual Studio Code Server on Azure Web App for Containers

Primary LanguageShellMIT LicenseMIT

Visual Studio Code Server on Azure Webapp for Containers

The aim of this repository is to deploy code-server, VS Code running on a remote server, to Azure Webapp for Containers.

[WARNING] Please note that its performance is not very good on Azure Webapp for Containers

Run in Docker

docker run -it -p 127.0.0.1:8443:8443 -v "${PWD}:/home/coder/project" codercom/code-server:1.621 --allow-http --no-auth

Deploy Code Server to Azure Webapp for Containers

Prepare docker compose YAML file for code server webapp (codeserver.yaml)

cat << EOD | tee codeserver.yaml
version: '3.3'

services:
  codeserver:
    image: 'codercom/code-server:1.621'
    volumes:
     - ${WEBAPP_STORAGE_HOME}/site/wwwroot:/home/coder/project
    ports:
      - "80:8443"
    entrypoint:
      - dumb-init
      - code-server
      - --allow-http
      - --no-auth
    restart: always
EOD

Open deploy.shand add values for RESOURCE_GROUP, REGION, APP_NAME and APP_PLAN_NAME, then run the script to deploy the code server container to Azure Webapp for Containers.

deploy.sh

RESOURCE_GROUP="<RESOURCE GROUP>"
REGION="<REGION: japaneast>"
APP_NAME="<APP SERVICE NAME>"
APP_PLAN_NAME="<APP SERVICE PLAN NAME>"
CONFIG_FILE="codeserver.yaml"

cwd=`dirname "$0"`
expr "$0" : "/.*" > /dev/null || cwd=`(cd "$cwd" && pwd)`

echo "Create Resource Group: $RESOURCE_GROUP"
az group create --name $RESOURCE_GROUP --location $REGION

echo "Create App Service Plan: $APP_PLAN_NAME"
az appservice plan create \
  --name $APP_PLAN_NAME \
  --resource-group $RESOURCE_GROUP \
  --sku S1 --is-linux

echo "Create Web App for Container: $APP_NAME"
az webapp create \
  --resource-group $RESOURCE_GROUP \
  --plan $APP_PLAN_NAME \
  --name $APP_NAME \
  --multicontainer-config-type compose \
  --multicontainer-config-file $cwd/$CONFIG_FILE

echo "Add App Setting"
az webapp config appsettings set \
  --resource-group $RESOURCE_GROUP \
  --name $APP_NAME \
  --settings WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE

Access the code-server on Azure webapp

open https://$APP_NAME.azurewebsites.net

Cleanup

cleanup.sh

az group delete --name $RESOURCE_GROUP