1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-12 11:15:22 +02:00
pigallery2/docker
2020-01-04 12:34:45 +01:00
..
alpine docker alpine test 2020-01-01 14:15:15 +01:00
debian-stretch docker alpine test 2020-01-01 14:15:15 +01:00
docker-compose preparing v1.8.0 2019-12-30 21:39:05 +01:00
README.md Update README.md 2020-01-04 12:34:45 +01:00

PiGallery2 docker installation Docker build

You can use docker to run PiGallery2. See all available docker tags here. available tags:

  • v* (stable): built from the a release with the same version name.
  • latest (stable): same as the latest v*, built with debian stretch
  • nightly : built from the current state of master. This might break from time to time.

We support multiple architectures, including amd64, arm32v7, arm64v8.

Official installation guide here, but this will most likely do the trick (source):

curl -sSL https://get.docker.com | sh

I. Docker compose

It is recommended to use docker-compose to run pigallery2.

I.0 Install docker-compose

Official dokcer-compose installation guide here, but this will most likely do the trick (source): Install dependencies:

sudo apt-get install libffi-dev libssl-dev
sudo apt-get install -y python python-pip
sudo apt-get remove python-configparser

Install docker-compose:

sudo pip install docker-compose

You can check if it was successful with docker-compose --version.

I.1 get docker-compose.yml file

Download docker-compose/default/docker-compose.yml and docker-compose/default/nginx.conf.

Edit docker-compose.yml to point the volumes to the right image and tmp directories. Edit nginx.conf by replacing yourdomain.com to you domain address.

Note: Do not change the image and the tmp path in the config.json or in the UI, only through the volume settings of the docker. See here and here.

Note: We are using nginx as reverse proxy to handle https and do proper HTTP queuing, gzipping, etc. Full nginx-based docker-compose tutorial here.

Note 2: You can skip nginx, by using docker-compose/pigallery2-only/docker-compose.yml.

I.1.a get SSL certificate with certbot

Install certbot: https://certbot.eff.org/. (Certbot uses letsencrypt to get free certificate). Than get your certificate:

certbot certonly --standalone -d yourdomain.com

I.1.b start docker-compose

In the folder that has docker-compose.yml:

docker-compose up -d

-d runs it as a daemon. Remove it, so you will see the logs.

After the containers are up and running, you go to yourdomain.com and log in with user: admin pass: admin and set up the page in the settings.

Note: docker-compose.yml contains restart:always, so the containers will be automatically started after reboot (read more here).

I.2 upgrade to newer version

docker-compose pull # get new version
docker-compose down # stop running container
docker system prune # from time to time its nice to clean up docker
docker-compose up -d # start containers

II. Without docker-compose

If you want to run the container by yourself, here you go:

docker run \
   -p 80:80 \
   -e NODE_ENV=production \
   -v <path to your config file folder>/config.json:/app/data/config/config.json \
   -v <path to your db file folder>:/app/data/db \
   -v <path to your images folder>:/app/data/images \
   -v <path to your temp folder>:/app/data/tmp \
   bpatrik/pigallery2:latest

After the container is up and running, you go to http://localhost and log in with user: admin pass: admin and set up the page in the settings.

Note: even with memory db, pigallery2 creates a db file for storing user credentials (if enabled), so mounting (with -v) the /app/data/db folder is recommended.

Note2: Do not change the image and the tmp path in the config.json or in the UI, only through the volume settings of the docker. See here and here.

II.a before v1.7.0

There was a breaking change in Docker files after v1.7.0. Use this to run earlier versions:

docker run \
   -p 80:80 \
   -e NODE_ENV=production \
   -v <path to your config file folder>/config.json:/pigallery2-release/config.json \
   -v <path to your db file folder>/sqlite.db:/pigallery2-release/sqlite.db \
   -v <path to your images folder>:/pigallery2-release/demo/images \
   -v <path to your temp folder>:/pigallery2-release/demo/TEMP \
   bpatrik/pigallery2:1.7.0-stretch

Make sure that a file at <path to your config file folder>/config.json and sqlite.db files exists before running it.

You do not need the <path to your db file folder>/sqlite.db line if you don't use the sqlite database.

Build the Docker image on your own

You can clone the repository and build the image, or you can just use the 'self-contained' Dockerfile: debian-stretch/selfcontained/Dockerfile