diff --git a/.env.production.example b/.env.production.example index 9e151cb..f2cda5d 100644 --- a/.env.production.example +++ b/.env.production.example @@ -9,7 +9,7 @@ APP_NAME=DjangoAPI API_SECRET_KEY= CHANGE THIS TO A RANDOM STRING API_ALLOWED_HOSTS=".localhost 127.0.0.1 [::1]" -POSTGRES_HOST=localhost +POSTGRES_HOST=db POSTGRES_NAME=postgres POSTGRES_USER=postgres POSTGRES_PASSWORD=password diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index c6cdcb4..66cc5a2 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -17,11 +17,11 @@ services: restart: unless-stopped env_file: ./.env.prod ports: - - 8000:8000 + - 8081:8081 entrypoint: /entrypoint.sh volumes: - ./opt/accesslogs/:/var/log/accesslogs/ - - ./opt/static_files:/opt/static_files + - ./opt/static_files:/app/static_files environment: - DJANGO_SETTINGS_MODULE=api.settings depends_on: diff --git a/docker/client/Dockerfile b/docker/client/Dockerfile index e7492aa..564ce6e 100644 --- a/docker/client/Dockerfile +++ b/docker/client/Dockerfile @@ -14,12 +14,12 @@ RUN npm install # Copy Application code into a directory called `app` COPY ./client /app +RUN npm run build + # ======================================== # ---- Executed at Container Runtime ---- # ======================================== # CMD commands get executed at container runtime! RUN chmod +x /entrypoint.sh -CMD ["/entrypoint.sh"] - -# TODO: Production \ No newline at end of file +CMD ["/entrypoint.sh"] \ No newline at end of file diff --git a/docker/client/entrypoint.sh b/docker/client/entrypoint.sh index 0173c5c..e200ba3 100644 --- a/docker/client/entrypoint.sh +++ b/docker/client/entrypoint.sh @@ -1,36 +1,7 @@ #!/bin/bash echo "${APP_NAME^^} - NextJS CONTAINER STARTING..." -echo $APP_NAME -# Display Docker Image / CI / Release details -echo "Image Build Date/Time: " "$(cat /app/build_timestamp.txt)" "UTC" - -echo "-----------------------------------------------------------" -echo "APP_ENV: ${APP_ENV}" - -# # ==================================================================================== -# # Debug / Sanity check info -# # ==================================================================================== -# echo " " -# echo "======= Current Dir / Files (Debug) =============================================================================" -# pwd -# ls -al - -# echo " " -# echo "======= Env Vars (Debug) ========================================================================================" -# if [ "${APP_ENV^^}" != "PRODUCTION" ]; then -# # Only print environment vars in non-prod environments to prevent sensitive variables being sent to logging system -# printenv -# fi - -# echo " " -# echo "======= Linux version (Debug) ===================================================================================" -# cat /etc/os-release - -# echo " " -# echo "======= Node Path & Version (Debug) ===========================================================================" -# node -v # Check for required env vars, exit as failure if missing these critical env vars. if [[ -z "${APP_ENV}" ]]; then @@ -55,4 +26,6 @@ if [ "${APP_ENV^^}" = "DEVELOPMENT" ]; then echo "======= Starting inbuilt nextjs webserver ===================================================================" npm run dev exit -fi \ No newline at end of file +fi + +npm run start \ No newline at end of file diff --git a/docker/nginx/custom.conf b/docker/nginx/custom.conf index 054240d..8644264 100644 --- a/docker/nginx/custom.conf +++ b/docker/nginx/custom.conf @@ -13,7 +13,7 @@ http { # upstream to the server container upstream backend { - server server:8000; #name of container:port exposed + server server:8081; #name of container:port exposed } # upstream to the server container @@ -41,7 +41,7 @@ http { } # serve django static files location /static/ { - alias /server/staticfiles/; + alias /opt/static_files/; } # proxy to client location / { diff --git a/docker/server/entrypoint.sh b/docker/server/entrypoint.sh index 336c7c7..86ec1ab 100644 --- a/docker/server/entrypoint.sh +++ b/docker/server/entrypoint.sh @@ -33,8 +33,8 @@ if [ "${APP_ENV^^}" = "DEVELOPMENT" ]; then # Run developments printf "\n" && echo "Starting inbuilt django webserver" - echo "Running: python manage.py runserver 0.0.0.0:8000" - python manage.py runserver 0.0.0.0:8000 + echo "Running: python manage.py runserver 0.0.0.0:8081" + python manage.py runserver 0.0.0.0:8081 exit fi @@ -45,6 +45,6 @@ if [ "${APP_ENV^^}" = "PRODUCTION" ]; then # Run Gunicorn / Django printf "\n" && echo " Running Gunicorn / Django" - echo "Running: gunicorn api.wsgi -b 0.0.0.0:8000 --workers=6 --keep-alive 20 --log-file=- --log-level debug --access-logfile=/var/log/accesslogs/gunicorn --capture-output --timeout 50" - gunicorn api.wsgi -b 0.0.0.0:8000 --workers=6 --keep-alive 20 --log-file=- --log-level debug --access-logfile=/var/log/accesslogs/gunicorn --capture-output --timeout 50 + echo "Running: gunicorn api.wsgi -b 0.0.0.0:8081 --workers=6 --keep-alive 20 --log-file=- --log-level debug --access-logfile=/var/log/accesslogs/gunicorn --capture-output --timeout 50" + gunicorn api.wsgi -b 0.0.0.0:8081 --workers=6 --keep-alive 20 --log-file=- --log-level debug --access-logfile=/var/log/accesslogs/gunicorn --capture-output --timeout 50 fi \ No newline at end of file