refactor(docker-compose and db init): rewrote docker-compose to work purely with env variables
It is possible to rename the default db in a postgres container instance via an env variable. This renders the initdb script useless. The only shortcoming is that the app now uses the db root user which is not ideal but its fine for a dev environment.
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ test-queries
|
||||
Contributing.md
|
||||
ISSUE_TEMPLATE.md
|
||||
lerna.json
|
||||
.env
|
||||
**/.env
|
||||
.env.example
|
||||
.eslintrc.json
|
||||
.mocharc.js
|
||||
|
||||
+9
-14
@@ -1,7 +1,5 @@
|
||||
version: "3"
|
||||
services:
|
||||
|
||||
# this could be enabled once the server container is added
|
||||
server:
|
||||
build:
|
||||
.
|
||||
@@ -11,41 +9,38 @@ services:
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
DEBUG: "speckle:*"
|
||||
DEBUG: "speckle:*"
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
database:
|
||||
image: "postgres" # use latest official postgres version
|
||||
env_file:
|
||||
- .env # configure postgres
|
||||
image: "postgres:13.1-alpine" # use the current alpine version for smaller image
|
||||
environment:
|
||||
POSTGRES_DB:
|
||||
POSTGRES_USER:
|
||||
POSTGRES_PASSWORD:
|
||||
volumes:
|
||||
# persist data even if container shuts down
|
||||
- speckle-postgres-data:/var/lib/postgresql/data/
|
||||
# this mounts the initdb folder to the db container
|
||||
# .sql .sh files are executed from this folder in alphabetical order
|
||||
- ./initdb:/docker-entrypoint-initdb.d
|
||||
ports:
|
||||
- "5432:5432"
|
||||
|
||||
pgadmin:
|
||||
image: dpage/pgadmin4
|
||||
environment:
|
||||
PGADMIN_DEFAULT_EMAIL: "${PGADMIN_EMAIL}"
|
||||
PGADMIN_DEFAULT_PASSWORD: "${PGADMIN_PASSWORD}"
|
||||
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
|
||||
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
|
||||
ports:
|
||||
- "16543:80"
|
||||
depends_on:
|
||||
- database
|
||||
|
||||
redis:
|
||||
image: "redis"
|
||||
image: "redis:6.0-alpine"
|
||||
ports:
|
||||
- "6379:6379" # It is not neccesary to expose the reddis port if running the app with compose
|
||||
volumes:
|
||||
- redis_volume_data:/data
|
||||
# - ./redis.conf:/tmp/redis.conf
|
||||
# command: [ "redis-server", "/tmp/redis.conf"]
|
||||
|
||||
redis_insight:
|
||||
image: redislabs/redisinsight:latest
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo Running Speckle Server initial database setup
|
||||
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||
CREATE USER $SPECKLE_DB_USER WITH PASSWORD '$SPECKLE_DB_PASSWORD';
|
||||
CREATE DATABASE $SPECKLE_DB_NAME;
|
||||
GRANT ALL PRIVILEGES ON DATABASE $SPECKLE_DB_NAME TO $SPECKLE_DB_USER;
|
||||
EOSQL
|
||||
Reference in New Issue
Block a user