archive
This commit is contained in:
2
silverstrike/fork/.dockerignore
Executable file
2
silverstrike/fork/.dockerignore
Executable file
@@ -0,0 +1,2 @@
|
||||
Dockerfile
|
||||
**/*.sw*
|
||||
42
silverstrike/fork/Dockerfile
Executable file
42
silverstrike/fork/Dockerfile
Executable file
@@ -0,0 +1,42 @@
|
||||
FROM ubuntu:18.04
|
||||
|
||||
# Copy the code
|
||||
ADD . /code
|
||||
WORKDIR /code
|
||||
|
||||
# install deps
|
||||
RUN apt-get update && apt-get install -y gcc libmariadbclient-dev python3-dev python3-pip && \
|
||||
pip3 install --no-cache-dir -r requirements.txt && \
|
||||
apt-get remove -y gcc && apt-get autoremove -y
|
||||
|
||||
# configure django
|
||||
ENV DJANGO_SETTINGS_MODULE=settings
|
||||
|
||||
# configure uwsgi
|
||||
ENV UWSGI_WSGI_FILE=wsgi.py UWSGI_HTTP=:8000 UWSGI_MASTER=1 UWSGI_WORKERS=2 UWSGI_THREADS=8 UWSGI_UID=1000 UWSGI_GID=2000 UWSGI_LAZY_APPS=1 UWSGI_WSGI_ENV_BEHAVIOR=holy
|
||||
|
||||
# collect static files
|
||||
RUN python3 manage.py collectstatic
|
||||
|
||||
#### POSTGRES
|
||||
RUN \
|
||||
apt -y install \
|
||||
curl \
|
||||
rsync \
|
||||
cron \
|
||||
postgresql postgresql-contrib \
|
||||
sudo \
|
||||
&& mkdir -p /mnt/save \
|
||||
&& service postgresql start
|
||||
USER postgres
|
||||
RUN service postgresql start \
|
||||
&& psql --command "CREATE USER ss WITH SUPERUSER PASSWORD 'ss';" \
|
||||
&& psql --command "CREATE DATABASE silverstrikedb;" \
|
||||
&& psql --command "GRANT ALL PRIVILEGES ON DATABASE silverstrikedb TO ss;"
|
||||
USER root
|
||||
|
||||
ENV ALLOWED_HOSTS=*
|
||||
ENV DATABASE_URL=postgres://ss:ss@localhost/silverstrikedb
|
||||
ENV SECRET_KEY=AimmBfzjdWcVN3rQs8YawbUowv5R8Eex
|
||||
|
||||
CMD service postgresql start && (until psql $DATABASE_URL < /dev/null; do sleep 5; done) && python3 manage.py migrate && uwsgi
|
||||
21
silverstrike/fork/LICENSE
Executable file
21
silverstrike/fork/LICENSE
Executable file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 - 2018 Simon Hanna
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
21
silverstrike/fork/docker-compose.yml
Executable file
21
silverstrike/fork/docker-compose.yml
Executable file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
version: "3.2"
|
||||
services:
|
||||
app:
|
||||
environment:
|
||||
- ALLOWED_HOSTS='*'
|
||||
- DATABASE_URL=postgres://silverstrike:secretpass@database/silverstrikedb
|
||||
- SECRET_KEY=PLprXpLzxemgLD57GPQQ84SBZdLVKFYg
|
||||
image: simhnna/silverstrike
|
||||
links:
|
||||
- database:database
|
||||
ports:
|
||||
- 8000:8000
|
||||
database:
|
||||
environment:
|
||||
POSTGRES_DB: silverstrikedb
|
||||
POSTGRES_USER: silverstrike
|
||||
POSTGRES_PASSWORD: secretpass
|
||||
image: postgres:10.3
|
||||
volumes:
|
||||
- ./silverstrikedb:/var/lib/postgresql/data
|
||||
22
silverstrike/fork/manage.py
Executable file
22
silverstrike/fork/manage.py
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError:
|
||||
# The above import may fail for some other reason. Ensure that the
|
||||
# issue is really that Django is missing to avoid masking other
|
||||
# exceptions on Python 2.
|
||||
try:
|
||||
import django
|
||||
except ImportError:
|
||||
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?"
|
||||
)
|
||||
raise
|
||||
execute_from_command_line(sys.argv)
|
||||
BIN
silverstrike/fork/master.zip
Executable file
BIN
silverstrike/fork/master.zip
Executable file
Binary file not shown.
6
silverstrike/fork/requirements.txt
Executable file
6
silverstrike/fork/requirements.txt
Executable file
@@ -0,0 +1,6 @@
|
||||
silverstrike
|
||||
whitenoise
|
||||
uwsgi
|
||||
psycopg2-binary
|
||||
dj-database-url
|
||||
mysqlclient
|
||||
163
silverstrike/fork/settings.py
Executable file
163
silverstrike/fork/settings.py
Executable file
@@ -0,0 +1,163 @@
|
||||
"""
|
||||
Django settings for demo project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 1.10.3.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/1.10/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/1.10/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
import dj_database_url
|
||||
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY', 'PLprXpLzxemgLD57GPQQ84SBZdLVKFYg')
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.humanize',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.sites',
|
||||
'widget_tweaks',
|
||||
'silverstrike',
|
||||
'allauth',
|
||||
'allauth.account',
|
||||
'rest_framework',
|
||||
'rest_framework.authtoken'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = '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 = 'wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': dj_database_url.config(conn_max_age=600)
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/1.10/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',
|
||||
},
|
||||
]
|
||||
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
'allauth.account.auth_backends.AuthenticationBackend',
|
||||
)
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.10/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/1.10/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||
|
||||
|
||||
LOGIN_REDIRECT_URL = 'index'
|
||||
LOGIN_URL = 'account_login'
|
||||
LOGOUT_URL = 'account_logout'
|
||||
ACCOUNT_LOGOUT_REDIRECT_URL = 'account_login'
|
||||
ACCOUNT_ADAPTER = 'signupadapter.SignupDisabledAdapter'
|
||||
|
||||
# Uncomment to prevent signup
|
||||
# ACCOUNT_ADAPTER = 'silverstrike.models.SignupDisabledAdapter'
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.IsAuthenticated'
|
||||
],
|
||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||
'PAGE_SIZE': 10,
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||||
'rest_framework.authentication.BasicAuthentication',
|
||||
'rest_framework.authentication.SessionAuthentication',
|
||||
'rest_framework.authentication.TokenAuthentication'
|
||||
)
|
||||
}
|
||||
|
||||
6
silverstrike/fork/signupadapter.py
Executable file
6
silverstrike/fork/signupadapter.py
Executable file
@@ -0,0 +1,6 @@
|
||||
from allauth.account.adapter import DefaultAccountAdapter
|
||||
|
||||
|
||||
class SignupDisabledAdapter(DefaultAccountAdapter):
|
||||
def is_open_for_signup(self, request):
|
||||
return False
|
||||
9
silverstrike/fork/urls.py
Executable file
9
silverstrike/fork/urls.py
Executable file
@@ -0,0 +1,9 @@
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from django.views.generic import RedirectView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include('silverstrike.urls')),
|
||||
]
|
||||
16
silverstrike/fork/wsgi.py
Executable file
16
silverstrike/fork/wsgi.py
Executable file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for demo 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/1.10/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
|
||||
|
||||
application = get_wsgi_application()
|
||||
Reference in New Issue
Block a user