diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2dbade0224fa7934fba4e1bcd446d7c7ddc281e6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# base image +FROM python:3.8.7-slim-buster +# setup environment variable +ENV DockerHOME=/wtwblog +ENV HOST=docker.for.mac.host.internal +# set work directory +RUN mkdir -p $DockerHOME +# where your code lives +WORKDIR $DockerHOME + +COPY wtwblog/requirements.txt . +ADD wtwblog $DockerHOME + + +# set environment variables +# install dependencies +RUN pip3 install --upgrade pip +# copy whole project to your docker home directory. COPY . $DockerHOME +# run this command to install all dependencies +RUN pip3 install -r requirements.txt + +# port where the Django app runs +EXPOSE 8003 +# start server +CMD python manage.py runserver 0.0.0.0:8003 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..3e89ece2e16f5fa963daac1fa1f391cf41417352 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,19 @@ +# +# These requirements were autogenerated by pipenv +# To regenerate from the project's Pipfile, run: +# +# pipenv lock --requirements +# + +-i https://pypi.org/simple +asgiref==3.3.4; python_version >= '3.6' +cffi==1.14.5 +cryptography==3.4.7; python_version >= '3.6' +django-rest-knox==4.1.0 +django==3.2.3 +djangorestframework==3.12.4 +django-cors-headers +psycopg2-binary~=2.8.6 +pycparser==2.20; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' +pytz==2021.1 +sqlparse==0.4.1; python_version >= '3.5' diff --git a/wtwblog/settings.py b/wtwblog/settings.py index da2bfeafe9b5ea23b4ce90c0326d8348414317ba..3f84f82e60d2d65b45e27deb8eea89c0f9a88165 100644 --- a/wtwblog/settings.py +++ b/wtwblog/settings.py @@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/ """ from pathlib import Path - +import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -39,7 +39,8 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'knox', - 'rest_framework' + 'rest_framework', + 'corsheaders', ] REST_FRAMEWORK = { @@ -54,6 +55,7 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'corsheaders.middleware.CorsMiddleware', ] ROOT_URLCONF = 'wtwblog.urls' @@ -76,6 +78,7 @@ TEMPLATES = [ WSGI_APPLICATION = 'wtwblog.wsgi.application' +CORS_ORIGIN_ALLOW_ALL = True # Database # https://docs.djangoproject.com/en/3.1/ref/settings/#databases @@ -87,14 +90,14 @@ DATABASES = { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'devusers', 'USER': 'priyamsoni', - 'HOST': '127.0.0.1', + 'HOST': os.getenv('HOST', default='localhost'), 'PORT': '5432', }, 'blog_db': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'devblog', 'USER': 'priyamsoni', - 'HOST': '127.0.0.1', + 'HOST': os.getenv('HOST', default='localhost'), 'PORT': '5432', } }