File tree Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,16 @@ echo " -----> Current working directory."
20
20
21
21
pwd
22
22
23
+ # If necessaary create the media directory if persistent volume being used.
24
+
25
+ if [ -d /opt/app-root/data ]; then
26
+ if [ ! -d /opt/app-root/data/media/images ]; then
27
+ echo " -----> Creating directory for uploaded image files."
28
+
29
+ mkdir -p /opt/app-root/data/media/images
30
+ fi
31
+ fi
32
+
23
33
# Run the application specific deploy steps for this project. If an
24
34
# external database is being used, only perform the database migration
25
35
# and do not run full setup. When external database is used the setup to
Original file line number Diff line number Diff line change 16
16
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
17
17
BASE_DIR = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
18
18
19
+ # If persistent volume mounted, use it for database and media.
20
+ if os .path .isdir ('/opt/app-root/data' ):
21
+ DATA_DIR = '/opt/app-root/data'
22
+ else :
23
+ DATA_DIR = BASE_DIR
19
24
20
25
# Quick-start development settings - unsuitable for production
21
26
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
@@ -122,15 +127,10 @@ def database_url():
122
127
}
123
128
124
129
else :
125
- if os .path .isdir ('/opt/app-root/data' ):
126
- DATABASE_DIR = '/opt/app-root/data'
127
- else :
128
- DATABASE_DIR = BASE_DIR
129
-
130
130
DATABASES = {
131
131
'default' : {
132
132
'ENGINE' : 'django.db.backends.sqlite3' ,
133
- 'NAME' : os .path .join (DATABASE_DIR , 'db.sqlite3' ),
133
+ 'NAME' : os .path .join (DATA_DIR , 'db.sqlite3' ),
134
134
}
135
135
}
136
136
@@ -175,7 +175,7 @@ def database_url():
175
175
STATIC_ROOT = os .path .join (BASE_DIR , 'static' )
176
176
177
177
MEDIA_URL = '/media/'
178
- MEDIA_ROOT = os .path .join (BASE_DIR , 'media' )
178
+ MEDIA_ROOT = os .path .join (DATA_DIR , 'media' )
179
179
180
180
LOGGING = {
181
181
'version' : 1 ,
You can’t perform that action at this time.
0 commit comments