Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.production.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions docker/client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
CMD ["/entrypoint.sh"]
33 changes: 3 additions & 30 deletions docker/client/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -55,4 +26,6 @@ if [ "${APP_ENV^^}" = "DEVELOPMENT" ]; then
echo "======= Starting inbuilt nextjs webserver ==================================================================="
npm run dev
exit
fi
fi

npm run start
4 changes: 2 additions & 2 deletions docker/nginx/custom.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -41,7 +41,7 @@ http {
}
# serve django static files
location /static/ {
alias /server/staticfiles/;
alias /opt/static_files/;
}
# proxy to client
location / {
Expand Down
8 changes: 4 additions & 4 deletions docker/server/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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