File tree 5 files changed +83
-14
lines changed
5 files changed +83
-14
lines changed Original file line number Diff line number Diff line change
1
+ DEBUG = 0
2
+ DB_ENGINE = django.db.backends.postgresql
3
+ DB_HOST = db
4
+ DB_PORT = 5432
5
+ DB_NAME = django_index
6
+ DB_USER = testUser
7
+ DB_PASSWORD = django_index_password
8
+ DJANGO_ALLOWED_HOSTS = localhost 127.0.0.1 [::1]
Original file line number Diff line number Diff line change
1
+ FROM bitnami/python:3.12.7
2
+
3
+ # set working directory
4
+ WORKDIR /usr/src/app
5
+
6
+ # install system dependencies
7
+ RUN apt-get update \
8
+ && apt-get -qq -y install netcat-traditional \
9
+ libglib2.0-0 libsm6 libxext6 libxrender-dev libgomp1 \
10
+ graphviz graphviz-dev gcc \
11
+ && apt-get -qq clean
12
+
13
+ # install python dependencies
14
+ COPY ./requirements.txt /usr/src/app/requirements.txt
15
+
16
+ RUN pip install --upgrade pip
17
+ RUN pip install --no-cache-dir -r requirements.txt
18
+
19
+ # copy project
20
+ COPY . /usr/src/app/
Original file line number Diff line number Diff line change 11
11
"""
12
12
13
13
from pathlib import Path
14
+ import os
14
15
15
16
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16
17
BASE_DIR = Path (__file__ ).resolve ().parent .parent
23
24
SECRET_KEY = "django-insecure-+031!wnlhf@ij86qi%7mu^f+r4hhezl=tz&05mvbopvh^)g_@u"
24
25
25
26
# SECURITY WARNING: don't run with debug turned on in production!
26
- DEBUG = True
27
+ DEBUG = int ( os . environ . get ( "DEBUG" , 0 ))
27
28
28
29
ALLOWED_HOSTS = ["*" ]
29
30
74
75
# Database
75
76
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
76
77
77
- # DATABASES = {
78
- # 'default': {
79
- # 'ENGINE': 'django.db.backends.sqlite3',
80
- # 'NAME': BASE_DIR / 'db.sqlite3',
81
- # }
82
- # }
83
-
84
78
DATABASES = {
85
79
"default" : {
86
- "ENGINE" : " django.db.backends.postgresql" ,
87
- "HOST" : "127.0.0.1" ,
88
- "PORT" : 5432 ,
89
- "USER" : "monitaur" ,
90
- "PASSWORD" : "dummy" ,
91
- "NAME" : "monitaur" ,
80
+ "ENGINE" : os . environ . get ( "DB_ENGINE" , " django.db.backends.sqlite3" ) ,
81
+ "HOST" : os . environ . get ( "DB_HOST" , "localhost" ) ,
82
+ "PORT" : os . environ . get ( "DB_PORT" , " 5432" ) ,
83
+ "USER" : os . environ . get ( "DB_USER" , "postgres" ) ,
84
+ "PASSWORD" : os . environ . get ( "DB_PASSWORD" , "postgres" ) ,
85
+ "NAME" : os . environ . get ( "DB_NAME" , "postgres" ) ,
92
86
}
93
87
}
94
88
Original file line number Diff line number Diff line change
1
+ services :
2
+
3
+ api :
4
+ build : .
5
+ command : python manage.py runserver 0.0.0.0:8080
6
+ entrypoint : ["/usr/src/app/entrypoint.sh"]
7
+ volumes :
8
+ - .:/usr/src/app
9
+ ports :
10
+ - 8080:8080
11
+ depends_on :
12
+ - db
13
+ env_file :
14
+ - .env
15
+ networks :
16
+ - django_index_network
17
+
18
+ db :
19
+ image : postgres:latest
20
+ volumes :
21
+ - db_data:/var/lib/postgresql/data/
22
+ environment :
23
+ - POSTGRES_USER=testUser
24
+ - POSTGRES_PASSWORD=django_index_password
25
+ - POSTGRES_DB=django_index
26
+ networks :
27
+ - django_index_network
28
+
29
+
30
+ networks :
31
+ django_index_network :
32
+
33
+ volumes :
34
+ db_data :
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ while ! nc -z db 5432; do
4
+ echo " Waiting for database...."
5
+ sleep 0.1
6
+ done
7
+
8
+ echo " Database started"
9
+
10
+ python manage.py migrate --no-input
11
+ # python manage.py seed_db --no-input
12
+
13
+ exec " $@ "
You can’t perform that action at this time.
0 commit comments