added firstrun script
This commit is contained in:
parent
7409caf072
commit
369202476e
2 changed files with 55 additions and 4 deletions
|
@ -1,12 +1,10 @@
|
||||||
DEBUG=True
|
DEBUG=True
|
||||||
|
|
||||||
DJANGO_SECRET_KEY='your-secret-key'
|
|
||||||
DJANGO_LOGLEVEL=info
|
DJANGO_LOGLEVEL=info
|
||||||
DJANGO_ALLOWED_HOSTS="127.0.0.1,localhost"
|
DJANGO_ALLOWED_HOSTS="127.0.0.1,localhost"
|
||||||
|
UID=1000
|
||||||
|
GID=1000
|
||||||
|
|
||||||
DATABASE_ENGINE= postgresql_psycopg2
|
DATABASE_ENGINE= postgresql_psycopg2
|
||||||
DATABASE_NAME=movienight
|
|
||||||
DATABASE_USERNAME=web
|
|
||||||
DATABASE_PASSWORD=super_secret_password
|
|
||||||
DATABASE_HOST=db
|
DATABASE_HOST=db
|
||||||
DATABASE_PORT=5432
|
DATABASE_PORT=5432
|
||||||
|
|
53
firstRun.sh
Executable file
53
firstRun.sh
Executable file
|
@ -0,0 +1,53 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
read -p "What is the project's name? " -r PROJECT_NAME
|
||||||
|
if [ -z "$PROJECT_NAME" ]
|
||||||
|
then
|
||||||
|
PROJECT_NAME="djangodocker"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "===== UPDATING PROJECT NAME ====="
|
||||||
|
git ls-files | xargs sed -i "s/djangodocker/${PROJECT_NAME}/g"
|
||||||
|
echo "Done!"
|
||||||
|
|
||||||
|
echo "===== UPDATING ENVIRONMENT ====="
|
||||||
|
cp .env.example .env
|
||||||
|
sed -i "s/djangodocker/${PROJECT_NAME}/g" ./.env
|
||||||
|
|
||||||
|
# SET DATABASE USERNAME
|
||||||
|
read -p "Enter a username for the database: " -r DATABASE_USERNAME
|
||||||
|
if [ -z "$DATABASE_USERNAME" ]
|
||||||
|
then
|
||||||
|
DATABASE_USERNAME="admin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# SET DATABASE PASSWORD
|
||||||
|
read -p "Enter a password for the database: " -r DATABASE_PASSWORD
|
||||||
|
if [ -z "$DATABASE_PASSWORD" ]
|
||||||
|
then
|
||||||
|
DATABASE_PASSWORD=$(tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 15)
|
||||||
|
fi
|
||||||
|
|
||||||
|
SECRET_KEY=$(tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 50)
|
||||||
|
{
|
||||||
|
echo "DATABASE_NAME=${PROJECT_NAME}"
|
||||||
|
echo "DATABASE_USERNAME=${DATABASE_USERNAME}"
|
||||||
|
echo "DATABASE_PASSWORD=${DATABASE_PASSWORD}"
|
||||||
|
echo "SECRET_KEY=${SECRET_KEY}"
|
||||||
|
echo "DJANGO_SECRET_KEY=${SECRET_KEY}"
|
||||||
|
} >> .env
|
||||||
|
|
||||||
|
mv djangodocker "$PROJECT_NAME"
|
||||||
|
|
||||||
|
echo "===== STARTING DOCKER ====="
|
||||||
|
docker compose up -d --build
|
||||||
|
|
||||||
|
echo "===== MIGRATING DATABASE ====="
|
||||||
|
docker exec -ti "${PROJECT_NAME}-api" ./manage.py migrate
|
||||||
|
|
||||||
|
echo "===== CREATE SUPERUSER ====="
|
||||||
|
docker exec -ti "${PROJECT_NAME}-api" ./manage.py createsuperuser
|
||||||
|
|
||||||
|
echo "Success! Go to http://localhost:8000 to see API documentation."
|
Loading…
Add table
Reference in a new issue