Update README.md installation method locally

This commit is contained in:
CronyAkatsuki 2023-03-26 13:53:33 +02:00
parent 870cb5e08b
commit 2c5737e4cd

View File

@ -8,21 +8,57 @@ simple tool for uploading and sharing files that is selfhostable.
To run on a regular system I recommend to use a virtual environment to install the dependencies and run the project from there.
We will also be setting up an specific user to run the app as safe as possible with a systemd service file for startup
```bash
# Create the virtual environment
python -m venv venv
# Create the user (You can specify a different home-dir)
sudo useradd --shell /bin/bash --system \
--home-dir "/usr/local/upfast" -m upfast
# Change to upfast user and cd /usr/local/upfast
su upfast
cd /usr/local/upfast
# Clone the project directly into upfast-src directory
git clone https://code.cronyakatsuki.xyz/crony/upfast upfast-src
# Create the virtual environment and load it for user on default
python3 -m venv venv
echo "source /usr/local/upfast/venv/bin/activate" > "/usr/local/upfast/.profile"
# Activate the virtual environment
source venv/bin/activate
# Install all the requirements
cd upfast-src/
pip install -r requirements.txt
# create the upload directory
mkdir upload
# Run the project
uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*'
```
#### Autostart with systemd
To autostart with systemd you will need to create a systemd .service file in path `/etc/systemd/system/upfast.service` and add this content to it.
```systemd
[Unit]
Description=UpFast service
Documentation=https://code.cronyakatsuki.xyz/crony/upfast
[Service]
User=upfast
Group=upfast
WorkingDirectory=/usr/local/upfast/upfast-src
ExecStart=/usr/local/upfast/venv/bin/uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*'
Restart=on-failure
```
Then just run `sudo systemctl daemon-reload` and enable the service with `sudo systemctl enable upfast.service`
### Docker
In the repo there is an included dockerfile to generate an image from the latest version of everything, to generate an image just run `docker build . -t upfast` (You need root privileges or to be in the docker group).