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 0000000..b6fecf6 Binary files /dev/null and b/app/db.sqlite3 differ 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 0000000..5561c4a Binary files /dev/null and b/static/favicon.ico differ 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