generated from codersforcauses/django-nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update dockerfiles and entrypoints for prod, adjust docker-compose, a…
…djust settings.py
- Loading branch information
Showing
10 changed files
with
123 additions
and
101 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,39 @@ | ||
#!/bin/bash | ||
#!/bin/sh | ||
|
||
echo "${APP_NAME^^} - NextJS CONTAINER STARTING..." | ||
echo $APP_NAME | ||
set -e | ||
|
||
# Display Docker Image / CI / Release details | ||
echo "Image Build Date/Time: " "$(cat /app/build_timestamp.txt)" "UTC" | ||
echo "$APP_NAME - NextJS CONTAINER STARTING..." | ||
echo "APP_NAME: $APP_NAME" | ||
|
||
# Display Build Date/Time if available | ||
if [ -f /app/build_timestamp.txt ]; then | ||
echo "Image Build Date/Time: $(cat /app/build_timestamp.txt) UTC" | ||
fi | ||
|
||
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 | ||
# Check for required env vars | ||
if [ -z "${APP_ENV}" ]; then | ||
echo "█████████████████████████████████████████████████████████████████████████████████████████████████████████████" | ||
echo "█ CRITICAL ERROR: Missing 'APP_ENV' environment variables." | ||
echo "█ CRITICAL ERROR: Missing 'APP_ENV' environment variable." | ||
echo "█████████████████████████████████████████████████████████████████████████████████████████████████████████████" | ||
echo "APP_ENV=" $APP_ENV | ||
echo "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░" | ||
exit | ||
echo "APP_ENV=${APP_ENV}" | ||
exit 1 | ||
fi | ||
|
||
# CI TEST DOWN THE TRACK | ||
|
||
# ==================================================================================== | ||
# Run inbuilt nextjs server if ENV is LOCAL | ||
# ==================================================================================== | ||
if [ "${APP_ENV^^}" = "DEVELOPMENT" ]; then | ||
# Install dependencies (idk why it's not installing the latest ones in the docker image) | ||
# Start the application based on APP_ENV | ||
if [ "${APP_ENV}" = "PRODUCTION" ]; then | ||
echo "Starting Next.js application in production mode" | ||
# Build and run for prod | ||
npm install | ||
# Run developments | ||
echo " " | ||
echo "======= Starting inbuilt nextjs webserver ===================================================================" | ||
npm run dev | ||
exit | ||
fi | ||
npm run build | ||
npm start | ||
elif [ "${APP_ENV}" = "DEVELOPMENT" ]; then | ||
echo "Starting Next.js application in development mode" | ||
npm install | ||
exec npm run dev | ||
else | ||
echo "Unknown APP_ENV: ${APP_ENV}" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,41 @@ | ||
# Use the official Python image | ||
FROM python:3.12-slim | ||
|
||
RUN apt-get update && apt-get install --yes --no-install-recommends postgresql-client g++ libssl-dev && rm -rf /var/lib/apt/lists/* | ||
|
||
RUN pip install --upgrade pip && pip install poetry | ||
|
||
RUN poetry config virtualenvs.in-project false | ||
RUN poetry config virtualenvs.create false | ||
# Install system dependencies | ||
RUN apt-get update && \ | ||
apt-get install --yes --no-install-recommends \ | ||
build-essential \ | ||
libssl-dev \ | ||
libpq-dev \ | ||
postgresql-client && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set work directory | ||
WORKDIR /app | ||
|
||
COPY ./docker/server/entrypoint.sh /entrypoint.sh | ||
# Install Poetry | ||
RUN pip install --upgrade pip && \ | ||
pip install poetry | ||
|
||
# Configure Poetry | ||
RUN poetry config virtualenvs.create false | ||
|
||
# Copy the application files | ||
COPY ./server/pyproject.toml ./server/poetry.lock ./ | ||
RUN poetry install --no-dev --no-interaction --no-ansi | ||
|
||
COPY ./server/ ./ | ||
|
||
RUN poetry install | ||
# Collect static files | ||
RUN python manage.py collectstatic --noinput --verbosity 2 | ||
|
||
COPY ./server ./ | ||
# Create log directory | ||
RUN mkdir -p /var/log/accesslogs && \ | ||
chmod -R 755 /var/log/accesslogs | ||
|
||
# Copy entrypoint script | ||
COPY ./docker/server/entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
CMD ["/entrypoint.sh"] | ||
|
||
# Start the application | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.