This commit is contained in:
Kamil Guttmann 2023-01-18 20:41:58 +01:00
parent cf883ca8ad
commit a8df3e8130
4 changed files with 34 additions and 3 deletions

32
README.md Normal file
View File

@ -0,0 +1,32 @@
# Webservice automatic deployment on Hetzner Cloud
## Getting started
First you need to create a python virtual environment and activate it:
```
python3 -m venv venv
source venv/bin/activate
```
Next you need to install required dependencies using pip:
```
pip install hcloud
```
To deploy the webservice simply run the `deploy.py` script providing the token to Hetzner Cloud and ssh key as arguments:
```
python3 deploy.py <HETZNER_TOKEN> <PUBLIC_SSH_KEY>
```
To remove the created servers run the `clean.py` script:
```
python3 clean.py <HETZNER_TOKEN>
```
You can also use the `deploy.sh` script to run all above commands.
```
chmod +x deploy.sh
./deploy.sh <HETZNER_TOKEN> <PUBLIC_SSH_KEY>
```

View File

@ -8,7 +8,6 @@ subnet_name = prefix+"-webservice-subnet"
server_name = prefix+"-webservice-server" server_name = prefix+"-webservice-server"
load_balancer_name = prefix+"-webservice-loadbalancer" load_balancer_name = prefix+"-webservice-loadbalancer"
public_key = sys.argv[2]
token = sys.argv[1] token = sys.argv[1]
server_count = 5 server_count = 5

View File

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
source venv/bin/activate source venv/bin/activate
python3 clean.py <HETZNER_TOKEN> <SSH_PUBLIC_KEY> python3 clean.py "$1"

2
deploy.sh Normal file → Executable file
View File

@ -2,4 +2,4 @@
python3 -m venv venv python3 -m venv venv
source venv/bin/activate source venv/bin/activate
pip install hcloud pip install hcloud
python3 deploy.py <HETZNER_TOKEN> <SSH_PUBLIC_KEY> python3 deploy.py "$1" "$2"