aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-10-06 17:35:50 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-10-06 17:35:50 +0100
commit2947010fe6fe3d54019164f9d8213a2fede55a45 (patch)
tree67796ab10edfa25562019e0e19cfb4075405e4d2
parent22f2d467a5b05e0a878d2c3125ef4f8ee8584f9b (diff)
SETTINGS FOR A GKE DEPLOY - not used
-rw-r--r--.gitignore2
-rw-r--r--Dockerfile35
-rw-r--r--config/settings/gcloud_settings.py124
-rw-r--r--ctrack.yaml117
-rw-r--r--requirements.txt23
-rw-r--r--requirements/base.txt12
-rw-r--r--requirements/local.txt21
-rw-r--r--requirements/production.txt12
8 files changed, 298 insertions, 48 deletions
diff --git a/.gitignore b/.gitignore
index 9236806..31ed3b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -287,3 +287,5 @@ ctrack/media/
.idea/
.sass-cache/
.vscode/
+ctrack-291710-service-account-key-SECRET.json
+static/
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..f1c158c
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,35 @@
+# Copyright 2015, Google, Inc.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# [START docker]
+
+# The Google App Engine python runtime is Debian Jessie with Python installed
+# and various os-level packages to allow installation of popular Python
+# libraries. The source is on github at:
+# https://github.com/GoogleCloudPlatform/python-docker
+FROM gcr.io/google_appengine/python
+
+# Create a virtualenv for the application dependencies.
+# # If you want to use Python 2, use the -p python2.7 flag.
+RUN virtualenv -p python3 /env
+ENV PATH /env/bin:$PATH
+
+#ADD requirements.txt /app/requirements.txt
+ADD requirements.txt /app/requirements.txt
+RUN /env/bin/pip install --upgrade pip && /env/bin/pip install -r /app/requirements.txt
+ADD . /app
+
+ENV DJANGO_SETTINGS_MODULE config.settings.gcloud_settings
+
+CMD gunicorn -b :$PORT config.wsgi
+# [END docker]
diff --git a/config/settings/gcloud_settings.py b/config/settings/gcloud_settings.py
new file mode 100644
index 0000000..253a76b
--- /dev/null
+++ b/config/settings/gcloud_settings.py
@@ -0,0 +1,124 @@
+# Copyright 2015 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+import os
+
+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/1.8/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = 'pf-@jxtojga)z+4s*uwbgjrq$aep62-thd0q7f&o77xtpka!_m'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+# SECURITY WARNING: If you deploy a Django app to production, make sure to set
+# an appropriate host here.
+# See https://docs.djangoproject.com/en/1.10/ref/settings/
+ALLOWED_HOSTS = ['*']
+
+# Application definition
+
+INSTALLED_APPS = (
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+ 'crispy_forms',
+ 'allauth',
+ 'allauth.account',
+ "ctrack.users.apps.UsersConfig",
+ "ctrack.organisations.apps.OrganisationsConfig",
+ "ctrack.caf.apps.CafConfig",
+ "ctrack.register.apps.RegisterConfig",
+ "ctrack.assessments.apps.AssessmentsConfig",
+ "ctrack.core.apps.CoreConfig",
+)
+
+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 = 'mysite.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 = "config.wsgi.application"
+
+# Database
+# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
+
+# [START dbconfig]
+DATABASES = {
+ 'default': {
+ # If you are using Cloud SQL for MySQL rather than PostgreSQL, set
+ # 'ENGINE': 'django.db.backends.mysql' instead of the following.
+ 'ENGINE': 'django.db.backends.postgresql',
+ 'NAME': 'ctrack',
+ 'USER': os.getenv('DATABASE_USER'),
+ 'PASSWORD': os.getenv('DATABASE_PASSWORD'),
+ 'HOST': '127.0.0.1',
+ 'PORT': '5432',
+ }
+}
+# [END dbconfig]
+
+# Internationalization
+# https://docs.djangoproject.com/en/1.8/topics/i18n/
+
+LANGUAGE_CODE = 'en-gb'
+
+TIME_ZONE = 'UTC'
+
+USE_I18N = True
+
+USE_L10N = True
+
+USE_TZ = True
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/1.8/howto/static-files/
+
+# [START staticurl]
+#STATIC_URL = '/static/'
+STATIC_URL = 'https://storage.googleapis.com/ctrack/static/'
+# [END staticurl]
+
+STATIC_ROOT = 'static/'
diff --git a/ctrack.yaml b/ctrack.yaml
new file mode 100644
index 0000000..526a708
--- /dev/null
+++ b/ctrack.yaml
@@ -0,0 +1,117 @@
+# Copyright 2015 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+# This file configures the ctrack application . The frontend serves
+# public web traffic.
+
+# The bookshelf frontend replication controller ensures that at least 3
+# instances of the bookshelf app are running on the cluster.
+# For more info about Pods see:
+# https://cloud.google.com/container-engine/docs/pods/
+# For more info about Deployments:
+# https://kubernetes.io/docs/user-guide/deployments/
+
+# [START kubernetes_deployment]
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: ctrack
+ labels:
+ app: ctrack
+spec:
+ replicas: 3
+ selector:
+ matchLabels:
+ app: ctrack
+ template:
+ metadata:
+ labels:
+ app: ctrack
+ spec:
+ containers:
+ - name: ctrack-app
+ # Replace with your project ID or use `make template`
+ image: gcr.io/ctrack-291710/ctrack
+ # This setting makes nodes pull the docker image every time before
+ # starting the pod. This is useful when debugging, but should be turned
+ # off in production.
+ imagePullPolicy: Always
+ env:
+ # [START cloudsql_secrets]
+ - name: DATABASE_USER
+ valueFrom:
+ secretKeyRef:
+ name: cloudsql
+ key: ctrack
+ - name: DATABASE_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: cloudsql
+ key: password
+ # [END cloudsql_secrets]
+ ports:
+ - containerPort: 8080
+
+ # [START proxy_container]
+ - image: gcr.io/cloudsql-docker/gce-proxy:1.16
+ name: cloudsql-proxy
+ command: ["/cloud_sql_proxy", "--dir=/cloudsql",
+ "-instances=ctrack-291710:europe-west2:ctrack=tcp:5432",
+ "-credential_file=/secrets/cloudsql/credentials.json"]
+ volumeMounts:
+ - name: cloudsql-oauth-credentials
+ mountPath: /secrets/cloudsql
+ readOnly: true
+ - name: ssl-certs
+ mountPath: /etc/ssl/certs
+ - name: cloudsql
+ mountPath: /cloudsql
+ # [END proxy_container]
+ # [START volumes]
+ volumes:
+ - name: cloudsql-oauth-credentials
+ secret:
+ secretName: cloudsql-oauth-credentials
+ - name: ssl-certs
+ hostPath:
+ path: /etc/ssl/certs
+ - name: cloudsql
+ emptyDir:
+ # [END volumes]
+# [END kubernetes_deployment]
+
+---
+
+# [START service]
+# The ctrack service provides a load-balancing proxy over the ctrack app
+# pods. By specifying the type as a 'LoadBalancer', Container Engine will
+# create an external HTTP load balancer.
+# For more information about Services see:
+# https://cloud.google.com/container-engine/docs/services/
+# For more information about external HTTP load balancing see:
+# https://cloud.google.com/container-engine/docs/load-balancer
+apiVersion: v1
+kind: Service
+metadata:
+ name: ctrack
+ labels:
+ app: ctrack
+spec:
+ type: LoadBalancer
+ ports:
+ - port: 80
+ targetPort: 8080
+ selector:
+ app: ctrack
+# [END service]
diff --git a/requirements.txt b/requirements.txt
index c1b500c..ad52554 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,20 @@
-# This file is expected by Heroku.
-
--r requirements/production.txt
+Django==3.0.2; python_version > '3.5'
+Django==2.2.9; python_version == '3.5'
+Django==1.11.28;python_version < '3.0'
+# Uncomment the mysqlclient requirement if you are using MySQL rather than
+# PostgreSQL. You must also have a MySQL client installed in that case.
+#mysqlclient==1.4.1
+wheel==0.35.1
+gunicorn==20.0.4; python_version > '3.0'
+gunicorn==19.10.0; python_version < '3.0'
+# psycopg2==2.8.4 # uncomment if you prefer to build from source
+psycopg2-binary==2.8.6
+Faker>=4.0.3
+python-slugify==4.0.1
+pytest==5.4.2
+pytest-django==3.10.0
+selenium==3.141.0
+factory-boy==3.0.1
+django-extensions==2.2.6
+django-allauth>=0.41.0
+django-environ
diff --git a/requirements/base.txt b/requirements/base.txt
deleted file mode 100644
index b1c994e..0000000
--- a/requirements/base.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-# Django
-# ------------------------------------------------------------------------------
-django==2.2.12 # pyup: < 3.0 # https://www.djangoproject.com/
-django-environ # https://github.com/joke2k/django-environ
-django-allauth>=0.41.0
-django-crispy-forms>=1.9.0
-
-# These were required for the basic run
-python-slugify
-argon2-cffi
-
-Faker>=4.0.3
diff --git a/requirements/local.txt b/requirements/local.txt
deleted file mode 100644
index ac8007c..0000000
--- a/requirements/local.txt
+++ /dev/null
@@ -1,21 +0,0 @@
--r ./base.txt
-
-ipdb # https://github.com/gotcha/ipdb
-psycopg2-binary # https://github.com/psycopg/psycopg2
-
-# Testing
-# ------------------------------------------------------------------------------
-pytest==5.4.2 # https://github.com/pytest-dev/pytest
-selenium==3.141.0
-
-# Code quality
-# ------------------------------------------------------------------------------
-black # https://github.com/ambv/black
-django_pdb
-
-# Django
-# ------------------------------------------------------------------------------
-factory-boy==3.0.1 # https://github.com/FactoryBoy/factory_boy
-
-django-extensions==2.2.6 # https://github.com/django-extensions/django-extensions
-pytest-django # https://github.com/pytest-dev/pytest-django
diff --git a/requirements/production.txt b/requirements/production.txt
deleted file mode 100644
index 810a210..0000000
--- a/requirements/production.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-# PRECAUTION: avoid production dependencies that aren't in development
-
--r ./base.txt
-
-gunicorn==20.0.4 # https://github.com/benoitc/gunicorn
-psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2
-Collectfast==1.3.1 # https://github.com/antonagestam/collectfast
-
-# Django
-# ------------------------------------------------------------------------------
-django-storages[google]==1.8 # https://github.com/jschneier/django-storages
-django-anymail[mailgun]==7.0.0 # https://github.com/anymail/django-anymail