Frontend (nginx) and backend (gunicorn) now both working for docker deployment.
This commit is contained in:
		
							parent
							
								
									951b52ef25
								
							
						
					
					
						commit
						0f03533408
					
				
					 13 changed files with 266 additions and 12 deletions
				
			
		
							
								
								
									
										18
									
								
								app/Dockerfile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								app/Dockerfile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | |||
| # pull python base image | ||||
| FROM python:3.7-alpine | ||||
| 
 | ||||
| # set up enviroment | ||||
| ENV PYTHONDONTWRITEBYTECODE 1 | ||||
| ENV PYTHONUNBUFFERED 1 | ||||
| 
 | ||||
| # set working directory | ||||
| WORKDIR /usr/src/app | ||||
| 
 | ||||
| # install dependencies | ||||
| RUN pip install --upgrade pip | ||||
| RUN pip install pipenv | ||||
| COPY ./Pipfile /usr/src/app/Pipfile | ||||
| RUN pipenv install --skip-lock --system --dev | ||||
| 
 | ||||
| # copy project | ||||
| COPY . /usr/src/app/ | ||||
							
								
								
									
										13
									
								
								app/Pipfile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								app/Pipfile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| [[source]] | ||||
| name = "pypi" | ||||
| url = "https://pypi.org/simple" | ||||
| verify_ssl = true | ||||
| 
 | ||||
| [dev-packages] | ||||
| 
 | ||||
| [packages] | ||||
| django = "*" | ||||
| gunicorn = "==19.6.0" | ||||
| 
 | ||||
| [requires] | ||||
| python_version = "3.5" | ||||
							
								
								
									
										36
									
								
								app/Pipfile.lock
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								app/Pipfile.lock
									
										
									
										generated
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,36 @@ | |||
| { | ||||
|     "_meta": { | ||||
|         "hash": { | ||||
|             "sha256": "6fedc9216775508baa2496b59b7cd7e991827db84bd68be0cada8c472f1adabf" | ||||
|         }, | ||||
|         "pipfile-spec": 6, | ||||
|         "requires": { | ||||
|             "python_version": "3.5" | ||||
|         }, | ||||
|         "sources": [ | ||||
|             { | ||||
|                 "name": "pypi", | ||||
|                 "url": "https://pypi.org/simple", | ||||
|                 "verify_ssl": true | ||||
|             } | ||||
|         ] | ||||
|     }, | ||||
|     "default": { | ||||
|         "django": { | ||||
|             "hashes": [ | ||||
|                 "sha256:068d51054083d06ceb32ce02b7203f1854256047a0d58682677dd4f81bceabd7", | ||||
|                 "sha256:55409a056b27e6d1246f19ede41c6c610e4cab549c005b62cbeefabc6433356b" | ||||
|             ], | ||||
|             "index": "pypi", | ||||
|             "version": "==2.1.4" | ||||
|         }, | ||||
|         "pytz": { | ||||
|             "hashes": [ | ||||
|                 "sha256:31cb35c89bd7d333cd32c5f278fca91b523b0834369e757f4c5641ea252236ca", | ||||
|                 "sha256:8e0f8568c118d3077b46be7d654cc8167fa916092e28320cde048e54bfc9f1e6" | ||||
|             ], | ||||
|             "version": "==2018.7" | ||||
|         } | ||||
|     }, | ||||
|     "develop": {} | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								app/db.sqlite3
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								app/db.sqlite3
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										15
									
								
								app/manage.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/manage.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | |||
| #!/usr/bin/env python | ||||
| import os | ||||
| import sys | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'reimbursinator.settings') | ||||
|     try: | ||||
|         from django.core.management import execute_from_command_line | ||||
|     except ImportError as exc: | ||||
|         raise ImportError( | ||||
|             "Couldn't import Django. Are you sure it's installed and " | ||||
|             "available on your PYTHONPATH environment variable? Did you " | ||||
|             "forget to activate a virtual environment?" | ||||
|         ) from exc | ||||
|     execute_from_command_line(sys.argv) | ||||
							
								
								
									
										0
									
								
								app/reimbursinator/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								app/reimbursinator/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										120
									
								
								app/reimbursinator/settings.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								app/reimbursinator/settings.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,120 @@ | |||
| """ | ||||
| Django settings for reimbursinator project. | ||||
| 
 | ||||
| Generated by 'django-admin startproject' using Django 2.1.4. | ||||
| 
 | ||||
| For more information on this file, see | ||||
| https://docs.djangoproject.com/en/2.1/topics/settings/ | ||||
| 
 | ||||
| For the full list of settings and their values, see | ||||
| https://docs.djangoproject.com/en/2.1/ref/settings/ | ||||
| """ | ||||
| 
 | ||||
| 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__))) | ||||
| 
 | ||||
| 
 | ||||
| # Quick-start development settings - unsuitable for production | ||||
| # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ | ||||
| 
 | ||||
| # SECURITY WARNING: keep the secret key used in production secret! | ||||
| SECRET_KEY = 'w*d2$rg#i88&6^9u2)jl0!4_)=_e1)0fxreofqzb(qxaw$3+$d' | ||||
| 
 | ||||
| # SECURITY WARNING: don't run with debug turned on in production! | ||||
| DEBUG = True | ||||
| 
 | ||||
| ALLOWED_HOSTS = ['192.168.99.100'] | ||||
| 
 | ||||
| 
 | ||||
| # Application definition | ||||
| 
 | ||||
| INSTALLED_APPS = [ | ||||
|     'django.contrib.admin', | ||||
|     'django.contrib.auth', | ||||
|     'django.contrib.contenttypes', | ||||
|     'django.contrib.sessions', | ||||
|     'django.contrib.messages', | ||||
|     'django.contrib.staticfiles', | ||||
| ] | ||||
| 
 | ||||
| MIDDLEWARE = [ | ||||
|     'django.middleware.security.SecurityMiddleware', | ||||
|     'django.contrib.sessions.middleware.SessionMiddleware', | ||||
|     'django.middleware.common.CommonMiddleware', | ||||
|     'django.middleware.csrf.CsrfViewMiddleware', | ||||
|     'django.contrib.auth.middleware.AuthenticationMiddleware', | ||||
|     'django.contrib.messages.middleware.MessageMiddleware', | ||||
|     'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||||
| ] | ||||
| 
 | ||||
| ROOT_URLCONF = 'reimbursinator.urls' | ||||
| 
 | ||||
| TEMPLATES = [ | ||||
|     { | ||||
|         'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||||
|         'DIRS': [], | ||||
|         'APP_DIRS': True, | ||||
|         'OPTIONS': { | ||||
|             'context_processors': [ | ||||
|                 'django.template.context_processors.debug', | ||||
|                 'django.template.context_processors.request', | ||||
|                 'django.contrib.auth.context_processors.auth', | ||||
|                 'django.contrib.messages.context_processors.messages', | ||||
|             ], | ||||
|         }, | ||||
|     }, | ||||
| ] | ||||
| 
 | ||||
| WSGI_APPLICATION = 'reimbursinator.wsgi.application' | ||||
| 
 | ||||
| 
 | ||||
| # Database | ||||
| # https://docs.djangoproject.com/en/2.1/ref/settings/#databases | ||||
| 
 | ||||
| DATABASES = { | ||||
|     'default': { | ||||
|         'ENGINE': 'django.db.backends.sqlite3', | ||||
|         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| # Password validation | ||||
| # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators | ||||
| 
 | ||||
| AUTH_PASSWORD_VALIDATORS = [ | ||||
|     { | ||||
|         'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | ||||
|     }, | ||||
|     { | ||||
|         'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | ||||
|     }, | ||||
|     { | ||||
|         'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | ||||
|     }, | ||||
|     { | ||||
|         'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | ||||
|     }, | ||||
| ] | ||||
| 
 | ||||
| 
 | ||||
| # Internationalization | ||||
| # https://docs.djangoproject.com/en/2.1/topics/i18n/ | ||||
| 
 | ||||
| LANGUAGE_CODE = 'en-us' | ||||
| 
 | ||||
| TIME_ZONE = 'UTC' | ||||
| 
 | ||||
| USE_I18N = True | ||||
| 
 | ||||
| USE_L10N = True | ||||
| 
 | ||||
| USE_TZ = True | ||||
| 
 | ||||
| 
 | ||||
| # Static files (CSS, JavaScript, Images) | ||||
| # https://docs.djangoproject.com/en/2.1/howto/static-files/ | ||||
| 
 | ||||
| STATIC_URL = '/static/' | ||||
							
								
								
									
										21
									
								
								app/reimbursinator/urls.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								app/reimbursinator/urls.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,21 @@ | |||
| """reimbursinator URL Configuration | ||||
| 
 | ||||
| The `urlpatterns` list routes URLs to views. For more information please see: | ||||
|     https://docs.djangoproject.com/en/2.1/topics/http/urls/ | ||||
| Examples: | ||||
| Function views | ||||
|     1. Add an import:  from my_app import views | ||||
|     2. Add a URL to urlpatterns:  path('', views.home, name='home') | ||||
| Class-based views | ||||
|     1. Add an import:  from other_app.views import Home | ||||
|     2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home') | ||||
| Including another URLconf | ||||
|     1. Import the include() function: from django.urls import include, path | ||||
|     2. Add a URL to urlpatterns:  path('blog/', include('blog.urls')) | ||||
| """ | ||||
| from django.contrib import admin | ||||
| from django.urls import path | ||||
| 
 | ||||
| urlpatterns = [ | ||||
|     path('admin/', admin.site.urls), | ||||
| ] | ||||
							
								
								
									
										16
									
								
								app/reimbursinator/wsgi.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								app/reimbursinator/wsgi.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | |||
| """ | ||||
| WSGI config for reimbursinator project. | ||||
| 
 | ||||
| It exposes the WSGI callable as a module-level variable named ``application``. | ||||
| 
 | ||||
| For more information on this file, see | ||||
| https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/ | ||||
| """ | ||||
| 
 | ||||
| import os | ||||
| 
 | ||||
| from django.core.wsgi import get_wsgi_application | ||||
| 
 | ||||
| os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'reimbursinator.settings') | ||||
| 
 | ||||
| application = get_wsgi_application() | ||||
							
								
								
									
										22
									
								
								docker-compose.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								docker-compose.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,22 @@ | |||
| version: '3.6' | ||||
| 
 | ||||
| services: | ||||
|   api: | ||||
|     build: ./app | ||||
|     command: gunicorn reimbursinator.wsgi:application --bind 0.0.0.0:81 | ||||
|     volumes: | ||||
|       - ./app/:/usr/src/app/ | ||||
|     ports: | ||||
|       - 8001:81 | ||||
|     environment: | ||||
|       - SECRET_KEY=please_change | ||||
|   web: | ||||
|     image: nginx:1.10.3 | ||||
|     volumes: | ||||
|       - ./static:/usr/share/nginx/html | ||||
|     ports: | ||||
|       - "8000:80" | ||||
|     environment: | ||||
|       - NGINX_HOST=reimbursinator.com | ||||
|       - NGINX_PORT=80 | ||||
|     command: /bin/bash -c "exec nginx -g 'daemon off;'" | ||||
|  | @ -1,8 +0,0 @@ | |||
| # Use nginx mainline as parent image | ||||
| FROM nginx:mainline | ||||
| 
 | ||||
| # Make port 80 available to the world outside this container | ||||
| EXPOSE 80 | ||||
| 
 | ||||
| # Copy over html documents | ||||
| COPY html /usr/share/nginx/html | ||||
							
								
								
									
										
											BIN
										
									
								
								static/favicon.ico
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								static/favicon.ico
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.1 KiB | 
|  | @ -1,12 +1,13 @@ | |||
| <!DOCTYPE html> | ||||
| <!doctype html> | ||||
| <html lang="en"> | ||||
| <head> | ||||
| 	<meta charset="utf-8"> | ||||
| 	<meta name="viewport" content="initial-scale=1, width=device-width"> | ||||
| 	<title>Reimbursinator</title> | ||||
| 	<link rel="shortcut icon" href="/favicon.ico" /> | ||||
| </head> | ||||
| <body> | ||||
| <h1>Reimbursinator v.1</h1> | ||||
| <p>This content served by nginx.</p> | ||||
| 	<h1>Reimbursinator v0.1</h1> | ||||
| 	<p>This content served by nginx</p> | ||||
| </body> | ||||
| </html> | ||||
| </html> | ||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 kououken
						kououken