File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ APP_NAME=DjangoAPI
99API_SECRET_KEY= CHANGE THIS TO A RANDOM STRING
1010API_ALLOWED_HOSTS=".localhost 127.0.0.1 [::1]"
1111
12- POSTGRES_HOST=localhost
12+ POSTGRES_HOST=db
1313POSTGRES_NAME=postgres
1414POSTGRES_USER=postgres
1515POSTGRES_PASSWORD=password
Original file line number Diff line number Diff line change @@ -17,11 +17,11 @@ services:
1717 restart : unless-stopped
1818 env_file : ./.env.prod
1919 ports :
20- - 8000:8000
20+ - 8081:8081
2121 entrypoint : /entrypoint.sh
2222 volumes :
2323 - ./opt/accesslogs/:/var/log/accesslogs/
24- - ./opt/static_files:/opt /static_files
24+ - ./opt/static_files:/app /static_files
2525 environment :
2626 - DJANGO_SETTINGS_MODULE=api.settings
2727 depends_on :
Original file line number Diff line number Diff line change @@ -14,12 +14,12 @@ RUN npm install
1414# Copy Application code into a directory called `app`
1515COPY ./client /app
1616
17+ RUN npm run build
18+
1719# ========================================
1820# ---- Executed at Container Runtime ----
1921# ========================================
2022
2123# CMD commands get executed at container runtime!
2224RUN chmod +x /entrypoint.sh
23- CMD ["/entrypoint.sh" ]
24-
25- # TODO: Production
25+ CMD ["/entrypoint.sh" ]
Original file line number Diff line number Diff line change 11#! /bin/bash
22
33echo " ${APP_NAME^^} - NextJS CONTAINER STARTING..."
4- echo $APP_NAME
54
6- # Display Docker Image / CI / Release details
7- echo " Image Build Date/Time: " " $( cat /app/build_timestamp.txt) " " UTC"
8-
9- echo " -----------------------------------------------------------"
10- echo " APP_ENV: ${APP_ENV} "
11-
12- # # ====================================================================================
13- # # Debug / Sanity check info
14- # # ====================================================================================
15- # echo " "
16- # echo "======= Current Dir / Files (Debug) ============================================================================="
17- # pwd
18- # ls -al
19-
20- # echo " "
21- # echo "======= Env Vars (Debug) ========================================================================================"
22- # if [ "${APP_ENV^^}" != "PRODUCTION" ]; then
23- # # Only print environment vars in non-prod environments to prevent sensitive variables being sent to logging system
24- # printenv
25- # fi
26-
27- # echo " "
28- # echo "======= Linux version (Debug) ==================================================================================="
29- # cat /etc/os-release
30-
31- # echo " "
32- # echo "======= Node Path & Version (Debug) ==========================================================================="
33- # node -v
345
356# Check for required env vars, exit as failure if missing these critical env vars.
367if [[ -z " ${APP_ENV} " ]]; then
@@ -55,4 +26,6 @@ if [ "${APP_ENV^^}" = "DEVELOPMENT" ]; then
5526 echo " ======= Starting inbuilt nextjs webserver ==================================================================="
5627 npm run dev
5728 exit
58- fi
29+ fi
30+
31+ npm run start
Original file line number Diff line number Diff line change 1313
1414 # upstream to the server container
1515 upstream backend {
16- server server:8000 ; #name of container:port exposed
16+ server server:8081 ; #name of container:port exposed
1717 }
1818
1919 # upstream to the server container
4141 }
4242 # serve django static files
4343 location /static/ {
44- alias /server/staticfiles /;
44+ alias /opt/static_files /;
4545 }
4646 # proxy to client
4747 location / {
Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ if [ "${APP_ENV^^}" = "DEVELOPMENT" ]; then
3333
3434 # Run developments
3535 printf " \n" && echo " Starting inbuilt django webserver"
36- echo " Running: python manage.py runserver 0.0.0.0:8000 "
37- python manage.py runserver 0.0.0.0:8000
36+ echo " Running: python manage.py runserver 0.0.0.0:8081 "
37+ python manage.py runserver 0.0.0.0:8081
3838 exit
3939fi
4040
@@ -45,6 +45,6 @@ if [ "${APP_ENV^^}" = "PRODUCTION" ]; then
4545
4646 # Run Gunicorn / Django
4747 printf " \n" && echo " Running Gunicorn / Django"
48- 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"
49- 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
48+ 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"
49+ 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
5050fi
You can’t perform that action at this time.
0 commit comments