Skip to content
Open
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
3 changes: 0 additions & 3 deletions samples/django-celery/app/command.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash

# Apply database migrations
python manage.py migrate

# Create superuser if not exists
python manage.py createsuperauto

Expand Down
15 changes: 15 additions & 0 deletions samples/django-celery/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
- POSTGRES_URL=postgres://postgres:${POSTGRES_PASSWORD}@database:5432/postgres
depends_on:
- database
- migrate
- broker
ports:
- mode: ingress
Expand All @@ -22,6 +23,19 @@ services:
retries: 3
start_period: 20s

migrate:
restart: no
build:
context: ./app
dockerfile: Dockerfile
environment:
- SECRET_KEY
- REDIS_URL=redis://broker:6379/0
- POSTGRES_URL=postgres://postgres:${POSTGRES_PASSWORD}@database:5432/postgres
depends_on:
- database
command: python manage.py migrate

worker:
restart: unless-stopped
build:
Expand All @@ -37,6 +51,7 @@ services:
depends_on:
- database
- broker
- migrate
command: celery -A django_celery worker --loglevel=info

database:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"permissions": {
"allow": [
"Bash(docker compose:*)"
],
"deny": []
}
}
7 changes: 4 additions & 3 deletions samples/django-channels-redis-postgres/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use a smaller base image
FROM python:3.10-slim-buster
FROM python:3.10-slim-bullseye

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
Expand All @@ -12,7 +12,8 @@ RUN apt-get update \
&& apt-get install -y \
gcc \
python3-dev \
libpq-dev
libpq-dev \
netcat-openbsd

# Install dependencies
COPY requirements.txt /app/
Expand All @@ -32,4 +33,4 @@ RUN adduser --disabled-password --gecos '' django
USER django

# Start server
CMD ["sh", "-c", "python manage.py migrate && daphne -b 0.0.0.0 -p 8000 django_defang.asgi:application"]
CMD ["sh", "-c", "daphne -b 0.0.0.0 -p 8000 django_defang.asgi:application"]
10 changes: 9 additions & 1 deletion samples/django-channels-redis-postgres/compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ services:
depends_on:
- redis-service
- postgres-service
command: sh -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
- migrate
command: sh -c "python manage.py runserver 0.0.0.0:8000"

migrate:
extends:
file: compose.yaml
service: migrate
environment:
- POSTGRES_URL=postgres://djangouser:djangopassword@postgres-service:5432/djangodatabase

redis-service:
extends:
file: compose.yaml
Expand Down
13 changes: 13 additions & 0 deletions samples/django-channels-redis-postgres/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
depends_on:
- redis-service
- postgres-service
- migrate

redis-service:
image: redis:6.2
Expand All @@ -31,6 +32,18 @@ services:
- mode: host
target: 6379

migrate:
restart: "no"
build:
context: ./app
dockerfile: Dockerfile
command: python manage.py migrate
depends_on:
- postgres-service
environment:
- POSTGRES_URL=postgres://djangouser:${POSTGRES_PASSWORD}@postgres-service:5432/djangodatabase?
- SECRET_KEY

postgres-service:
image: postgres:16.4
# uncomment the following line in BYOC
Expand Down
15 changes: 15 additions & 0 deletions samples/rails/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ services:
retries: 5
depends_on:
- db
- migrate
migrate:
restart: "no"
build:
context: ./app
dockerfile: Dockerfile
env_file:
- .env
environment:
POSTGRES_PASSWORD:
command: ["bin/rails", "db:prepare"]
depends_on:
db:
condition: service_healthy

db:
restart: unless-stopped
image: postgres:16
Expand Down
Loading