50 lines
1.3 KiB
Bash
50 lines
1.3 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
echo "Running app..."
|
|
|
|
if docker compose version > /dev/null 2>&1; then
|
|
docker compose up -d
|
|
else
|
|
docker run -d \
|
|
--name diary-db \
|
|
--network diary_network \
|
|
--restart unless-stopped \
|
|
-e POSTGRES_DB=diarydb \
|
|
-e POSTGRES_USER=diaryuser \
|
|
-e POSTGRES_PASSWORD=diarypass \
|
|
-v postgres_data:/var/lib/postgresql/data \
|
|
postgres:15-alpine
|
|
|
|
docker run -d \
|
|
--name diary-app \
|
|
--network diary_network \
|
|
--restart unless-stopped \
|
|
-e DJANGO_SETTINGS_MODULE=diary_app.settings \
|
|
-e POSTGRES_DB=diarydb \
|
|
-e POSTGRES_USER=diaryuser \
|
|
-e POSTGRES_PASSWORD=diarypass \
|
|
-e DB_HOST=diary-db \
|
|
-e DB_PORT=5432 \
|
|
-e SECRET_KEY=change-me-in-production-use-a-long-random-string \
|
|
-e DEBUG=False \
|
|
-v diary_static:/app/staticfiles \
|
|
diary-app:latest
|
|
|
|
docker run -d \
|
|
--name diary-nginx \
|
|
--network diary_network \
|
|
--restart unless-stopped \
|
|
-p 80:80 \
|
|
-v "$(pwd)/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro" \
|
|
-v diary_static:/app/staticfiles:ro \
|
|
nginx:alpine
|
|
fi
|
|
|
|
echo ""
|
|
echo "All containers started."
|
|
echo "The app is available at http://localhost"
|
|
echo ""
|
|
echo "Note: First startup may take 10-15 seconds while the"
|
|
echo " database initialises and migrations run."
|