1
0
forked from crony/UpFast
UpFast/README.md

106 lines
2.9 KiB
Markdown
Raw Normal View History

2023-03-23 21:00:39 +01:00
# UpFast
2023-03-26 16:03:38 +02:00
Simple tool for uploading and sharing files that you can self-host.
## How to host
### Regular system
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 user (You can specify a different home-dir)
sudo useradd --shell /bin/bash --system \
--home-dir "/usr/local/upfast" -m upfast
2023-03-26 16:02:39 +02:00
# Change to upfast user and go to upfast dir
su upfast
2023-03-26 16:02:39 +02:00
cd
# Clone the project directly into upfast-src directory
2023-03-26 16:02:39 +02:00
git clone https://code.cronyakatsuki.xyz/crony/upfast .
# Create the virtual environment and load it for user on default
2023-04-04 18:46:26 +02:00
python3 -m venv env
# Activate the virtual environment
2023-04-04 18:46:26 +02:00
source env/bin/activate
# Install all the requirements
pip install -r requirements.txt
2023-03-26 16:03:18 +02:00
# Load environment by default
echo "source /usr/local/upfast/venv/bin/activate" > "/usr/local/upfast/.profile"
# create the upload directory
mkdir upload
2023-03-26 16:03:38 +02:00
# UpFast go brrr
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
2023-03-26 16:02:39 +02:00
WorkingDirectory=/usr/local/upfast/
2023-04-04 18:46:26 +02:00
ExecStart=/usr/local/upfast/env/bin/uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*'
Restart=on-failure
```
2023-03-26 16:03:38 +02:00
Finally run following commmands.
2023-03-26 17:30:38 +02:00
```bash
2023-03-26 16:03:38 +02:00
# refresh services
2023-03-26 17:30:38 +02:00
sudo systemctl daemon-reload
2023-03-26 16:03:38 +02:00
# enable the service
2023-03-26 17:30:38 +02:00
sudo systemctl enable upfast.service
2023-03-26 16:03:38 +02:00
```
### 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).
To run the docker container check the container id with `docker images` command.
> sample docker run command
```bash
sudo docker run -p 8000:8000 -v ./upload:/usr/src/app/upload CONTAINER_ID
```
2023-03-26 12:27:02 +02:00
The sample command will need an upload directory, you can replace `./upload` with a different path to save uploaded stuff.
### Nginx Proxy setup
This is an example nginx proxy config for http
```nginx
server {
listen 80;
listen [::]:80;
server_name upfast.example.com ;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_buffering off;
}
}
```
2023-03-26 17:39:48 +02:00
# Contributions
Thanks [TLasT](https://craftmenners.men) on his help with testing and documentation.