Browse Source

Another iteration on dev script

rafalp 6 years ago
parent
commit
0cf5ceff17
2 changed files with 35 additions and 6 deletions
  1. 1 1
      Dockerfile
  2. 34 5
      dev

+ 1 - 1
Dockerfile

@@ -4,7 +4,7 @@
 FROM python:3.5
 FROM python:3.5
 
 
 ENV PYTHONUNBUFFERED 1
 ENV PYTHONUNBUFFERED 1
-ENV IN_DOCKER 1
+ENV IN_MISAGO_DOCKER 1
 ENV PATH "$PATH:/srv/misago"
 ENV PATH "$PATH:/srv/misago"
 
 
 # Install dependencies in one single command/layer
 # Install dependencies in one single command/layer

+ 34 - 5
dev

@@ -37,7 +37,7 @@ error() {
 }
 }
 
 
 require_in_docker() {
 require_in_docker() {
-    if [[ ! $IN_DOCKER = 1 ]]; then
+    if [[ ! $IN_MISAGO_DOCKER = 1 ]]; then
         error "This command can only be ran inside the running Misago container."
         error "This command can only be ran inside the running Misago container."
         exit 1
         exit 1
     fi
     fi
@@ -75,6 +75,7 @@ intro() {
     echo "Development project:"
     echo "Development project:"
     echo
     echo
     echo "    ${BOLD}init${NORMAL}              initialize new dev project for development, do nothing if project already exists."
     echo "    ${BOLD}init${NORMAL}              initialize new dev project for development, do nothing if project already exists."
+    echo "    ${BOLD}afterinit${NORMAL}         display help message displayed after init command is complete."
     echo "    ${BOLD}clear${NORMAL}             if dev project exists, delete it's files and destroy docker containers."
     echo "    ${BOLD}clear${NORMAL}             if dev project exists, delete it's files and destroy docker containers."
     echo "    ${BOLD}rebuild${NORMAL}           rebuild docker containers."
     echo "    ${BOLD}rebuild${NORMAL}           rebuild docker containers."
     echo "    ${BOLD}reset${NORMAL}             run clear followed by init."
     echo "    ${BOLD}reset${NORMAL}             run clear followed by init."
@@ -112,6 +113,11 @@ invalid_argument() {
 
 
 # Initialize new dev project
 # Initialize new dev project
 init() {
 init() {
+    if [[ $2 = "message" ]]; then
+        after_init_message
+        exit 0
+    fi
+
     for dev_path in "${dev_paths[@]}"; do
     for dev_path in "${dev_paths[@]}"; do
         if [ -e $dev_path ]; then
         if [ -e $dev_path ]; then
             error "Dev project already exists, or was not deleted completely."
             error "Dev project already exists, or was not deleted completely."
@@ -136,7 +142,7 @@ init() {
     done
     done
     
     
     docker-compose stop
     docker-compose stop
-    docker-compose build "${@:2}"
+    docker-compose build --pull --force-rm "${@:2}"
     docker-compose run --rm misago ./dev init_in_docker
     docker-compose run --rm misago ./dev init_in_docker
 }
 }
 
 
@@ -159,8 +165,14 @@ init_in_docker() {
     # create superuser Admin with password "password"
     # create superuser Admin with password "password"
     python manage.py createsuperuser --username $username --email admin@example.com --password $password
     python manage.py createsuperuser --username $username --email admin@example.com --password $password
 
 
+    # display after init message
     echo
     echo
     echo "================================================================================"
     echo "================================================================================"
+    after_init_message
+}
+
+# After-init message
+after_init_message() {
     echo
     echo
     echo "You can now start the development server using:"
     echo "You can now start the development server using:"
     echo
     echo
@@ -168,12 +180,27 @@ init_in_docker() {
     echo
     echo
     echo "Running server will be available in the browser under the http://127.0.0.1:8000 address."
     echo "Running server will be available in the browser under the http://127.0.0.1:8000 address."
     echo
     echo
-    echo "Default superuser has been created with following credentials:"
+    echo "Default superuser has been created with this username and password:"
     echo
     echo
     echo "Username:    $username"
     echo "Username:    $username"
     echo "Password:    $password"
     echo "Password:    $password"
     echo
     echo
-    echo "For development project configuration see files in the \"devproject\" directory."
+    echo "Development project directories:"
+    echo
+    echo "devproject        contains configuration files for development instance."
+    echo "media             user uploaded files."
+    echo "userdata          working directory for user data exports."
+    echo "avatargallery     example avatar gallery."
+    echo
+    echo "To connect to development database use following credentials:"
+    echo
+    echo "User:         misago"
+    echo "Password:     misago"
+    echo "Database:     misago"
+    echo "Host:         postgres"
+    echo "Port:         5432"
+    echo
+    echo "Note: development server must be running for connection to be possible."
     echo
     echo
 }
 }
 
 
@@ -221,7 +248,7 @@ clear() {
 # Rebuild docker containers
 # Rebuild docker containers
 rebuild() {
 rebuild() {
     docker-compose stop
     docker-compose stop
-    docker-compose build "${@:2}"
+    docker-compose build --pull --force-rm "${@:2}"
 }
 }
 
 
 # Run tests suite
 # Run tests suite
@@ -298,6 +325,8 @@ if [[ $1 ]]; then
         init $@
         init $@
     elif [[ $1 = "init_in_docker" ]]; then
     elif [[ $1 = "init_in_docker" ]]; then
         init_in_docker
         init_in_docker
+    elif [[ $1 = "afterinit" ]]; then
+        after_init_message
     elif [[ $1 = "clear" ]]; then
     elif [[ $1 = "clear" ]]; then
         clear
         clear
     elif [[ $1 = "reset" ]]; then
     elif [[ $1 = "reset" ]]; then