├── .gitignore ├── LICENSE ├── README.md ├── assets └── codeserver.png ├── cleanup.sh ├── codeserver.yaml └── deploy.sh /.gitignore: -------------------------------------------------------------------------------- 1 | /t/* 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Yoichi Kawasaki 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Visual Studio Code Server on Azure Webapp for Containers 2 | 3 | The aim of this repository is to deploy [code-server](https://github.com/codercom/code-server), VS Code running on a remote server, to [Azure Webapp for Containers](https://azure.microsoft.com/en-us/services/app-service/containers/). 4 | 5 | > [WARNING] Please note that its performance is not very good on Azure Webapp for Containers 6 | 7 | ![](assets/codeserver.png) 8 | 9 | ## Run in Docker 10 | 11 | ```sh 12 | docker run -it -p 127.0.0.1:8443:8443 -v "${PWD}:/home/coder/project" codercom/code-server:1.621 --allow-http --no-auth 13 | ``` 14 | 15 | ## Deploy Code Server to Azure Webapp for Containers 16 | 17 | Prepare docker compose YAML file for code server webapp (`codeserver.yaml`) 18 | ```sh 19 | cat << EOD | tee codeserver.yaml 20 | version: '3.3' 21 | 22 | services: 23 | codeserver: 24 | image: 'codercom/code-server:1.621' 25 | volumes: 26 | - ${WEBAPP_STORAGE_HOME}/site/wwwroot:/home/coder/project 27 | ports: 28 | - "80:8443" 29 | entrypoint: 30 | - dumb-init 31 | - code-server 32 | - --allow-http 33 | - --no-auth 34 | restart: always 35 | EOD 36 | ``` 37 | 38 | Open `deploy.sh`and 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. 39 | 40 | > deploy.sh 41 | ```bash 42 | RESOURCE_GROUP="" 43 | REGION="" 44 | APP_NAME="" 45 | APP_PLAN_NAME="" 46 | CONFIG_FILE="codeserver.yaml" 47 | 48 | cwd=`dirname "$0"` 49 | expr "$0" : "/.*" > /dev/null || cwd=`(cd "$cwd" && pwd)` 50 | 51 | echo "Create Resource Group: $RESOURCE_GROUP" 52 | az group create --name $RESOURCE_GROUP --location $REGION 53 | 54 | echo "Create App Service Plan: $APP_PLAN_NAME" 55 | az appservice plan create \ 56 | --name $APP_PLAN_NAME \ 57 | --resource-group $RESOURCE_GROUP \ 58 | --sku S1 --is-linux 59 | 60 | echo "Create Web App for Container: $APP_NAME" 61 | az webapp create \ 62 | --resource-group $RESOURCE_GROUP \ 63 | --plan $APP_PLAN_NAME \ 64 | --name $APP_NAME \ 65 | --multicontainer-config-type compose \ 66 | --multicontainer-config-file $cwd/$CONFIG_FILE 67 | 68 | echo "Add App Setting" 69 | az webapp config appsettings set \ 70 | --resource-group $RESOURCE_GROUP \ 71 | --name $APP_NAME \ 72 | --settings WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE 73 | ``` 74 | 75 | Access the code-server on Azure webapp 76 | ```sh 77 | open https://$APP_NAME.azurewebsites.net 78 | ``` 79 | 80 | ## Cleanup 81 | 82 | > cleanup.sh 83 | ``` 84 | az group delete --name $RESOURCE_GROUP 85 | ``` 86 | -------------------------------------------------------------------------------- /assets/codeserver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yokawasa/code-server-azure-webapp/ce85c9e1a1d503c869972c7de92f80afa492ff1d/assets/codeserver.png -------------------------------------------------------------------------------- /cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | RESOURCE_GROUP=RG-yoichika-demox 4 | echo "Clean up Resourcde Group: $RESOURCE_GROUP" 5 | az group delete --name $RESOURCE_GROUP -------------------------------------------------------------------------------- /codeserver.yaml: -------------------------------------------------------------------------------- 1 | version: '3.3' 2 | 3 | services: 4 | codeserver: 5 | image: 'codercom/code-server:1.621' 6 | volumes: 7 | - ${WEBAPP_STORAGE_HOME}/site/wwwroot:/home/coder/project 8 | ports: 9 | - "80:8443" 10 | entrypoint: 11 | - dumb-init 12 | - code-server 13 | - --allow-http 14 | - --no-auth 15 | restart: always 16 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | RESOURCE_GROUP="" 4 | REGION="" 5 | APP_NAME="" 6 | APP_PLAN_NAME="" 7 | CONFIG_FILE=codeserver.yaml 8 | 9 | set -e -x 10 | cwd=`dirname "$0"` 11 | expr "$0" : "/.*" > /dev/null || cwd=`(cd "$cwd" && pwd)` 12 | 13 | echo "Create Resource Group: $RESOURCE_GROUP" 14 | az group create --name $RESOURCE_GROUP --location $REGION 15 | 16 | echo "Create App Service Plan: $APP_PLAN_NAME" 17 | az appservice plan create \ 18 | --name $APP_PLAN_NAME \ 19 | --resource-group $RESOURCE_GROUP \ 20 | --sku S1 --is-linux 21 | 22 | echo "Create Web App for Container: $APP_NAME" 23 | az webapp create \ 24 | --resource-group $RESOURCE_GROUP \ 25 | --plan $APP_PLAN_NAME \ 26 | --name $APP_NAME \ 27 | --multicontainer-config-type compose \ 28 | --multicontainer-config-file $cwd/$CONFIG_FILE 29 | 30 | echo "Add App Setting" 31 | az webapp config appsettings set \ 32 | --resource-group $RESOURCE_GROUP \ 33 | --name $APP_NAME \ 34 | --settings WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE 35 | 36 | echo "Done!!" 37 | echo "" 38 | echo "Access the code-server:" 39 | echo "open https://$APP_NAME.azurewebsites.net" 40 | echo "" 41 | --------------------------------------------------------------------------------