make it kubernetes friendly
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Torma Kristóf 2020-12-29 21:43:31 +01:00
parent dd1fd1c80f
commit 189326b30f
12 changed files with 145 additions and 28 deletions

25
.drone.yml Normal file
View File

@ -0,0 +1,25 @@
kind: pipeline
type: docker
name: default
steps:
- name: code-analysis
image: aosapps/drone-sonar-plugin
settings:
sonar_host:
from_secret: SONAR_HOST
sonar_token:
from_secret: SONAR_CODE
- name: kaniko
image: banzaicloud/drone-kaniko
settings:
registry: registry.kmlabz.com
repo: tormakris/${DRONE_REPO_NAME}
username:
from_secret: DOCKER_USERNAME
password:
from_secret: DOCKER_PASSWORD
tags:
- latest
- ${DRONE_BUILD_NUMBER}

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ env_secret_key.txt
/static /static
!.gitignore !.gitignore
gunicorn.conf.py gunicorn.conf.py
venv/

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../../../:\Users\torma\Documents\projects\geogame\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

30
.idea/geogame.iml Normal file
View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="FacetManager">
<facet type="django" name="Django">
<configuration>
<option name="rootFolder" value="$MODULE_DIR$" />
<option name="settingsModule" value="geogame/settings.py" />
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
<option name="environment" value="&lt;map/&gt;" />
<option name="doNotUseTestRunner" value="false" />
<option name="trackFilePattern" value="migrations" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Django" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/geogame/templates" />
</list>
</option>
</component>
</module>

View File

@ -0,0 +1,23 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="pylibmc" />
</list>
</value>
</option>
</inspection_tool>
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredIdentifiers">
<list>
<option value="models.VideonUser.query" />
<option value="models.StreamResource.query" />
<option value="models.OutputUrls.query" />
</list>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (geogame)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/geogame.iml" filepath="$PROJECT_DIR$/.idea/geogame.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM python:3-slim
ENV TZ Europe/Budapest
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt && rm -rf requirements.txt
COPY ./geogame .
EXPOSE 8080
ENTRYPOINT ["gunicorn", "-b", "0.0.0.0:8080", "--workers", "4", "--threads", "4", "wsgi:application"]

View File

@ -15,13 +15,11 @@ import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
with open(os.path.join(BASE_DIR, "env_secret_key.txt")) as secret_key: SECRET_KEY = os.environ.get("SECRET_KEY")
SECRET_KEY = secret_key.read().strip()
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False DEBUG = False
@ -53,7 +51,6 @@ INSTALLED_APPS = [
'geogame.main', 'geogame.main',
'django_countries', 'django_countries',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -71,7 +68,7 @@ ROOT_URLCONF = 'geogame.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "geogame/templates"),], 'DIRS': [os.path.join(BASE_DIR, "geogame/templates"), ],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
@ -86,21 +83,19 @@ TEMPLATES = [
WSGI_APPLICATION = 'geogame.wsgi.application' WSGI_APPLICATION = 'geogame.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
with open(os.path.join(BASE_DIR, "env_db.txt")) as db_pw: DATABASES = {
DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'geogame', 'NAME': 'geogame',
'USER': 'geogame', 'USER': 'geogame',
'PASSWORD': db_pw.read().strip(), 'PASSWORD': os.environ.get("DB_PW"),
'HOST': 'localhost', 'HOST': '192.168.8.4',
'PORT': '', 'PORT': '5432',
}
} }
}
# Password validation # Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
@ -120,7 +115,6 @@ AUTH_PASSWORD_VALIDATORS = [
}, },
] ]
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/ # https://docs.djangoproject.com/en/2.2/topics/i18n/
@ -143,16 +137,12 @@ STATIC_ROOT = os.path.join(BASE_DIR, "static")
MEDIA_ROOT = os.path.join(BASE_DIR, "media") MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = '/attachments/' MEDIA_URL = '/attachments/'
EMAIL_HOST = '192.168.8.7'
with open(os.path.join(BASE_DIR, "env_email_key.txt")) as email_key: EMAIL_HOST_USER = ''
SENDGRID_API_KEY = email_key.read().strip() EMAIL_HOST_PASSWORD = ''
EMAIL_HOST = 'smtp.sendgrid.net' EMAIL_PORT = 25
EMAIL_HOST_USER = 'apikey'
EMAIL_HOST_PASSWORD = SENDGRID_API_KEY
EMAIL_PORT = 587
EMAIL_USE_TLS = True EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = "admin@peakdistrictwalks.org.uk" DEFAULT_FROM_EMAIL = "geogame@kmlabz.com"
# AUTH # AUTH

View File

@ -11,10 +11,10 @@ django-extensions==2.2.1
django-starfield==1.0.post1 django-starfield==1.0.post1
geographiclib==1.49 geographiclib==1.49
geopy==1.20.0 geopy==1.20.0
gunicorn==19.9.0 gunicorn
idna==2.8 idna==2.8
oauthlib==3.1.0 oauthlib==3.1.0
psycopg2==2.8.3 psycopg2-binary
python3-openid==3.1.0 python3-openid==3.1.0
pytz==2019.2 pytz==2019.2
requests==2.22.0 requests==2.22.0