Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 0 additions & 76 deletions docker-compose-dev.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3.5'

services:
web:
build: .

celery:
build: .
22 changes: 2 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
version: '3.5'

x-environment-vars: &environment-vars
POSTGRES_HOST: postgres
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
ELASTICSEARCH_HOST: elastic:9200
REDIS_URL: redis://redis:6379/0
ADMIN_EMAIL: "@{ADMIN_EMAIL}"
ADMIN_PASSWORD: "@{ADMIN_PASSWORD}"

x-defaults: &defaults
build: .
image: eventyay/open-event-server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamareebjamal Should we specify a tag?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically defaults to latest. Making new changes unnecessary and easier to update

restart: unless-stopped
environment:
<<: *environment-vars
depends_on:
- postgres
- redis
- elastic
links:
- postgres:postgres
- redis:redis
- elastic:elastic
volumes:
- ./static:/data/app/static

Expand All @@ -44,18 +39,6 @@ services:
volumes:
- rd:/var/lib/redis/data

elastic:
image: elasticsearch:5.6.12-alpine
container_name: opev-elastic-search
restart: unless-stopped
environment:
- discovery.type=single-node
volumes:
- es:/usr/share/elasticsearch/data
ports:
- 9200:9200
- 9300:9300

web:
<<: *defaults
container_name: opev-web
Expand All @@ -73,4 +56,3 @@ services:
volumes:
pg:
rd:
es:
6 changes: 0 additions & 6 deletions postgres-initdb.d/create_db.sql

This file was deleted.

1 change: 1 addition & 0 deletions scripts/container_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ echo "[LOG] Using redis: ${REDIS_URL}"

if [ "$DEPLOYMENT" == "api" ]
then
echo "[LOG] Waiting for Database" && ./scripts/wait-for.sh ${POSTGRES_HOST}:5432 --timeout=60 -- echo "[LOG] Database Up"
echo "[LOG] Preparing database"
python manage.py prepare_kubernetes_db
echo "[LOG] Running migrations"
Expand Down
79 changes: 79 additions & 0 deletions scripts/wait-for.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/sh

TIMEOUT=15
QUIET=0

echoerr() {
if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
}

usage() {
exitcode="$1"
cat << USAGE >&2
Usage:
$cmdname host:port [-t timeout] [-- command args]
-q | --quiet Do not output any status messages
-t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
USAGE
exit "$exitcode"
}

wait_for() {
for i in `seq $TIMEOUT` ; do
nc -z "$HOST" "$PORT" > /dev/null 2>&1

result=$?
if [ $result -eq 0 ] ; then
if [ $# -gt 0 ] ; then
exec "$@"
fi
exit 0
fi
sleep 1
done
echo "Operation timed out" >&2
exit 1
}

while [ $# -gt 0 ]
do
case "$1" in
*:* )
HOST=$(printf "%s\n" "$1"| cut -d : -f 1)
PORT=$(printf "%s\n" "$1"| cut -d : -f 2)
shift 1
;;
-q | --quiet)
QUIET=1
shift 1
;;
-t)
TIMEOUT="$2"
if [ "$TIMEOUT" = "" ]; then break; fi
shift 2
;;
--timeout=*)
TIMEOUT="${1#*=}"
shift 1
;;
--)
shift
break
;;
--help)
usage 0
;;
*)
echoerr "Unknown argument: $1"
usage 1
;;
esac
done

if [ "$HOST" = "" -o "$PORT" = "" ]; then
echoerr "Error: you need to provide a host and port to test."
usage 2
fi

wait_for "$@"