docker: make deployment easier
This commit is contained in:
parent
7081b5be90
commit
987a3aa8f2
5 changed files with 85 additions and 107 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,5 +1,5 @@
|
|||
config.yaml
|
||||
docker-compose.yml
|
||||
.env
|
||||
*/*_modules/
|
||||
.coverage
|
||||
.cache
|
||||
|
|
|
@ -26,12 +26,12 @@ and Docker Compose (version 1.6.0 or greater) already installed.
|
|||
3. Configure Docker Compose:
|
||||
|
||||
```console
|
||||
user@host:szuru$ cp docker-compose.yml.example docker-compose.yml
|
||||
user@host:szuru$ edit docker-compose.yml
|
||||
user@host:szuru$ cp example.env .env
|
||||
user@host:szuru$ edit .env
|
||||
```
|
||||
|
||||
Read the comments to guide you. For production use, it is *important*
|
||||
that you configure the volumes appropriately to avoid data loss.
|
||||
Change the values of the variables in `.env` as needed.
|
||||
Read the comments to guide you.
|
||||
|
||||
### Running the Application
|
||||
|
||||
|
|
64
docker-compose.yml
Normal file
64
docker-compose.yml
Normal file
|
@ -0,0 +1,64 @@
|
|||
## Example Docker Compose configuration
|
||||
##
|
||||
## Use this as a template to set up docker-compose, or as guide to set up other
|
||||
## orchestration services
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
api:
|
||||
build:
|
||||
context: ./server
|
||||
depends_on:
|
||||
- sql
|
||||
- elasticsearch
|
||||
environment:
|
||||
## These should be the names of the dependent containers listed above,
|
||||
## or FQDNs/IP addresses if these services are running outside of Docker
|
||||
POSTGRES_HOST: sql
|
||||
ESEARCH_HOST: elasticsearch
|
||||
## Credentials for database:
|
||||
POSTGRES_USER:
|
||||
POSTGRES_PASSWORD:
|
||||
## Commented Values are Default:
|
||||
#POSTGRES_DB: defaults to same as POSTGRES_USER
|
||||
#POSTGRES_PORT: 5432
|
||||
#ESEARCH_PORT: 9200
|
||||
#ESEARCH_INDEX: szurubooru
|
||||
#LOG_SQL: 0 (1 for verbose SQL logs)
|
||||
volumes:
|
||||
- "${MOUNT_DATA}:/data"
|
||||
- "./server/config.yaml:/opt/app/config.yaml"
|
||||
client:
|
||||
build:
|
||||
context: ./client
|
||||
args:
|
||||
BUILD_INFO:
|
||||
depends_on:
|
||||
- api
|
||||
environment:
|
||||
BACKEND_HOST: api
|
||||
volumes:
|
||||
- "${MOUNT_DATA}:/data:ro"
|
||||
ports:
|
||||
- "${PORT}:80"
|
||||
sql:
|
||||
image: postgres:alpine
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER:
|
||||
POSTGRES_PASSWORD:
|
||||
volumes:
|
||||
- "${MOUNT_SQL}:/var/lib/postgresql/data"
|
||||
elasticsearch:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.1
|
||||
environment:
|
||||
## Specifies the Java heap size used
|
||||
## Read
|
||||
## https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
|
||||
## for more info
|
||||
ES_JAVA_OPTS: -Xms512m -Xmx512m
|
||||
volumes:
|
||||
- index:/usr/share/elasticsearch/data
|
||||
|
||||
volumes:
|
||||
index: # Scratch space for ElasticSearch index, will be rebuilt if lost
|
|
@ -1,102 +0,0 @@
|
|||
## Example Docker Compose configuration
|
||||
##
|
||||
## Use this as a template to set up docker-compose, or as guide to set up other
|
||||
## orchestration services
|
||||
|
||||
version: '2'
|
||||
services:
|
||||
|
||||
## Python3 container for backend API
|
||||
backend:
|
||||
build:
|
||||
context: ./server
|
||||
depends_on:
|
||||
- sql
|
||||
- elasticsearch
|
||||
environment: # Commented Values are Default
|
||||
## These should be the names of the dependent containers listed above, or
|
||||
## accessible hostnames/IP addresses if these services are running
|
||||
## outside of Docker
|
||||
POSTGRES_HOST: sql
|
||||
ESEARCH_HOST: elasticsearch
|
||||
## Credentials for database
|
||||
POSTGRES_USER: szuru
|
||||
POSTGRES_PASSWORD: badpass
|
||||
## Leave commented if using the official postgres container,
|
||||
## it will default to the value in POSTGRES_USER
|
||||
#POSTGRES_DB:
|
||||
## Leave commented if using the default port 5432
|
||||
#POSTGRES_PORT: 5432
|
||||
## Leave commented if using the default port 9200
|
||||
#ESEARCH_PORT: 9200
|
||||
## Uncomment and change if you want to use a different index
|
||||
#ESEARCH_INDEX: szurubooru
|
||||
## Leave commented unless you want verbose SQL in the container logs
|
||||
#LOG_SQL: 1
|
||||
volumes:
|
||||
- data:/data
|
||||
## If more customizations that are not covered in `config.yaml.dist` are needed
|
||||
## Comment this line if you are not going
|
||||
## to supply a YAML file
|
||||
- ./server/config.yaml:/opt/app/config.yaml
|
||||
|
||||
## HTTP container for frontend
|
||||
frontend:
|
||||
build:
|
||||
context: ./client
|
||||
args:
|
||||
## This shows up on the homescreen, indicating build information
|
||||
## Change as desired
|
||||
BUILD_INFO: docker-example
|
||||
depends_on:
|
||||
- backend
|
||||
environment:
|
||||
## This should be the name of the previous container
|
||||
BACKEND_HOST: backend
|
||||
volumes:
|
||||
- data:/data:ro
|
||||
ports:
|
||||
## If you want to expose the website on another port like 80,
|
||||
## change to 80:80
|
||||
- 8080:80
|
||||
|
||||
## PostgreSQL container for database
|
||||
sql:
|
||||
image: postgres:alpine
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
## These should equal the same credentials as used on the first container
|
||||
POSTGRES_USER: szuru
|
||||
POSTGRES_PASSWORD: badpass
|
||||
volumes:
|
||||
- database:/var/lib/postgresql/data
|
||||
|
||||
## ElasticSearch container for image indexing
|
||||
elasticsearch:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.1
|
||||
environment:
|
||||
## Specifies the Java heap size used
|
||||
## Read
|
||||
## https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
|
||||
## for more info
|
||||
ES_JAVA_OPTS: -Xms512m -Xmx512m
|
||||
volumes:
|
||||
- index:/usr/share/elasticsearch/data
|
||||
|
||||
volumes:
|
||||
## IMPORTANT FOR PRODUCTION USE:
|
||||
## To avoid data loss, you should read and understand how Docker volumes work
|
||||
## before proceeding. Information can be found on
|
||||
## https://docs.docker.com/storage/volumes/
|
||||
## These mounts should be configured with drivers apporpriate for your system.
|
||||
## For small deployments, bind mounts or using the local-persist driver should
|
||||
## be fine. Make sure you mount to a directory that is safe and backed up.
|
||||
## local-persist driver can be found at:
|
||||
## https://github.com/CWSpear/local-persist
|
||||
## It is okay to leave these as-is for development or testing purposes
|
||||
|
||||
data: # This volume will hold persistant Image and User data for the board
|
||||
|
||||
database: # This holds the SQL database
|
||||
|
||||
index: # Scratch space for ElasticSearch Index
|
16
example.env
Normal file
16
example.env
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Database credentials
|
||||
POSTGRES_USER=szuru
|
||||
POSTGRES_PASSWORD=changeme
|
||||
|
||||
# This shows up on the homescreen, indicating build information
|
||||
BUILD_INFO=latest
|
||||
|
||||
# Port to expose HTTP service
|
||||
PORT=8080
|
||||
|
||||
# Directory to store image data
|
||||
MOUNT_DATA=/var/local/szurubooru/data
|
||||
|
||||
# Directory to store database files
|
||||
MOUNT_SQL=/var/local/szurubooru/sql
|
||||
|
Loading…
Reference in a new issue