Skip to content

Install with Docker

Andreas Backström edited this page Aug 27, 2024 · 5 revisions

Note

There are multiple ways you can host BookLogr. This guide goes through the recommended way of installing it on your own hardware but depending on your needs certain steps can be altered as you deem neccessary.

Prerequisites

Clone repository

Start by cloning the BookLogr release into a suitable directory, git clone --branch v1.0.0 --single-branch https://github.com/Mozzo1000/booklogr.git

Edit .env

Go to the booklogr directory and copy the .env.example file and rename it to .env. Edit the .env file as needed.

See ENV-variables.md for more information

Edit docker-compose.yml

In the docker-compose.yml file, there are some values that need to be changed. These are marked with a comment CHANGE THIS FOR USE IN PRODUCTION!

Start the containers

From the booklogr directory, run docker compose up -d to start all docker services in the background.

Reverse proxy (nginx)

It is recommended to use a reverse proxy for the docker containers when wanting to access them externally.

Create Nginx configuration file for api service

sudo nano /etc/nginx/sites-available/api.booklogr

Paste the following inside the file,

server {
    server_name api.YOUR_DOMAIN;

    location / {
            proxy_pass http://127.0.0.1:5002;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Change api.YOURDOMAIN to the public domain you want the api service to be accessible from.

Create Nginx configuration file for auth service

sudo nano /etc/nginx/sites-available/auth.booklogr

Paste the following inside the file,

server {
    server_name auth.YOUR_DOMAIN;

    location / {
            proxy_pass http://127.0.0.1:5001;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Change auth.YOURDOMAIN to the public domain you want the api service to be accessible from.

Enable both configuration files,

sudo ln -s /etc/nginx/sites-available/api.booklogr /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/auth.booklogr /etc/nginx/sites-enabled/

Restart Nginx service

sudo systemctl restart nginx

Build web interface

Go to the web directory and copy the .env.example file and rename it to .env. Edit this .env file as needed. Primarily, the env variables VITE_API_ENDPOINT and VITE_AUTH_API_URL need to reflect the IP/hostname of the services exposed through the proxy service.

Example for https://demo.booklogr.app, the .env file looks like:

VITE_API_ENDPOINT="https://api.booklogr.app"
VITE_AUTH_API_URL="https://auth.booklogr.app"
VITE_GOOGLE_CLIENT_ID=XXX.apps.googleusercontent.com
VITE_DISABLE_HOMEPAGE=true

See also ENV-variables.md for more information

From web directory, run npm install and npm run build. Copy the files created in the dist folder to your web server.

Note

Building the web interface does not need to be done on the server that will host the files.

Serving web interface with Nginx

Note

You do not need to use Nginx. Apache or any other web server able to serve HTML and Javascript files should work.

Create a directory for the html files, sudo mkdir /var/www/booklogr

Copy all files from the dist folder from the step above to /var/www/booklogr

Create Nginx configuration file

sudo nano /etc/nginx/sites-available/booklogr-web

Paste the following inside the file,

server {
    listen 80;
    listen [::]:80;

    root /var/www/booklogr;
    index index.html index.htm;

    server_name YOUR_DOMAIN;

    location / {
            try_files $uri $uri/ =404;
    }
}

Enable the new nginx configuration,

sudo ln -s /etc/nginx/sites-available/booklogr-web /etc/nginx/sites-enabled/

Restart Nginx service

sudo systemctl restart nginx

🎉 You should now be able to go to YOUR_DOMAIN and have a working BookLogr service running! 🎉

Tip

It is recommended to use an SSL certificate for all web services, especially if you are hosting BookLogr for external use.

Clone this wiki locally