Skip to content

Commit

Permalink
chore(docker): add postgresql service properly
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed Jun 8, 2022
1 parent c2d3129 commit 76b2261
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 34 deletions.
1 change: 1 addition & 0 deletions .env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ANSIBLE_VAULT_KEY=${ANSIBLE_VAULT_KEY}
ENV=${ENV}
FLOWER_PORT=${FLOWER_PORT}
FLOWER_PASSWORD=${FLOWER_PASSWORD}
HOST_POSTGRES_DUMP=${HOST_POSTGRES_DUMP}
MAPBOX_API_KEY=${MAPBOX_API_KEY}
POSTGRES_HOST=${POSTGRES_HOST}
POSTGRES_PORT=${POSTGRES_PORT}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
ENV: dev
FLOWER_PORT: 28888
FLOWER_PASSWORD: flowerpass
HOST_POSTGRES_DUMP: /tmp/dump
POSTGRES_HOST: epigraphhub-db
POSTGRES_PORT: 25432
POSTGRES_USER: dev_epigraph
Expand Down
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ CRON:=
DOCKER=docker-compose \
--env-file .env \
--project-name eph-$(ENV) \
--file docker/compose-base.yaml \
--file docker/compose-$(ENV).yaml
--file docker/compose.yaml

# DOCKER

Expand All @@ -22,14 +21,19 @@ docker-build:

.PHONY:docker-start
docker-start:
$(DOCKER) up -d ${SERVICES}
$(DOCKER) up --remove-orphans -d ${SERVICES}


.PHONY:docker-stop
docker-stop:
$(DOCKER) stop ${SERVICES}


.PHONY:docker-down
docker-down:
$(DOCKER) down --volumes


.PHONY:docker-restart
docker-restart: docker-stop docker-start
echo "[II] Docker services restarted!"
Expand All @@ -38,6 +42,10 @@ docker-restart: docker-stop docker-start
docker-logs-follow:
$(DOCKER) logs --follow --tail 300 ${SERVICES}

.PHONY:docker-logs-follow
docker-logs-follow:
$(DOCKER) logs --follow --tail 100 ${SERVICES}

.PHONY:docker-logs
docker-logs:
$(DOCKER) logs --tail 300 ${SERVICES}
Expand Down
24 changes: 0 additions & 24 deletions docker/compose-dev.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions docker/compose-prod.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions docker/compose-base.yaml → docker/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ services:
ports:
- ${SUPERSET_PORT}:8088
depends_on:
- epigraphhub-db
- epigraphhub-redis
- epigraphhub-celery
- epigraphhub-celery-beat
Expand Down Expand Up @@ -167,3 +168,4 @@ services:

volumes:
redis:
pgdata:
19 changes: 19 additions & 0 deletions docker/postgresql/dump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd ../.. && pwd )"

if [ -f ${PROJECT_DIR}/.env ]; then
# Load Environment Variables
export $(cat ${PROJECT_DIR}/.env | grep -v '#' | sed 's/\r$//' | awk '/=/ {print $1}' )
fi

HOST_POSTGRES_DUMP=${HOST_POSTGRES_DUMP:-/tmp/dump}
mkdir -p ${HOST_POSTGRES_DUMP}

set -ex

PGPASSWORD=${POSTGRES_PASSWORD} pg_dumpall \
--host ${POSTGRES_HOST} \
--port ${POSTGRES_PORT} \
--user ${POSTGRES_USER} \
> ${HOST_POSTGRES_DUMP}/$(date --iso-8601).dump
Empty file added docker/postgresql/restore.sh
Empty file.

0 comments on commit 76b2261

Please sign in to comment.