vscode try

This commit is contained in:
Mateusz 2022-12-30 15:58:47 +01:00
parent 4d49a7d3b8
commit 48a5884cd8
3 changed files with 19 additions and 45 deletions

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 31,
"metadata": {},
"outputs": [
{
@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 32,
"metadata": {},
"outputs": [
{
@ -62,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 33,
"metadata": {},
"outputs": [
{

0
hetzner/sigma/computeC Normal file → Executable file
View File

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 22,
"metadata": {},
"outputs": [
{
@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 23,
"metadata": {},
"outputs": [
{
@ -62,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 24,
"metadata": {},
"outputs": [
{
@ -78,7 +78,7 @@
"from hcloud.images.domain import Image\n",
"from hcloud.server_types.domain import ServerType\n",
"\n",
"cloud_init_mysql=r'''#cloud-config\n",
"cloud_init_vscode=r'''#cloud-config\n",
"packages:\n",
" - apt-transport-https\n",
" - ca-certificates\n",
@ -87,55 +87,29 @@
" - software-properties-common\n",
"\n",
"write_files:\n",
" - path: /root/docker-compose.yml\n",
" content: |\n",
" version: '3.9'\n",
"\n",
" services:\n",
" db:\n",
" image: mysql:5.7\n",
" restart: always\n",
" environment:\n",
" MYSQL_DATABASE: gitea\n",
" MYSQL_USER: gitea\n",
" MYSQL_PASSWORD: gitea\n",
" MYSQL_ROOT_PASSWORD: gitea\n",
" ports:\n",
" - \"10.10.10.2:3306:3306\"\n",
" volumes:\n",
" - my-db:/var/lib/mysql\n",
" phpmyadmin:\n",
" image: phpmyadmin\n",
" restart: always\n",
" ports:\n",
" - \"8080:80\"\n",
" volumes:\n",
" my-db: {}\n",
" - content: |\n",
" curl -fsSL https://code-server.dev/install.sh > /root/install.sh\n",
" path: /root/install.sh\n",
" owner: root:root\n",
" permissions: '755'\n",
"\n",
"runcmd:\n",
" - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -\n",
" - add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"\n",
" - apt-get update -y\n",
" - apt-get install -y docker-ce docker-ce-cli containerd.io\n",
" - curl -L \"https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose\n",
" - chmod +x /usr/local/bin/docker-compose\n",
" - systemctl start docker\n",
" - systemctl enable docker\n",
" - cd /root/ && docker-compose up -d\n",
" - bash /root/install.sh\n",
" - code-server --bind-addr 0.0.0.0:8080\n",
" '''\n",
"\n",
"mysql_server = client.servers.create(\n",
" name=f\"{PREFIX}-mysql\", \n",
"vscode_server = client.servers.create(\n",
" name=f\"{PREFIX}-vscode\", \n",
" server_type=ServerType(\"cx11\"), \n",
" image=Image(name=\"ubuntu-20.04\"), \n",
" ssh_keys=[ssh_key], \n",
" networks=[vnet], \n",
" location=Location(\"hel1\"), \n",
" user_data=cloud_init_mysql\n",
" user_data=cloud_init_vscode\n",
")\n",
"\n",
"mysql_server.action.wait_until_finished()\n",
"print(f\"Creating gitea server: {mysql_server.action.complete}\")"
"vscode_server.action.wait_until_finished()\n",
"print(f\"Creating gitea server: {vscode_server.action.complete}\")"
]
}
],