make it kubernetes friendly
continuous-integration/drone/push Build is failing Details

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
!.gitignore
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, ...)
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.2/howto/deployment/checklist/
# 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 = secret_key.read().strip()
SECRET_KEY = os.environ.get("SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
@ -53,7 +51,6 @@ INSTALLED_APPS = [
'geogame.main',
'django_countries',
]
MIDDLEWARE = [
@ -71,7 +68,7 @@ ROOT_URLCONF = 'geogame.urls'
TEMPLATES = [
{
'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,
'OPTIONS': {
'context_processors': [
@ -86,21 +83,19 @@ TEMPLATES = [
WSGI_APPLICATION = 'geogame.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
with open(os.path.join(BASE_DIR, "env_db.txt")) as db_pw:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'geogame',
'USER': 'geogame',
'PASSWORD': db_pw.read().strip(),
'HOST': 'localhost',
'PORT': '',
}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'geogame',
'USER': 'geogame',
'PASSWORD': os.environ.get("DB_PW"),
'HOST': '192.168.8.4',
'PORT': '5432',
}
}
# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
@ -120,7 +115,6 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
# Internationalization
# 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_URL = '/attachments/'
with open(os.path.join(BASE_DIR, "env_email_key.txt")) as email_key:
SENDGRID_API_KEY = email_key.read().strip()
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'apikey'
EMAIL_HOST_PASSWORD = SENDGRID_API_KEY
EMAIL_PORT = 587
EMAIL_HOST = '192.168.8.7'
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = 25
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = "admin@peakdistrictwalks.org.uk"
DEFAULT_FROM_EMAIL = "geogame@kmlabz.com"
# AUTH

View File

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