summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShyam Sunder <sgsunder1@gmail.com>2018-09-23 19:35:42 -0400
committerrr- <rr-@sakuya.pl>2018-12-22 12:31:25 +0100
commit987a3aa8f2a7b5f286e6e7cbda4c8894eb3a35ed (patch)
treef793ae05faf38f57d51da7ef4e9a49567bdfb48b
parent7081b5be9075c3385f33a9a9c053fd6f36f0cd18 (diff)
docker: make deployment easier
-rw-r--r--.gitignore2
-rw-r--r--INSTALL.md8
-rw-r--r--docker-compose.yml64
-rw-r--r--docker-compose.yml.example102
-rw-r--r--example.env16
5 files changed, 85 insertions, 107 deletions
diff --git a/.gitignore b/.gitignore
index 0a6eb18..dc476e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
config.yaml
-docker-compose.yml
+.env
*/*_modules/
.coverage
.cache
diff --git a/INSTALL.md b/INSTALL.md
index 6465235..7c156e6 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -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
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..108613f
--- /dev/null
+++ b/docker-compose.yml
@@ -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
diff --git a/docker-compose.yml.example b/docker-compose.yml.example
deleted file mode 100644
index ab8ab2e..0000000
--- a/docker-compose.yml.example
+++ /dev/null
@@ -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
diff --git a/example.env b/example.env
new file mode 100644
index 0000000..25a6235
--- /dev/null
+++ b/example.env
@@ -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
+