Self Hosting

This guide will help you with self hosting Food Server.

If you decide to self-host, you will need a basic understanding of Python as well as Python 3. Having familiarity with databases will also assist.

Table of contents

Setting up Postgres

We recommend using PostgreSQL for the database, as this is tested, and the recommended configuration. Installation of libpq or an equivalent is required to sate food-server's requirement of psycopg2. While others will likely work as SQLAlchemy is used, we will not provide support for such configurations.

You may wish to install a tool such as pgAdmin to easily make database changes.

MacOS

Assuming you use Homebrew, run the following:

brew install postgresql

To start PostgreSQL temporarily, you can run brew services run postgresql. For more information on services via Homebrew, run brew services --help.

Linux

On Debian-based distributions (i.e. Ubuntu or Linux Mint):

apt install libpq-dev python3-dev postgresql postgresql-client

For RHEL-based distributions (i.e. CentOS/Fedora):

dnf install libpq-devel python3-devel postgresql-server

For Arch Linux (Additional configuration may be required after install. Check the Arch Wiki):

pacman -S postgresql-libs postgresql

Many package managers will start PostgreSQL automatically. Typically, you can run systemctl start postgresql to ensure this. Refer to your distribution's documentation for further information.

Creating the database

Once PostgreSQL is finished downloading, you will need to create the database.

If you installed via a package manager on either macOS or a linux based distribution, open the command line of your choice and run the below. It should be noted that in some cases you may need to run these commands with sudo.

psql -c "CREATE USER username WITH PASSWORD 'password';"

psql -c "CREATE DATABASE database_name OWNER owner;"

On Windows you will need to run the above, but first you will need to find the psql binary installed to your system. In the above commands, replace psql with the path to your psql binary.

After all the above is complete, you will need to edit config-example.py with your database credentials and name. Then you will need to rename config-example.py to config.py.

db_url = "postgresql://username:password@localhost/database_name"

Database setup is complete!

Setting up the development environment

You'll most likely want to create a virtualenv to install things. For example:

python3 -m venv virtualenv

Ensure you activate the environment via source venv/bin/activate.

Once done, ensure you install requirements:

You will need to copy config-example.py to config.py and edit accordingly.

Starting food-server

Run in development mode, and enjoy!

For development, we recommend using dev.wiilink24.com as the base domain, resolving to 127.0.0.1. A web panel is available as subdirectory /thepantry/. Its default credentials are username admin/password admin. Please change them.