Skip to content

Commit ee3e7d6

Browse files
committed
Fix up internal ip
1 parent eb93c01 commit ee3e7d6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ENV DJANGO_SETTINGS_MODULE api.config.settings
44
ENV SECRET_KEY r#lkao5gtpp@me&4532%!q%sj9yzg)xb-_*mlousmi&=#2r7&w
55
ENV DEBUG True
66
ENV DATABASE_URL postgres://postgres@db/postgres
7-
ENV DOCKER_HOST $(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
7+
ENV DOCKER_HOST True
88
RUN mkdir /project
99
WORKDIR /project
1010
RUN apt-get update

api/config/settings.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
import os
14+
import subprocess
1415
import dj_database_url
1516

1617
# Environment specific settings from environment variables or local .env file
@@ -33,10 +34,13 @@
3334
]
3435

3536
if "DOCKER_HOST" in os.environ:
36-
INTERNAL_IPS += os.environ["DOCKER_HOST"]
37+
ip = subprocess.check_output(
38+
['ip', 'addr', 'show', 'eth0'],
39+
universal_newlines=True
40+
).split("inet ")[1].split("/")[0]
41+
INTERNAL_IPS.append(ip)
3742

3843
# Application definition
39-
4044
INSTALLED_APPS = [
4145
'api.core',
4246
'debug_toolbar',
@@ -49,7 +53,7 @@
4953
'django.contrib.staticfiles',
5054
]
5155

52-
MIDDLEWARE_CLASSES = [
56+
MIDDLEWARE = [
5357
'debug_toolbar.middleware.DebugToolbarMiddleware',
5458
'django.middleware.security.SecurityMiddleware',
5559
'django.contrib.sessions.middleware.SessionMiddleware',

0 commit comments

Comments
 (0)