Skip to content

Commit 55fccf9

Browse files
Modified docker-compose.yml as well as Dockerfile
1 parent 3d9fca1 commit 55fccf9

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

Dockerfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM python:3.13.3-slim
55
# This layer is cached unless the base image or the list of packages changes
66
RUN apt-get update && apt-get install -y \
77
build-essential \
8-
python-dev \
8+
python-dev-is-python3 \
99
libpq-dev \
1010
curl \
1111
&& rm -rf /var/lib/apt/lists/*
@@ -32,8 +32,4 @@ COPY . .
3232

3333
# Expose the application port
3434
# This layer is cached unless the exposed port changes
35-
EXPOSE 8000
36-
37-
# Default command to run the application
38-
# This layer is cached unless the command changes
39-
CMD ["entrypoint.sh"]
35+
EXPOSE 8000

cart/views.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,14 @@ class CartViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
5454
"""
5555
A viewset for viewing and editing cart items.
5656
"""
57+
queryset = None
5758
lookup_field = 'product_id'
5859
lookup_url_kwarg = 'product_id'
5960

61+
def get_queryset(self):
62+
if getattr(self, 'swagger_fake_view', False):
63+
return None # For schema generation
64+
6065
@extend_schema(
6166
operation_id="cart_get_details",
6267
description="Get the current cart contents with total price.",

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ services:
88
volumes:
99
- database:/var/lib/postgresql/data
1010
environment:
11+
POSTGRES_DB: ${POSTGRES_DB}
1112
POSTGRES_USER: ${POSTGRES_USER}
1213
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
13-
POSTGRES_DB: ${POSTGRES_DB}
1414
healthcheck:
1515
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
1616
interval: 10s
@@ -43,7 +43,7 @@ services:
4343
build: .
4444
container_name: backend
4545
command: [ "./wait-for-it.sh", "database:5432", "--",
46-
"uwsgi", "--ini", "/code/config/uwsgi/uwsgi.ini" ]
46+
"sh", "-c", "python manage.py migrate && uwsgi --ini /code/config/uwsgi/uwsgi.ini" ]
4747
restart: always
4848
volumes:
4949
- .:/code

ecommerce_api/settings/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,6 @@
349349

350350
SITE_ID = 1
351351

352-
353-
354-
355352
ASGI_APPLICATION = 'ecommerce_api.asgi.application'
356353

357354
STRIPE_PUBLISHABLE_KEY = config('STRIPE_PUBLISHABLE_KEY')
@@ -414,3 +411,6 @@
414411
TAGGIT_CASE_INSENSITIVE = True
415412

416413
CELERY_BROKER_URL = f"amqp://{config('RABBITMQ_DEFAULT_USER')}:{config('RABBITMQ_DEFAULT_PASS')}@{config('RABBITMQ_HOST')}:5672/"
414+
415+
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
416+
SESSION_CACHE_ALIAS = "default"

ecommerce_api/settings/local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .base import *
22

33
DEBUG = True
4-
DATABASES['default']['HOST'] = 'localhost'
4+
# DATABASES['default']['HOST'] = 'localhost'
55

66
CORS_ALLOWED_ORIGINS = [
77
"http://localhost:5173",

entrypoint.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
3+
set -e
24

35
echo "Running migrations...."
46
python manage.py migrate
57

68
echo "Starting server...."
7-
python manage.py runserver 0.0.0.0:8000
9+
exec "$@"

0 commit comments

Comments
 (0)