From 0f0353340883fe215f6068d6b81a9861a315befe Mon Sep 17 00:00:00 2001 From: kououken Date: Thu, 20 Dec 2018 11:46:26 -0600 Subject: [PATCH] Frontend (nginx) and backend (gunicorn) now both working for docker deployment. --- app/Dockerfile | 18 ++++ app/Pipfile | 13 +++ app/Pipfile.lock | 36 ++++++++ app/db.sqlite3 | Bin 0 -> 131072 bytes app/manage.py | 15 ++++ app/reimbursinator/__init__.py | 0 app/reimbursinator/settings.py | 120 +++++++++++++++++++++++++++ app/reimbursinator/urls.py | 21 +++++ app/reimbursinator/wsgi.py | 16 ++++ docker-compose.yml | 22 +++++ frontend/Dockerfile | 8 -- static/favicon.ico | Bin 0 -> 1150 bytes {frontend/html => static}/index.html | 9 +- 13 files changed, 266 insertions(+), 12 deletions(-) create mode 100644 app/Dockerfile create mode 100644 app/Pipfile create mode 100644 app/Pipfile.lock create mode 100644 app/db.sqlite3 create mode 100644 app/manage.py create mode 100644 app/reimbursinator/__init__.py create mode 100644 app/reimbursinator/settings.py create mode 100644 app/reimbursinator/urls.py create mode 100644 app/reimbursinator/wsgi.py create mode 100644 docker-compose.yml delete mode 100644 frontend/Dockerfile create mode 100644 static/favicon.ico rename {frontend/html => static}/index.html (55%) diff --git a/app/Dockerfile b/app/Dockerfile new file mode 100644 index 0000000..ac22c17 --- /dev/null +++ b/app/Dockerfile @@ -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/ diff --git a/app/Pipfile b/app/Pipfile new file mode 100644 index 0000000..f6bb2dc --- /dev/null +++ b/app/Pipfile @@ -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" diff --git a/app/Pipfile.lock b/app/Pipfile.lock new file mode 100644 index 0000000..fe77e7d --- /dev/null +++ b/app/Pipfile.lock @@ -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": {} +} diff --git a/app/db.sqlite3 b/app/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..b6fecf6420251615360cff2635ba0af13237cc93 GIT binary patch literal 131072 zcmeI5TWllOdBuFpm_;`A{PW``_Kf) zIcH`#7gAhC&Z4mN=fXptbH4M<|NEUYXL!yTi&vh%sCTs3PP0{4JF$!~C5WQ%u2@VE zgk}04d$(Ta=?BS5(09@C`Jj)>!nwft05c~4$82Qd?I3gHg8&GC00@8p2!H?xfB*=9 z00@8p2>kI0%*{rqQxaYj$T!GmNQEp$e-!;h^nB!Zk$;NZiDbh+3%?eAA1%fU1V8`; zKmY_l00ck)1VG?85Xg{#aC&K@t+m^Fv(Zi_lPN`S=p9|HrIV?`YAU^&PR3HXCvur5 z(#3PBd@`9{zYq-wbJsT1z0M60aI|Bn*U(aRN(@%|2 z56@X1GENU#UDazto2YPZJ((_~^Us8+lNT%}Y17HB)~f5g%iO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CM@8k>QqohQhAmQjwqW=*6Otcl< zj-HE7M}8goZshMHFGsFM&V>Ib{Dbh{h40Y{c!2;2fB*=900@8p2!H?xfPjZUd_EwE zORK@#x^_n~f4=W2wGm_Kn3;Y|rZ$OGkp7UhMt@1tVP)j>>`oeX=1=W9?2H`CE;dK) z&a4F0O2z4nCM}DVS!%Jm9^k6XAJJpK3f@y@=EYd%+6*;LJsB|NdCX0Tt_sse1yiS| zf~nP6A#s9MSjh#LV2?Eu?KC|#MNJpZN?bYnA3J$XNz0d3{pR_57N!8hX2P&B z74&RO2|RsjoZ2j$^)n4U115qemd9x6O2)@k*grwolVWE*9-@|O>poMDUBGNjQFi9z zLBrZqW*0DPQ=XmqSb$n5Qa+~9&Sj=dsGaku6cEPGrnp%8^RM&==v#MtQfWqv=PdiF z)k@A3>a;Uu+Lk_UX^M1Oni6}KagkastucX4GbXQRgXjM}0~V4X00JNY0w4eaAOHd& r00JNY0w8b%31I$z1RE70fdB}A00@8p2!H?xfB*=900@A9hrsUv2ZE)( literal 0 HcmV?d00001 diff --git a/app/manage.py b/app/manage.py new file mode 100644 index 0000000..689d9f6 --- /dev/null +++ b/app/manage.py @@ -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) diff --git a/app/reimbursinator/__init__.py b/app/reimbursinator/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/reimbursinator/settings.py b/app/reimbursinator/settings.py new file mode 100644 index 0000000..fb4838a --- /dev/null +++ b/app/reimbursinator/settings.py @@ -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/' diff --git a/app/reimbursinator/urls.py b/app/reimbursinator/urls.py new file mode 100644 index 0000000..04f4d6d --- /dev/null +++ b/app/reimbursinator/urls.py @@ -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), +] diff --git a/app/reimbursinator/wsgi.py b/app/reimbursinator/wsgi.py new file mode 100644 index 0000000..ff66723 --- /dev/null +++ b/app/reimbursinator/wsgi.py @@ -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() diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f9c5ffc --- /dev/null +++ b/docker-compose.yml @@ -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;'" diff --git a/frontend/Dockerfile b/frontend/Dockerfile deleted file mode 100644 index 44556fe..0000000 --- a/frontend/Dockerfile +++ /dev/null @@ -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 diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..5561c4ac7e2293d9924d82691c9080ad82777e16 GIT binary patch literal 1150 zcmbVM-A|HX6o1>g>&A7_b(j4o-L$pVO|#9c)+T9zhNbD!si61)$cG>xZXk*k8bWEc z)R+7~35YgzIj0wv^9G3oL==9V_fh;>>!Rn~@0{m7zjMy>Jm)#@%W>!EDJbAbUgk>9 zbKE74) z>4d}4$1phPL?V%3DTH-}5s5@#=+eV#wZPhAf!WlJ&CSh2?i-43U4x{g5apuVD7<+U z!C;Va*(~joX3wNzh>CAOT6PB&{bH!y=fqa^e+eZ>)qtr(}FCmqm1I3z`l&2JJ??a#)~lt%JwoKHy2}G%Cv7g26r$ z@n-0hGK9k+#tY|5B$60#*b$iJ;h&noH2)E5RR_9_MyOOOIBZsg=00P__X$DLUAj)T zrjS6W>+bF@yk0NqG*Za~(mN^aq>_mLiedYA9O?89vnPoI?bq-3Q=J`b{rtU*jEo>2 zk0Y5((tfs?-rLI{lgY5WnanOysTA`O0tW{AvADR%atLC0Xb4lj34}udgo5*!pPRwx zJ1@b5(YGFWsUFi)Jidm%AQBE@j5xRZphiNx`^_+VOnSJ7U&1@$f}%x6ci_Xy$_kd2 zmaw+AhW>sBtA)qyLa)VuUh0MX`0#!VFKQ}b?$*L&)S&9AgledQ-DYF`Vz=8+TT_kp z)+V-&ys?)0Nt+MH?CdNm#3j(G6;QS{p|!allClRVExC&_(LJW?YNSxL%b?e^Ln;x$ z<$8S-zp$`?s>*U$x^>WNmDC?2divPK>0r8_! zv?=6JG|LE0e}%lM0V-t&tA`Mrzdu0>XBZzJ2ha21Cnt}=AJ4xpFSGCXWNiLF@W1*G Doj*;G literal 0 HcmV?d00001 diff --git a/frontend/html/index.html b/static/index.html similarity index 55% rename from frontend/html/index.html rename to static/index.html index 81aca20..660996a 100644 --- a/frontend/html/index.html +++ b/static/index.html @@ -1,12 +1,13 @@ - + Reimbursinator + -

Reimbursinator v.1

-

This content served by nginx.

+

Reimbursinator v0.1

+

This content served by nginx

- + \ No newline at end of file