Add one click installer scripts/autoinstall.sh
This commit is contained in:
+6
-1
@@ -1,11 +1,16 @@
|
|||||||
version: '2'
|
version: '2'
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: scripts/db/Dockerfile
|
||||||
image: mariadb
|
image: mariadb
|
||||||
environment:
|
environment:
|
||||||
- MYSQL_ROOT_PASSWORD=toor
|
- MYSQL_ROOT_PASSWORD=toor
|
||||||
web:
|
web:
|
||||||
build: .
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: scripts/web/Dockerfile
|
||||||
command: python manage.py runserver 0.0.0.0:8000
|
command: python manage.py runserver 0.0.0.0:8000
|
||||||
volumes:
|
volumes:
|
||||||
- .:/code
|
- .:/code
|
||||||
|
|||||||
Executable
+56
@@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Checking if docker is installed..."
|
||||||
|
docker --version
|
||||||
|
if [ "$?" -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "Installing docker..."
|
||||||
|
apt install docker -y
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Checking if docker-compose is installed..."
|
||||||
|
docker-compose --version
|
||||||
|
if [ "$?" -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "Installing docker-compose 1.11.2..."
|
||||||
|
curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
|
||||||
|
chmod +x /usr/local/bin/docker-compose
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Building db container..."
|
||||||
|
docker-compose build db
|
||||||
|
|
||||||
|
echo "Starting db container..."
|
||||||
|
docker-compose up -d db
|
||||||
|
|
||||||
|
echo "Waiting 10 seconds..."
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
echo "Importing database settings..."
|
||||||
|
docker-compose exec db sh /db/install.sh
|
||||||
|
if [ "$?" -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "Success!"
|
||||||
|
else
|
||||||
|
echo "Failure!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Shutting down db container..."
|
||||||
|
|
||||||
|
echo "Copying settings..."
|
||||||
|
cp sikweb/settings-docker-sample.py sikweb/settings.py
|
||||||
|
|
||||||
|
echo "Building web container..."
|
||||||
|
docker-compose build web
|
||||||
|
|
||||||
|
echo "Running manage.py commands..."
|
||||||
|
docker-compose run web python manage.py migrate
|
||||||
|
docker-compose run web python manage.py makemigrations infoscreen members webapp
|
||||||
|
docker-compose run web python manage.py migrate
|
||||||
|
docker-compose run web python manage.py createdefaultadmin
|
||||||
|
|
||||||
|
echo "Starting all containers..."
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
echo "Done."
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
FROM mariadb:latest
|
||||||
|
RUN mkdir -p /db
|
||||||
|
WORKDIR /db
|
||||||
|
ADD scripts/db/init.sql /db/
|
||||||
|
ADD scripts/db/install.sh /db/
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
CREATE USER 'sik'@'%' IDENTIFIED BY 'password123';
|
||||||
|
CREATE DATABASE sik DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
|
||||||
|
GRANT ALL PRIVILEGES ON `sik\_%` . * TO 'sik'@'%' IDENTIFIED BY 'password123';
|
||||||
|
GRANT ALL PRIVILEGES ON sik.* TO 'sik'@'%';
|
||||||
|
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
mysql -u root -ptoor < /db/init.sql
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
FROM python:3.5
|
FROM python:3.5
|
||||||
ENV PYTHONBUFFERED 1
|
ENV PYTHONBUFFERED 1
|
||||||
RUN mkdir /code
|
RUN mkdir -p /code
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
ADD requirements.txt /code/
|
ADD requirements.txt /code/
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
../../requirements.txt
|
||||||
@@ -0,0 +1,207 @@
|
|||||||
|
"""
|
||||||
|
Django settings for sikweb project.
|
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 1.9.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/1.9/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/1.9/ref/settings/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
from os.path import expanduser
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
# 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/1.9/howto/deployment/checklist/
|
||||||
|
|
||||||
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
|
SECRET_KEY = '7p$85^4ibb^p4-=vs44b7!y0e-zemugze18@a#30&71=a8)dp('
|
||||||
|
|
||||||
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
|
DEBUG = True
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
|
|
||||||
|
# Application definition
|
||||||
|
|
||||||
|
INSTALLED_APPS = [
|
||||||
|
'django.contrib.admin',
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
'corsheaders',
|
||||||
|
'webapp',
|
||||||
|
'members',
|
||||||
|
'infoscreen',
|
||||||
|
'rest_framework',
|
||||||
|
'django_nose',
|
||||||
|
]
|
||||||
|
|
||||||
|
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
|
||||||
|
|
||||||
|
NOSE_ARGS = [
|
||||||
|
'--with-coverage',
|
||||||
|
'--cover-package=webapp,members,infoscreen',
|
||||||
|
]
|
||||||
|
|
||||||
|
MIDDLEWARE_CLASSES = [
|
||||||
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'django.middleware.locale.LocaleMiddleware',
|
||||||
|
'corsheaders.middleware.CorsMiddleware',
|
||||||
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
|
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
||||||
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
]
|
||||||
|
CORS_ORIGIN_ALLOW_ALL = True
|
||||||
|
|
||||||
|
ROOT_URLCONF = 'sikweb.urls'
|
||||||
|
|
||||||
|
TEMPLATES = [
|
||||||
|
{
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
'DIRS': ['templates'],
|
||||||
|
'APP_DIRS': True,
|
||||||
|
'OPTIONS': {
|
||||||
|
'context_processors': [
|
||||||
|
'django.template.context_processors.debug',
|
||||||
|
'django.template.context_processors.request',
|
||||||
|
'django.template.context_processors.i18n',
|
||||||
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
'django.core.context_processors.static',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
WSGI_APPLICATION = 'sikweb.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
# Database
|
||||||
|
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
|
'NAME': 'sik',
|
||||||
|
'USER': 'sik',
|
||||||
|
'PASSWORD': 'password123',
|
||||||
|
'HOST': 'db',
|
||||||
|
'PORT': '3306',
|
||||||
|
'TEST': {
|
||||||
|
'NAME': 'sik_test',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/1.9/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',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
REST_FRAMEWORK = {
|
||||||
|
'DEFAULT_PERMISSION_CLASSES': (
|
||||||
|
'rest_framework.permissions.IsAuthenticated',
|
||||||
|
'rest_framework.permissions.DjangoModelPermissions',
|
||||||
|
),
|
||||||
|
'DEFAULT_THROTTLE_CLASSES': (
|
||||||
|
'members.throttles.BurstRateThrottle',
|
||||||
|
'members.throttles.SustainedRateThrottle'
|
||||||
|
),
|
||||||
|
'DEFAULT_THROTTLE_RATES': {
|
||||||
|
'burst': '60/min',
|
||||||
|
'sustained': '1000/day'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
# Email settings (tested working with gmail)
|
||||||
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||||
|
EMAIL_USE_TLS = True
|
||||||
|
EMAIL_HOST='smtp.gmail.com'
|
||||||
|
EMAIL_PORT=587
|
||||||
|
EMAIL_HOST_USER = '<gmailtunnarisi>@gmail.com'
|
||||||
|
EMAIL_HOST_PASSWORD = '<gmail_passu>'
|
||||||
|
DEFAULT_EMAIL_FROM = 'SIK Viestintä <sikviestinta@gmail.com>'
|
||||||
|
|
||||||
|
|
||||||
|
#ReCaptcha
|
||||||
|
# http://www.yaconiello.com/blog/integrating-google-recaptcha-to-django/
|
||||||
|
|
||||||
|
GOOGLE_RECAPTCHA_SITE_KEY = "YOUR-PUBLIC-KEY"
|
||||||
|
GOOGLE_RECAPTCHA_SECRET_KEY = "YOUR-PRIVATE-KEY"
|
||||||
|
|
||||||
|
#Logger level
|
||||||
|
|
||||||
|
LOGGERLEVEL = logging.ERROR
|
||||||
|
LOGPATH = "logs/debug.log"
|
||||||
|
|
||||||
|
# Internationalization
|
||||||
|
# https://docs.djangoproject.com/en/1.9/topics/i18n/
|
||||||
|
|
||||||
|
LANGUAGES = (
|
||||||
|
('en', _('English')),
|
||||||
|
('fi', _('Finnish')),
|
||||||
|
)
|
||||||
|
|
||||||
|
LANGUAGE_CODE = 'fi'
|
||||||
|
|
||||||
|
LOCALE_PATHS = (
|
||||||
|
os.path.join(BASE_DIR, 'locale'),
|
||||||
|
)
|
||||||
|
|
||||||
|
print("LOCALE_PATHS: {}".format(LOCALE_PATHS))
|
||||||
|
|
||||||
|
TIME_ZONE = 'Europe/Helsinki'
|
||||||
|
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
USE_L10N = True
|
||||||
|
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/1.9/howto/static-files/
|
||||||
|
STATICFILES_FINDERS = (
|
||||||
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||||
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||||
|
)
|
||||||
|
STATIC_URL = '/static/'
|
||||||
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||||
|
STATICFILES_DIRS = (
|
||||||
|
os.path.join(BASE_DIR, 'global_static'),
|
||||||
|
)
|
||||||
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||||
|
MEDIA_URL = '/media/'
|
||||||
|
|
||||||
|
HSL_USERHASH = 'YOUR HSL USERHASH HERE'
|
||||||
|
HSL_DEPARTURE_THRESHOLD = 8
|
||||||
|
HSL_HURRY_THRESHOLD = 13
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
user_name = "admin"
|
||||||
|
password = "password123"
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
u = User(username=self.user_name)
|
||||||
|
u.set_password(self.password)
|
||||||
|
u.is_superuser = True
|
||||||
|
u.is_staff = True
|
||||||
|
u.save()
|
||||||
|
|
||||||
|
self.stdout.write("Created default user {} with password {}.")
|
||||||
Reference in New Issue
Block a user