Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
0635ec1c
Commit
0635ec1c
authored
Feb 11, 2019
by
Florent Chehab
Browse files
Parametrization of the admin user creation with env variables
parent
7a48bf38
Pipeline
#34892
passed with stages
in 3 minutes and 9 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
0635ec1c
...
...
@@ -7,6 +7,8 @@ stages:
variables
:
ENV
:
DEV
SECRET_KEY
:
stupid_key_for_CI
DJANGO_ADMIN_USERNAME
:
admin
DJANGO_ADMIN_PASSWORD
:
admin
POSTGRES_DB
:
postgres
POSTGRES_USER
:
postgres
POSTGRES_PASSWORD
:
postgres
...
...
backend/backend_app/load_data/loading_scripts/loadAdminUser.py
View file @
0635ec1c
from
django.contrib.auth.models
import
User
import
os
class
LoadAdminUser
(
object
):
...
...
@@ -13,9 +14,13 @@ class LoadAdminUser(object):
self
.
admin
=
user
[
0
]
else
:
User
.
objects
.
create_superuser
(
username
=
"admin"
,
email
=
"null@null.fr"
,
password
=
"admin"
username
=
os
.
environ
[
"DJANGO_ADMIN_USERNAME"
],
email
=
"null@null.fr"
,
password
=
os
.
environ
[
"DJANGO_ADMIN_PASSWORD"
],
)
self
.
admin
=
User
.
objects
.
filter
(
username
=
"admin"
)[
0
]
self
.
admin
=
User
.
objects
.
filter
(
username
=
os
.
environ
[
"DJANGO_ADMIN_USERNAME"
]
)[
0
]
def
get
(
self
):
return
self
.
admin
docker-compose.yml
View file @
0635ec1c
...
...
@@ -11,6 +11,8 @@ services:
environment
:
-
ENV=DEV
-
SECRET_KEY=please_change_me
-
DJANGO_ADMIN_USERNAME=admin
-
DJANGO_ADMIN_PASSWORD=admin
-
DB_HOST=database
-
DB_PORT=5432
-
POSTGRES_DB=postgres
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment