Skip to content

Commit

Permalink
fix docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mtianyan committed Jul 26, 2020
1 parent fc57686 commit b734f20
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
45 changes: 35 additions & 10 deletions Mxonline3/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import sys
import os


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
Expand Down Expand Up @@ -89,17 +90,41 @@
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mxonline3',
'USER': 'root',
'PASSWORD': 'mtianyanroot',
'HOST': '127.0.0.1',
'PORT': '3306'

try:
var = os.environ["use_docker"]
print(var)
if var == "1":
UseDocker = True
else:
UseDocker = False
except KeyError:
UseDocker = False

print(UseDocker)

if UseDocker:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mxonline3',
'USER': 'root',
'PASSWORD': 'mtianyanroot',
'HOST': 'mysql',
'PORT': '3306'
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mxonline3',
'USER': 'root',
'PASSWORD': 'mtianyanroot',
'HOST': '127.0.0.1',
'PORT': '3306'

}
}
}

# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ mysqlclient = "==1.3.14"
defusedxml = "==0.5.0"
slugify = "==0.0.1"
PyMySQL = "==0.9.3"
environ = "*"

[dev-packages]

Expand Down

0 comments on commit b734f20

Please sign in to comment.