Update 'Quick Guide to publishing websites on hal.elte.hu with Python3 backend'

master
baskayj 4 years ago
parent
commit
b4b86283f7
  1. 11
      Quick-Guide-to-publishing-websites-on-hal.elte.hu-with-Python3-backend.md

11
Quick-Guide-to-publishing-websites-on-hal.elte.hu-with-Python3-backend.md

@ -1,4 +1,5 @@
# Making a website with Flask
# Quick Guide to publishing websites on hal.elte.hu with Python3 backend
## Making a website with Flask
Requirements:
* Python3 virtual environment
* Flask (`pip3 install Flask`)
@ -18,7 +19,7 @@ Flask-WTF==1.0.0
.
```
# Configuring Apache2
## Configuring Apache2
Since Flask’s built-in server is not fit for live traffic, you need another WSGI server, that’s where Apache2 comes in the picture.
1. Install **Apache2**: `sudo apt-get install apache2`
2. Install **mod_wsgi** compiled with python3: `sudo apt-get install libapache2-mod-wsgi-py3`
@ -99,7 +100,7 @@ Make sure to replace `your_app`, appropriately, and set the location of your pyt
By going to **localhost/your_app** in your browser you should be able to see now your website, and if it has any interacitvity that runs some Python in the background it should work too. This will be up until you turn of you computer, or stop Apache2.
# Testing your website with Docker
## Testing your website with Docker
Since the site on hal.elte.hu will run inside a Docker container, before publishing you should test your work locally. To install Docker visit [this](https://docs.docker.com/get-docker/) link.
Once Docker is up and running, you should make a new project folder **DO NOT USE /var/www/html/!**, and copy `your_app.conf` and the `your_app folder` from `/var/www/html/` inside. (You should omit copying the venv.) Once you're done adding some other scirpts detailed a little further, the folder struture should look like this:
> |----/your_app_docker/
@ -186,7 +187,7 @@ With everything in place go to `/your_app_docker` and run the following commands
Then you should be able to access your website at **localhost:8085/your_app**. Once you're done you can stop and remove both the container and the image.
# Upload your project to Gitea
## Upload your project to Gitea
Now that Docker can run your site with an Apache2 server locally you can upload it to Gitea, so it can also be built and run on hal.elte.hu.
1. Navigate to `/your_app_docker`, you don't need to remove any file, nor you need to add anything.
2. `touch README.md`
@ -197,7 +198,7 @@ Now that Docker can run your site with an Apache2 server locally you can upload
7. `git push -u origin master`
For the push to succed you have to add an ssh public key to your gitea account. (*Settings->SSH/GPG keys->Add Key*) The easiest (laziest) solution would be to upload the public key that corresponds to your `.ssh/is_rsa`.
# Testing Docker & Gitea together
## Testing Docker & Gitea together
Now your site is ready to be deployed, but it's good practice to test ***locally*** first.
1. `docker build --rm -t your_app_img https://hal.elte.hu/gitea/username/your_app.git`
2. `docker run -d --name your_app -p 8085:80 your_app_img`

Loading…
Cancel
Save