Skip to content

Commit

Permalink
Overide gh docker compose with docker compose services
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 committed Sep 3, 2024
1 parent c36be6b commit fb26d1b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 65 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- develop
pull_request:

env:
COMPOSE_FILE: docker-compose.yml:gh-docker-compose.yml

jobs:
test:
name: 🚴 Test 🚴
Expand Down Expand Up @@ -48,6 +51,7 @@ jobs:

- name: 🕮 Validate if there are no pending django migrations.
env:
COMPOSE_FILE: ./docker-compose.yml:./gh-docker-compose.yml
DOCKER_IMAGE_BACKEND: ${{ steps.prep.outputs.tagged_image }}
run: |
docker compose -f ./gh-docker-compose.yml run --rm web bash -c 'wait-for-it db:5432 && ./manage.py makemigrations --check --dry-run' || {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
environment:
DJANGO_DEBUG: ${DJANGO_DEBUG:-True}
DJANGO_ALLOWED_HOST: ${DJANGO_ALLOWED_HOST:-localhost}
DJNAGO_SECRET_KEY: ${DJANGO_SECRET_KEY:- test}
DJNAGO_SECRET_KEY: ${DJANGO_SECRET_KEY}
DATABASE_NAME: ${DATABASE_NAME:-chatbot}
DATABASE_USER: ${DATABASE_USER:-postgres}
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-postgres}
Expand Down
65 changes: 2 additions & 63 deletions gh-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,5 @@
services:
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
volumes:
- postgres-data16:/var/lib/postgresql/data

redis:
image: redis:6-alpine
volumes:
- redis-data:/data

qdrant:
image: qdrant/qdrant:v1.11.3
ports:
- "6333:6333"
volumes:
- qdrant_data:/qdrant/storage

web:
image: $DOCKER_IMAGE_BACKEND
# To attach to container with stdin `docker attach <container_name>`
# Used for python debugging.
stdin_open: true
tty: true
extra_hosts:
- "host.docker.internal:host-gateway"
env_file: !reset null
environment:
CI: "true"
APP_ENVIRONMENT: CI
APP_TYPE: web
DJANGO_DEBUG: "true"
DJANGO_SECRET_KEY: RANDOM_KEY
# -- Domain configurations
DJANGO_ALLOWED_HOSTS: "*"
APP_DOMAIN: localhost:8000
APP_HTTP_PROTOCOL: http
APP_FRONTEND_HOST: http://localhost:3000
SESSION_COOKIE_DOMAIN: localhost
CSRF_COOKIE_DOMAIN: localhost
# Database config
DATABASE_NAME: postgres
DATABASE_USER: postgres
DATABASE_PASSWORD: postgres
DATABASE_HOST: db
DATABASE_PORT: 5432
# # Redis config
CELERY_REDIS_URL: ${CELERY_REDIS_URL:-redis://redis:6379/0}
DJANGO_CACHE_REDIS_URL: ${DJANGO_CACHE_REDIS_URL:-redis://redis:6379/1}
# Email config
EMAIL_FROM: ${EMAIL_FROM:-togglecorp-dev <[email protected]>}
volumes:
- ./:/code
- ./ci-share/:/ci-share/
# - ./coverage/:/code/coverage/
depends_on:
- db
- redis

volumes:
postgres-data16:
redis-data:
qdrant_data:
DJANGO_SECRET_KEY: "test"
2 changes: 1 addition & 1 deletion main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
DJANGO_ALLOWED_HOST=(list, ["*"]),
DJANGO_STATIC_ROOT=(str, os.path.join(BASE_DIR, "assets/static")), # Where to store
DJANGO_MEDIA_ROOT=(str, os.path.join(BASE_DIR, "assets/media")), # Where to store
DJANGO_TIME_ZONE=(str, "UTC"),
DJANGO_STATIC_URL=(str, "/static/"),
DJANGO_MEDIA_URL=(str, "/media/"),
DJANGO_TIME_ZONE=(str, "UTC"),
# Database
DATABASE_NAME=str,
DATABASE_USER=str,
Expand Down
7 changes: 7 additions & 0 deletions main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path

urlpatterns = [
path("admin/", admin.site.urls),
]
if settings.DEBUG:

# Static and media file URLs
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

0 comments on commit fb26d1b

Please sign in to comment.