Merge pull request #219 from jtr860830/master
Fix docker-compose start up order
This commit is contained in:
commit
da0513a7c5
5 changed files with 35 additions and 11 deletions
10
Dockerfile
10
Dockerfile
|
|
@ -7,11 +7,13 @@ COPY . /app/
|
|||
|
||||
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
|
||||
apt update && \
|
||||
apt install -y git ruby-dev nodejs && \
|
||||
apt install -y git ruby-dev nodejs postgresql-client && \
|
||||
apt clean && \
|
||||
gem install compass sass && \
|
||||
npm -g install less && \
|
||||
pip install -r requirements.txt && \
|
||||
pip install redis coveralls
|
||||
pip install --no-cache-dir -r requirements.txt && \
|
||||
pip install --no-cache-dir redis
|
||||
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
RUN chmod +x /app/entrypoint.sh \
|
||||
/app/wait-for-postgres.sh
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
6
db.env
Normal file
6
db.env
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Database environment variables
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=root
|
||||
POSTGRES_DB=dj_crm
|
||||
DB_HOST=db
|
||||
DB_PORT=5432
|
||||
|
|
@ -5,17 +5,14 @@ services:
|
|||
image: postgres
|
||||
# volumes:
|
||||
# - /home/db:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_PASSWORD: "root"
|
||||
POSTGRES_USER: "postgres"
|
||||
POSTGRES_DB: "dj_crm"
|
||||
env_file:
|
||||
- ./db.env
|
||||
|
||||
web:
|
||||
build: .
|
||||
image: micropyramid/django-crm:1
|
||||
environment:
|
||||
DB_HOST: db
|
||||
DB_PORT: 5432
|
||||
env_file:
|
||||
- ./db.env
|
||||
ports:
|
||||
- "8001:8000"
|
||||
depends_on:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Execute startup scripts
|
||||
./wait-for-postgres.sh $DB_HOST
|
||||
python manage.py collectstatic --noinput
|
||||
python manage.py migrate
|
||||
python manage.py runserver 0.0.0.0:8000
|
||||
18
wait-for-postgres.sh
Normal file
18
wait-for-postgres.sh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
# wait-for-postgres.sh
|
||||
|
||||
set -e
|
||||
|
||||
host="$1"
|
||||
shift
|
||||
cmd="$@"
|
||||
|
||||
echo "Testing Postgres connection with psql ..."
|
||||
until PGPASSWORD=$POSTGRES_PASSWORD psql -h "$host" -U "postgres" -c '\q'; do
|
||||
#~ >&2 echo "Postgres is unavailable - sleeping"
|
||||
>&2 echo -n .
|
||||
sleep 1
|
||||
done
|
||||
|
||||
>&2 echo "Postgres is up - executing command"
|
||||
exec $cmd
|
||||
Loading…
Reference in a new issue