mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
adding docker-compose files and docker documentation
This commit is contained in:
parent
3f7751024e
commit
dea0fd00ec
31
README.md
31
README.md
@ -2,7 +2,7 @@
|
|||||||
[](https://badge.fury.io/js/pigallery2)
|
[](https://badge.fury.io/js/pigallery2)
|
||||||
[](https://travis-ci.org/bpatrik/pigallery2)
|
[](https://travis-ci.org/bpatrik/pigallery2)
|
||||||
[](https://pigallery2.herokuapp.com)
|
[](https://pigallery2.herokuapp.com)
|
||||||
[](https://hub.docker.com/r/bpatrik/pigallery2/)
|

|
||||||
[](https://david-dm.org/bpatrik/pigallery2)
|
[](https://david-dm.org/bpatrik/pigallery2)
|
||||||
[](https://david-dm.org/bpatrik/pigallery2?type=dev)
|
[](https://david-dm.org/bpatrik/pigallery2?type=dev)
|
||||||
|
|
||||||
@ -27,19 +27,27 @@ Live Demo @ heroku: https://pigallery2.herokuapp.com/
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 1. Getting started (on Raspberry Pi)
|
## 1. Getting started (also works on Raspberry Pi)
|
||||||
### 1.1 Direct Install
|
|
||||||
### 1.1.0 [Install NodeJs](https://nodejs.org/en/download/)
|
### 1.1 Run with Docker
|
||||||
|
If you have `docker` and don't want to install all the dependencies, you can use one of our docker build.
|
||||||
|
For configuration and docker-compose files read more [here](docker/README.md) or check all builds: https://hub.docker.com/r/bpatrik/pigallery2/tags/
|
||||||
|
|
||||||
|
**Note**: You dont need to do the installation steps if you are using docker.
|
||||||
|
|
||||||
|
|
||||||
|
### 1.2 Direct Install
|
||||||
|
### 1.2.0 [Install NodeJs](https://nodejs.org/en/download/)
|
||||||
Download and extract
|
Download and extract
|
||||||
```bash
|
```bash
|
||||||
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
|
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
|
||||||
sudo apt-get install -y nodejs
|
sudo apt-get install -y nodejs
|
||||||
```
|
```
|
||||||
|
|
||||||
Full node install on raspberry pi description: https://www.w3schools.com/nodejs/nodejs_raspberrypi.asp
|
Full node install on raspberry pi description: https://www.w3schools.com/nodejs/nodejs_raspberrypi.asp
|
||||||
|
|
||||||
### 1.1.1 Install PiGallery2
|
### 1.2.1 Install PiGallery2
|
||||||
#### 1.1.1-a Install from release
|
#### 1.2.1-a Install from release
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd ~
|
cd ~
|
||||||
@ -48,7 +56,7 @@ unzip pigallery2.zip -d pigallery2
|
|||||||
cd pigallery2
|
cd pigallery2
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
#### 1.1.1-b Install from source
|
#### 1.2.1-b Install from source
|
||||||
```bash
|
```bash
|
||||||
cd ~
|
cd ~
|
||||||
wget https://github.com/bpatrik/pigallery2/archive/master.zip
|
wget https://github.com/bpatrik/pigallery2/archive/master.zip
|
||||||
@ -61,7 +69,7 @@ npm build
|
|||||||
|
|
||||||
**Note2**: you can use `npm run create-release -- --languages=fr,ro` to restrict building to the listed languages (english is added by default)
|
**Note2**: you can use `npm run create-release -- --languages=fr,ro` to restrict building to the listed languages (english is added by default)
|
||||||
|
|
||||||
#### 1.1.2 Run PiGallery2
|
#### 1.2.2 Run PiGallery2
|
||||||
```bash
|
```bash
|
||||||
npm start
|
npm start
|
||||||
```
|
```
|
||||||
@ -69,11 +77,6 @@ To configure it, run `PiGallery2` first to create `config.json` file, then edit
|
|||||||
The app has a nice UI for settings, you may use that too.
|
The app has a nice UI for settings, you may use that too.
|
||||||
Default user: `admin` pass: `admin`
|
Default user: `admin` pass: `admin`
|
||||||
|
|
||||||
### 1.2 Run with Docker
|
|
||||||
If you have `docker` and don't want to install all the dependencies, you can use one of our docker build.
|
|
||||||
For configuration read more [here](docker/README.md) or check all builds: https://hub.docker.com/r/bpatrik/pigallery2/tags/
|
|
||||||
|
|
||||||
**Note**: You dont need to do the installation steps if you are using docker.
|
|
||||||
|
|
||||||
|
|
||||||
### 1.3 Advanced configuration
|
### 1.3 Advanced configuration
|
||||||
|
@ -1,16 +1,71 @@
|
|||||||
# PiGallery2 docker installation [](https://hub.docker.com/r/bpatrik/pigallery2/)
|
# PiGallery2 docker installation 
|
||||||
|
|
||||||
You can use [docker](https://docs.docker.com/install/) to run PiGallery2.
|
You can use [docker](https://docs.docker.com/install/) to run PiGallery2. See all available docker tags here: https://hub.docker.com/r/bpatrik/pigallery2/tags/
|
||||||
|
|
||||||
## all docker tags
|
|
||||||
https://hub.docker.com/r/bpatrik/pigallery2/tags/
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
If you have `docker` and don't want to install all the dependencies, use this:
|
###0. Install docker
|
||||||
|
Official installation guide [here](https://docs.docker.com/install/),
|
||||||
|
but this will most likely do the trick ([source](https://dev.to/rohansawant/installing-docker-and-docker-compose-on-the-raspberry-pi-in-5-simple-steps-3mgl)):
|
||||||
|
```bash
|
||||||
|
curl -sSL https://get.docker.com | sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## I. Docker compose
|
||||||
|
It is recommended to use [docker-compose](https://docs.docker.com/compose/) to run pigallery2.
|
||||||
|
|
||||||
|
### I.0 Install docker-compose
|
||||||
|
Official dokcer-compose installation guide [here](https://docs.docker.com/compose/install/),
|
||||||
|
but this will most likely do the trick ([source](https://dev.to/rohansawant/installing-docker-and-docker-compose-on-the-raspberry-pi-in-5-simple-steps-3mgl)):
|
||||||
|
Install dependencies:
|
||||||
|
```bash
|
||||||
|
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:
|
||||||
|
```bash
|
||||||
|
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](docker-compose/default/docker-compose.yml) and
|
||||||
|
[docker-compose/default/nginx.conf](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:** We are using nginx as reverse proxy to handle https and do proper HTTP queuing, gzipping, etc. Full nginx-based docker-compose tutorial [here](https://www.domysee.com/blogposts/reverse-proxy-nginx-docker-compose).
|
||||||
|
|
||||||
|
**Note 2:** You can skip nginx, by using [docker-compose/pigallery2-only/docker-compose.yml](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:
|
||||||
|
```bash
|
||||||
|
certbot certonly --standalone -d yourdomain.com
|
||||||
|
```
|
||||||
|
|
||||||
|
#### I.1.a start docker-compose
|
||||||
|
In the folder that has `docker-compose.yml`:
|
||||||
|
```bash
|
||||||
|
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](https://stackoverflow.com/questions/43671482/how-to-run-docker-compose-up-d-at-system-start-up)).
|
||||||
|
|
||||||
|
|
||||||
|
## II. Without docker-compose
|
||||||
|
If you want to run the container by yourself, here you go:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run \
|
docker run \
|
||||||
-p 80:80 \
|
-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 config file folder>/config.json:/app/data/config/config.json \
|
||||||
-v <path to your db file folder>:/app/data/db \
|
-v <path to your db file folder>:/app/data/db \
|
||||||
-v <path to your images folder>:/app/data/images \
|
-v <path to your images folder>:/app/data/images \
|
||||||
@ -22,7 +77,7 @@ After the container is up and running, you go to `http://localhost` and log in w
|
|||||||
|
|
||||||
**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.
|
**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.
|
||||||
|
|
||||||
### before v1.7.0
|
### II.a before v1.7.0
|
||||||
There was a breaking change in Docker files after v1.7.0. Use this to run earlier versions:
|
There was a breaking change in Docker files after v1.7.0. Use this to run earlier versions:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -40,6 +95,8 @@ Make sure that a file at `<path to your config file folder>/config.json` and `sq
|
|||||||
You do not need the `<path to your db file folder>/sqlite.db` line if you don't use the sqlite database.
|
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
|
## 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](debian-stretch/selfcontained/Dockerfile)
|
You can clone the repository and build the image, or you can just use the 'self-contained' Dockerfile: [debian-stretch/selfcontained/Dockerfile](debian-stretch/selfcontained/Dockerfile)
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ FROM node:12-alpine
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
# command line arg orverride the config.json with these settings
|
# command line arg orverride the config.json with these settings
|
||||||
ENTRYPOINT ["npm", "start", "--", \
|
ENTRYPOINT ["npm", "start", "--", \
|
||||||
|
# after a extensive job (like video converting), pigallery calls gc, to clean up everthing as fast as possible
|
||||||
|
"--expose-gc", \
|
||||||
"--config-path=/app/data/config/config.json", \
|
"--config-path=/app/data/config/config.json", \
|
||||||
"--Server-Database-sqlite-storage=/app/data/db/sqlite.db", \
|
"--Server-Database-sqlite-storage=/app/data/db/sqlite.db", \
|
||||||
"--Server-Database-memory-usersFile=/app/data/db/users.db", \
|
"--Server-Database-memory-usersFile=/app/data/db/users.db", \
|
||||||
|
@ -12,6 +12,8 @@ FROM node:12-stretch-slim
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
# command line arg orverride the config.json with these settings
|
# command line arg orverride the config.json with these settings
|
||||||
ENTRYPOINT ["npm", "start", "--", \
|
ENTRYPOINT ["npm", "start", "--", \
|
||||||
|
# after a extensive job (like video converting), pigallery calls gc, to clean up everthing as fast as possible
|
||||||
|
"--expose-gc", \
|
||||||
"--config-path=/app/data/config/config.json", \
|
"--config-path=/app/data/config/config.json", \
|
||||||
"--Server-Database-sqlite-storage=/app/data/db/sqlite.db", \
|
"--Server-Database-sqlite-storage=/app/data/db/sqlite.db", \
|
||||||
"--Server-Database-memory-usersFile=/app/data/db/users.db", \
|
"--Server-Database-memory-usersFile=/app/data/db/users.db", \
|
||||||
|
@ -9,22 +9,22 @@ RUN set -x && npm install --unsafe-perm && \
|
|||||||
mkdir -p /build/release/data/images && \
|
mkdir -p /build/release/data/images && \
|
||||||
mkdir -p /build/release/data/tmp && \
|
mkdir -p /build/release/data/tmp && \
|
||||||
npm run create-release && \
|
npm run create-release && \
|
||||||
cd /build/release && npm install --unsafe-perm && \
|
cd /build/release && npm install --unsafe-perm
|
||||||
npm start -- --config-only --force-rewrite-config \
|
|
||||||
--config-path=/app/data/config/config.json \
|
|
||||||
--Server-Database-sqlite-storage='/app/data/db/sqlite.db' \
|
|
||||||
--Server-Database-memory-usersFile='/app/data/db/users.db' \
|
|
||||||
--Server-Media-folder='/app/data/images' \
|
|
||||||
--Server-Media-tempFolder='/app/data/tmp'
|
|
||||||
|
|
||||||
|
|
||||||
FROM node:12-stretch-slim
|
FROM node:12-stretch-slim
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENTRYPOINT ["npm", "start"]
|
ENTRYPOINT ["npm", "start", "--", \
|
||||||
|
# after a extensive job (like video converting), pigallery calls gc, to clean up everthing as fast as possible
|
||||||
|
"--expose-gc", \
|
||||||
|
"--config-path=/app/data/config/config.json", \
|
||||||
|
"--Server-Database-sqlite-storage=/app/data/db/sqlite.db", \
|
||||||
|
"--Server-Database-memory-usersFile=/app/data/db/users.db", \
|
||||||
|
"--Server-Media-folder=/app/data/images", \
|
||||||
|
"--Server-Media-tempFolder=/app/data/tmp"]
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
COPY --from=BUILDER /build/release /app
|
COPY --from=BUILDER /build/release /app
|
||||||
RUN ln -s /app/data/config/config.json config.json
|
|
||||||
VOLUME ["/app/data/config", "/app/data/db", "/app/data/images", "/app/data/tmp"]
|
VOLUME ["/app/data/config", "/app/data/db", "/app/data/images", "/app/data/tmp"]
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --retries=4 --start-period=60s \
|
HEALTHCHECK --interval=30s --timeout=10s --retries=4 --start-period=60s \
|
||||||
CMD wget --quiet --tries=1 --no-check-certificate --spider \
|
CMD wget --quiet --tries=1 --no-check-certificate --spider \
|
||||||
|
31
docker/docker-compose/default/docker-compose.yml
Normal file
31
docker/docker-compose/default/docker-compose.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
nginx:
|
||||||
|
image: nginx:latest
|
||||||
|
container_name: production_nginx
|
||||||
|
volumes:
|
||||||
|
- ./nginx.conf:/etc/nginx/nginx.conf
|
||||||
|
- ./nginx/error.log:/etc/nginx/error_log.log
|
||||||
|
- ./nginx/cache/:/etc/nginx/cache
|
||||||
|
- /etc/letsencrypt/:/etc/letsencrypt/
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
- 443:443
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
pigallery2:
|
||||||
|
image: bpatrik/pigallery2:nightly-stretch
|
||||||
|
container_name: pigallery2
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
volumes:
|
||||||
|
- "./pigallery2/config:/app/data/config"
|
||||||
|
- "db-data:/app/data/db"
|
||||||
|
- "./pigallery2/images:/app/data/images"
|
||||||
|
- "./pigallery2/tmp:/app/data/tmp"
|
||||||
|
expose:
|
||||||
|
- "80"
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db-data:
|
76
docker/docker-compose/default/nginx.conf
Normal file
76
docker/docker-compose/default/nginx.conf
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
events {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
|
||||||
|
##
|
||||||
|
# Basic Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
tcp_nodelay on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
types_hash_max_size 2048;
|
||||||
|
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
##
|
||||||
|
# SSL Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
||||||
|
ssl_prefer_server_ciphers on;
|
||||||
|
|
||||||
|
##
|
||||||
|
# Logging Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
error_log /var/log/nginx/error.log;
|
||||||
|
|
||||||
|
##
|
||||||
|
# Gzip Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
# Virtual Host Configs
|
||||||
|
##
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
|
server_name yourdomain.com www.yourdomain.com;
|
||||||
|
return 301 https://$server_name$request_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
server_name yourdomain.com;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://pigallery2:80; # forwarding to the other container, named 'pigallery2'
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
listen 443 ssl default_server;
|
||||||
|
listen [::]:443 ssl default_server;
|
||||||
|
|
||||||
|
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
|
||||||
|
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||||
|
}
|
||||||
|
}
|
18
docker/docker-compose/pigallery2-only/docker-compose.yml
Normal file
18
docker/docker-compose/pigallery2-only/docker-compose.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
pigallery2:
|
||||||
|
image: bpatrik/pigallery2:nightly-stretch
|
||||||
|
container_name: pigallery2
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
volumes:
|
||||||
|
- "./pigallery2/config:/app/data/config"
|
||||||
|
- "db-data:/app/data/db"
|
||||||
|
- "./pigallery2/images:/app/data/images"
|
||||||
|
- "./pigallery2/tmp:/app/data/tmp"
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db-data:
|
Loading…
x
Reference in New Issue
Block a user