Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
igentify
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nimrod
igentify
Commits
a2e923d1
Commit
a2e923d1
authored
6 years ago
by
Michal Cyprian
Browse files
Options
Downloads
Patches
Plain Diff
Add Platform.sh settings
parent
92609193
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
myapp/settings.py
+40
-0
40 additions, 0 deletions
myapp/settings.py
with
40 additions
and
0 deletions
myapp/settings.py
+
40
−
0
View file @
a2e923d1
...
@@ -11,6 +11,9 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
...
@@ -11,6 +11,9 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
"""
"""
import
os
import
os
import
json
import
base64
from
urllib.parse
import
urlparse
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
...
@@ -118,3 +121,40 @@ USE_TZ = True
...
@@ -118,3 +121,40 @@ USE_TZ = True
# https://docs.djangoproject.com/en/2.1/howto/static-files/
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL
=
'
/static/
'
STATIC_URL
=
'
/static/
'
# Import some Platform.sh settings from the environment.
STATIC_ROOT
=
os
.
path
.
join
(
os
.
getenv
(
'
PLATFORM_APP_DIR
'
),
'
static
'
)
entropy
=
os
.
getenv
(
'
PLATFORM_PROJECT_ENTROPY
'
)
if
entropy
:
SECRET_KEY
=
entropy
routes
=
os
.
getenv
(
'
PLATFORM_ROUTES
'
)
if
routes
:
routes
=
json
.
loads
(
base64
.
b64decode
(
routes
).
decode
(
'
utf-8
'
))
app_name
=
os
.
getenv
(
'
PLATFORM_APPLICATION_NAME
'
)
for
url
,
route
in
routes
.
items
():
host
=
urlparse
(
url
).
netloc
if
(
host
not
in
ALLOWED_HOSTS
and
route
[
'
type
'
]
==
'
upstream
'
and
route
[
'
upstream
'
]
==
app_name
):
ALLOWED_HOSTS
.
append
(
host
)
relationships
=
os
.
getenv
(
'
PLATFORM_RELATIONSHIPS
'
)
if
relationships
:
relationships
=
json
.
loads
(
base64
.
b64decode
(
relationships
).
decode
(
'
utf-8
'
))
db_settings
=
relationships
[
'
database
'
][
0
]
DATABASES
=
{
'
default
'
:
{
'
ENGINE
'
:
'
django.db.backends.postgresql
'
,
'
NAME
'
:
db_settings
[
'
path
'
],
'
USER
'
:
db_settings
[
'
username
'
],
'
PASSWORD
'
:
db_settings
[
'
password
'
],
'
HOST
'
:
db_settings
[
'
host
'
],
'
PORT
'
:
db_settings
[
'
port
'
],
},
'
sqlite
'
:
{
'
ENGINE
'
:
'
django.db.backends.sqlite3
'
,
'
NAME
'
:
os
.
path
.
join
(
BASE_DIR
,
'
db.sqlite3
'
),
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment