finish ex2
This commit is contained in:
parent
405f055aca
commit
4d49a7d3b8
@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 28,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -30,7 +30,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -62,7 +62,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 30,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -102,9 +102,9 @@
|
||||
" environment:\n",
|
||||
" - USER_UID=1000\n",
|
||||
" - USER_GID=1000\n",
|
||||
" - GITEA__server__ROOT_URL=http://localhost:3000/\n",
|
||||
" - GITEA__server__DOMAIN=${DOMAIN}\n",
|
||||
" - GITEA__database__DB_TYPE=mysql\n",
|
||||
" - GITEA__database__HOST=localhost:3306\n",
|
||||
" - GITEA__database__HOST=10.10.10.2:3306\n",
|
||||
" - GITEA__database__NAME=gitea\n",
|
||||
" - GITEA__database__USER=gitea\n",
|
||||
" - GITEA__database__PASSWD=gitea\n",
|
||||
@ -112,13 +112,16 @@
|
||||
" networks:\n",
|
||||
" - gitea\n",
|
||||
" volumes:\n",
|
||||
" - ./gitea:/data\n",
|
||||
" - ./data:/root/gitea\n",
|
||||
" - ./config:/root/gitea/config\n",
|
||||
" - /etc/timezone:/etc/timezone:ro\n",
|
||||
" - /etc/localtime:/etc/localtime:ro\n",
|
||||
" - /mnt/volume:/data\n",
|
||||
" ports:\n",
|
||||
" - \"3000:3000\"\n",
|
||||
" - \"222:22\"\n",
|
||||
"\n",
|
||||
"'''\n",
|
||||
"runcmd = f'''\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",
|
||||
@ -128,8 +131,13 @@
|
||||
" - chmod +x /usr/local/bin/docker-compose\n",
|
||||
" - systemctl start docker\n",
|
||||
" - systemctl enable docker\n",
|
||||
" - cd /root/ && docker-compose up -d\n",
|
||||
" '''\n",
|
||||
" - cd /root/\n",
|
||||
" - IP=$(hostname -I | cut -d ' ' -f 1)\n",
|
||||
" - echo \"DOMAIN=$IP\" >> .env\n",
|
||||
" - docker-compose up -d\n",
|
||||
"'''\n",
|
||||
"\n",
|
||||
"cloud_init_gitea += runcmd\n",
|
||||
"\n",
|
||||
"gitea_server = client.servers.create(\n",
|
||||
" name=f\"{PREFIX}-gitea\", \n",
|
||||
|
@ -1,16 +1,31 @@
|
||||
version: "2"
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
server:
|
||||
image: gitea/gitea:1.17.3-rootless
|
||||
environment:
|
||||
- GITEA__server__ROOT_URL=http://135.181.195.235:3000/
|
||||
restart: always
|
||||
volumes:
|
||||
- ./data:/var/lib/gitea
|
||||
- ./config:/etc/gitea
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "2222:2222"
|
||||
networks:
|
||||
gitea:
|
||||
external: false
|
||||
|
||||
services:
|
||||
server:
|
||||
image: gitea/gitea:1.17.4
|
||||
container_name: gitea
|
||||
environment:
|
||||
- USER_UID=1000
|
||||
- USER_GID=1000
|
||||
- GITEA__database__DB_TYPE=mysql
|
||||
- GITEA__server__DOMAIN=${DOMAIN}
|
||||
- GITEA__database__HOST=10.10.10.2:3306
|
||||
- GITEA__database__NAME=gitea
|
||||
- GITEA__database__USER=gitea
|
||||
- GITEA__database__PASSWD=gitea
|
||||
restart: always
|
||||
networks:
|
||||
- gitea
|
||||
volumes:
|
||||
- ./data:/root/gitea
|
||||
- ./config:/root/gitea/config
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /mnt/volume:/data
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "222:22"
|
||||
|
@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 34,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -30,7 +30,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 35,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -62,7 +62,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 36,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -89,23 +89,28 @@
|
||||
"write_files:\n",
|
||||
" - path: /root/docker-compose.yml\n",
|
||||
" content: |\n",
|
||||
" version: '3.3'\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",
|
||||
" - '3306:3306'\n",
|
||||
" expose:\n",
|
||||
" - '3306'\n",
|
||||
" volumes:\n",
|
||||
" - my-db:/var/lib/mysql\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",
|
||||
"\n",
|
||||
"runcmd:\n",
|
||||
" - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -\n",
|
||||
|
@ -1,25 +1,22 @@
|
||||
version: '3.3'
|
||||
services:
|
||||
db:
|
||||
image: mysql:5.7
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_DATABASE: 'gitea'
|
||||
# So you don't have to use root, but you can if you like
|
||||
MYSQL_USER: 'gitea'
|
||||
# You can use whatever password you like
|
||||
MYSQL_PASSWORD: 'gitea'
|
||||
# Password for root access
|
||||
MYSQL_ROOT_PASSWORD: 'gitea'
|
||||
ports:
|
||||
# <Port exposed> : < MySQL Port running inside container>
|
||||
- '3306:3306'
|
||||
expose:
|
||||
# Opens port 3306 on the container
|
||||
- '3306'
|
||||
# Where our data will be persisted
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
db:
|
||||
image: mysql:5.7
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_DATABASE: gitea
|
||||
MYSQL_USER: gitea
|
||||
MYSQL_PASSWORD: gitea
|
||||
MYSQL_ROOT_PASSWORD: gitea
|
||||
ports:
|
||||
- "10.10.10.2:3306:3306"
|
||||
volumes:
|
||||
- my-db:/var/lib/mysql
|
||||
phpmyadmin:
|
||||
image: phpmyadmin
|
||||
restart: always
|
||||
ports:
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- my-db:/var/lib/mysql
|
||||
# Names our volume
|
||||
volumes:
|
||||
my-db:
|
||||
my-db: {}
|
BIN
hetzner/sigma/computeC
Normal file
BIN
hetzner/sigma/computeC
Normal file
Binary file not shown.
169
hetzner/vscode/cloud-init.ipynb
Normal file
169
hetzner/vscode/cloud-init.ipynb
Normal file
@ -0,0 +1,169 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Key s444498-pzc-ssh-key-2 already in use: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAj15oTbXA0KGBw5V/76KXDgJZpLNrxUO/rTA0u0eRl1 wirus@wirusowylapek\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from hcloud import Client\n",
|
||||
"client = Client(\n",
|
||||
" token=\"KccUEiddxtzGoLWSNC3V8tylq7MYHCjdnShtgasQ8jSbHqCjGoaa6Rq7yoz4uS23\"\n",
|
||||
")\n",
|
||||
"PREFIX = \"s444498\"\n",
|
||||
"YOUR_LOCAL_SSH_PUBKEY = \"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAj15oTbXA0KGBw5V/76KXDgJZpLNrxUO/rTA0u0eRl1 wirus@wirusowylapek\"\n",
|
||||
"try:\n",
|
||||
" ssh_key = client.ssh_keys.create(name=f\"{PREFIX}-pzc-ssh-key-2\", public_key=YOUR_LOCAL_SSH_PUBKEY)\n",
|
||||
" print(f\"Key {ssh_key.data_model.name} created: {ssh_key.data_model.public_key}\")\n",
|
||||
"except:\n",
|
||||
" ssh_key = client.ssh_keys.get_by_name(f\"{PREFIX}-pzc-ssh-key-2\")\n",
|
||||
" print(f\"Key {ssh_key.data_model.name} already in use: {ssh_key.data_model.public_key}\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 35,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Network in use: s444498-pzc-test-vnet (10.10.10.0/24)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from hcloud.networks.domain import NetworkSubnet\n",
|
||||
"\n",
|
||||
"try:\n",
|
||||
" vnet = client.networks.create(\n",
|
||||
" name=f\"{PREFIX}-pzc-test-vnet\", \n",
|
||||
" ip_range=\"10.10.10.0/24\", \n",
|
||||
" subnets=[\n",
|
||||
" NetworkSubnet(ip_range=\"10.10.10.0/24\", network_zone=\"eu-central\", type=\"cloud\")\n",
|
||||
" ]\n",
|
||||
" )\n",
|
||||
" print(f\"Created network: {vnet.data_model.name} ({vnet.data_model.ip_range})\")\n",
|
||||
"except:\n",
|
||||
" vnet = client.networks.get_by_name(\n",
|
||||
" f\"{PREFIX}-pzc-test-vnet\", \n",
|
||||
" )\n",
|
||||
" print(f\"Network in use: {vnet.data_model.name} ({vnet.data_model.ip_range})\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Creating gitea server: True\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from hcloud.locations.domain import Location\n",
|
||||
"from hcloud.images.domain import Image\n",
|
||||
"from hcloud.server_types.domain import ServerType\n",
|
||||
"\n",
|
||||
"cloud_init_mysql=r'''#cloud-config\n",
|
||||
"packages:\n",
|
||||
" - apt-transport-https\n",
|
||||
" - ca-certificates\n",
|
||||
" - curl\n",
|
||||
" - gnupg-agent\n",
|
||||
" - 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",
|
||||
"\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",
|
||||
" '''\n",
|
||||
"\n",
|
||||
"mysql_server = client.servers.create(\n",
|
||||
" name=f\"{PREFIX}-mysql\", \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",
|
||||
")\n",
|
||||
"\n",
|
||||
"mysql_server.action.wait_until_finished()\n",
|
||||
"print(f\"Creating gitea server: {mysql_server.action.complete}\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.10.8 64-bit",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.8"
|
||||
},
|
||||
"orig_nbformat": 4,
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
"hash": "767d51c1340bd893661ea55ea3124f6de3c7a262a8b4abca0554b478b1e2ff90"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
Loading…
Reference in New Issue
Block a user