Deploy application in container using compose to bring up db
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
# Use postgres/example user/password credentials
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
|
||||
postgresql:
|
||||
image: postgres:17.0
|
||||
container_name: tech-postgresql
|
||||
@@ -19,3 +16,20 @@ services:
|
||||
POSTGRED_DB: techstorage
|
||||
PGDATA: /var/lib/postgresql/data
|
||||
|
||||
flightslot:
|
||||
image: flightslot:dev
|
||||
container_name: tech-flightslot
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 8000:8000
|
||||
depends_on:
|
||||
- postgresql
|
||||
environment:
|
||||
- DJANGO_SETTINGS_MODULE=cntmanage.settings_prod
|
||||
- SECRET_KEY=6WIjA!+mI+ZOWHaJm6v^8F4o,@-gliDtwkp*QFvpkFe"Oo0quq
|
||||
- DB_NAME=techstorage
|
||||
- DB_USER=tech
|
||||
- DB_PASSWORD=tech
|
||||
- DB_HOST=postgresql
|
||||
- DB_PORT=5432
|
||||
|
||||
20
cntmanage/docker/entrypoint.sh
Executable file
20
cntmanage/docker/entrypoint.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "📦 Starting Django deploy script..."
|
||||
|
||||
echo "🔧 Running migrations..."
|
||||
django-admin migrate --noinput
|
||||
|
||||
echo "📁 Collecting static files..."
|
||||
django-admin collectstatic --noinput
|
||||
|
||||
echo "📁 Manually copying static files..."
|
||||
cp -v /app/static/* /var/www/static/
|
||||
|
||||
echo "📁 Manually copying template files..."
|
||||
cp -rv /app/templates/ /var/www/templates/
|
||||
|
||||
echo "🚀 Launching Flightslot..."
|
||||
exec "$@"
|
||||
40
cntmanage/docker/flighslot.Dockerfile
Normal file
40
cntmanage/docker/flighslot.Dockerfile
Normal file
@@ -0,0 +1,40 @@
|
||||
### STAGE 1 - Builder image ###
|
||||
# Builder container
|
||||
FROM python:3.12 AS builder
|
||||
# Install Poetry
|
||||
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||
ENV PATH="${PATH}:/root/.local/bin"
|
||||
RUN env
|
||||
# Create build directory
|
||||
WORKDIR /build
|
||||
# Copy project files
|
||||
COPY . ./
|
||||
# Run poetry update to download dependencies
|
||||
RUN poetry update --no-interaction --no-ansi
|
||||
# Build project
|
||||
RUN poetry build
|
||||
|
||||
### STAGE 2 — Final image
|
||||
FROM python:3.12-slim AS deploy
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy application custom static files
|
||||
RUN mkdir -p static
|
||||
COPY ./static/cantorair.jpg ./static
|
||||
|
||||
# Copy application custom templates for admin page
|
||||
RUN mkdir -p /templates/admin
|
||||
COPY ./templates/admin/* ./templates/admin/
|
||||
|
||||
# Copy and install application wheel package
|
||||
COPY --from=builder /build/dist/*.whl ./
|
||||
RUN pip install --no-cache-dir *.whl
|
||||
RUN pip install gunicorn whitenoise
|
||||
|
||||
# Copy entryupoint bash script
|
||||
COPY ./docker/entrypoint.sh ./
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
||||
# Command to be executed after entry point
|
||||
CMD ["gunicorn", "cntmanage.wsgi:application", "--bind", "0.0.0.0:8000"]
|
||||
Reference in New Issue
Block a user