mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
add dockerfiles
This commit is contained in:
parent
1b0952cd0d
commit
e8841eae82
@ -8,7 +8,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr height="39" style="background-color:#50a5e6;">
|
<tr height="39" style="background-color:#50a5e6;">
|
||||||
<td style="padding-left:15px;font-family:'微软雅黑','黑体',arial;">
|
<td style="padding-left:15px;font-family:'微软雅黑','黑体',arial;">
|
||||||
{{ website_name }} 登录信息找回
|
{{ website_name }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -32,18 +32,18 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr height="30">
|
<tr height="30">
|
||||||
<td style="padding-left:55px;padding-right:55px;font-family:'微软雅黑','黑体',arial;font-size:14px;">
|
<td style="padding-left:55px;padding-right:55px;font-family:'微软雅黑','黑体',arial;font-size:14px;">
|
||||||
您刚刚在 {{ website_name }} 申请了找回登录信息服务。
|
We received a request to reset your password for {{ website_name }}.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr height="30">
|
<tr height="30">
|
||||||
<td style="padding-left:55px;padding-right:55px;font-family:'微软雅黑','黑体',arial;font-size:14px;">
|
<td style="padding-left:55px;padding-right:55px;font-family:'微软雅黑','黑体',arial;font-size:14px;">
|
||||||
请在<span style="color:rgb(255,0,0)">30分钟</span>内点击下面链接设置您的新密码:
|
You can use the following link to reset your password in <span style="color:rgb(255,0,0)">20 minutes.</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr height="60">
|
<tr height="60">
|
||||||
<td style="padding-left:55px;padding-right:55px;font-family:'微软雅黑','黑体',arial;font-size:14px;">
|
<td style="padding-left:55px;padding-right:55px;font-family:'微软雅黑','黑体',arial;font-size:14px;">
|
||||||
<a href="{{ link }}" target="_blank"
|
<a href="{{ link }}" target="_blank"
|
||||||
style="color: rgb(255,255,255);text-decoration: none;display: block;min-height: 39px;width: 158px;line-height: 39px;background-color:rgb(80,165,230);font-size:20px;text-align:center;">重置密码</a>
|
style="color: rgb(255,255,255);text-decoration: none;display: block;min-height: 39px;width: 158px;line-height: 39px;background-color:rgb(80,165,230);font-size:20px;text-align:center;">Reset Password</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr height="10">
|
<tr height="10">
|
||||||
@ -51,7 +51,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr height="20">
|
<tr height="20">
|
||||||
<td style="padding-left:55px;padding-right:55px;font-family:'微软雅黑','黑体',arial;font-size:12px;">
|
<td style="padding-left:55px;padding-right:55px;font-family:'微软雅黑','黑体',arial;font-size:12px;">
|
||||||
如果上面的链接点击无效,请复制以下链接至浏览器的地址栏直接打开。
|
If the button above doesn't work, please copy the following link to your browser and press enter.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr height="30">
|
<tr height="30">
|
||||||
@ -63,8 +63,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr height="20">
|
<tr height="20">
|
||||||
<td style="padding-left:55px;padding-right:55px;font-family:'微软雅黑','黑体',arial;font-size:12px;">
|
<td style="padding-left:55px;padding-right:55px;font-family:'微软雅黑','黑体',arial;font-size:12px;">
|
||||||
如果您没有提出过该申请,请忽略此邮件。有可能是其他用户误填了您的邮件地址,我们不会对你的帐户进行任何修改。
|
If you did not ask that, please ignore this email. It will expire and become useless in 20 minutes.
|
||||||
请不要向他人透露本邮件的内容,否则可能会导致您的账号被盗。
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr height="20">
|
<tr height="20">
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
FROM python:3.6-alpine3.6
|
FROM python:3.6-alpine3.6
|
||||||
|
|
||||||
ADD requirements.txt /tmp
|
ENV OJ_ENV production
|
||||||
RUN apk add --no-cache --virtual .build-deps build-base jpeg-dev zlib-dev postgresql-dev && \
|
RUN apk add --no-cache nginx supervisor jpeg-dev zlib-dev postgresql-dev freetype-dev
|
||||||
pip install -r /tmp/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple && \
|
|
||||||
apk del .build-deps --purge
|
|
||||||
|
|
||||||
Volume ["/app"]
|
ADD requirements.txt /tmp
|
||||||
|
RUN apk add --no-cache build-base && \
|
||||||
|
pip install --no-cache-dir -r /tmp/requirements.txt -i https://pypi.doubanio.com/simple && \
|
||||||
|
apk del build-base --purge
|
||||||
|
|
||||||
|
VOLUME [ "/app" ]
|
||||||
|
|
||||||
CMD sh /app/deploy/run.sh
|
CMD sh /app/deploy/run.sh
|
||||||
|
|||||||
@ -46,7 +46,7 @@ http {
|
|||||||
|
|
||||||
# Timeout for keep-alive connections. Server will close connections after
|
# Timeout for keep-alive connections. Server will close connections after
|
||||||
# this time.
|
# this time.
|
||||||
keepalive_timeout 65;
|
keepalive_timeout 10;
|
||||||
|
|
||||||
# Sendfile copies data between one FD and other from within the kernel,
|
# Sendfile copies data between one FD and other from within the kernel,
|
||||||
# which is more efficient than read() + write().
|
# which is more efficient than read() + write().
|
||||||
@ -89,12 +89,11 @@ http {
|
|||||||
|
|
||||||
# Sets the path, format, and configuration for a buffered log write.
|
# Sets the path, format, and configuration for a buffered log write.
|
||||||
# access_log /var/log/nginx/access.log main;
|
# access_log /var/log/nginx/access.log main;
|
||||||
access_log off
|
access_log off;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80 default_server;
|
listen 80 default_server;
|
||||||
server_name _;
|
server_name _;
|
||||||
keetalive_timeout 5;
|
|
||||||
|
|
||||||
location /static/avatar {
|
location /static/avatar {
|
||||||
expires max;
|
expires max;
|
||||||
|
|||||||
@ -13,3 +13,5 @@ flake8-coding
|
|||||||
requests
|
requests
|
||||||
django-redis
|
django-redis
|
||||||
psycopg2
|
psycopg2
|
||||||
|
gunicorn
|
||||||
|
jsonfield
|
||||||
|
|||||||
@ -12,11 +12,29 @@ fi
|
|||||||
|
|
||||||
cd $BASE
|
cd $BASE
|
||||||
find . -name "*.pyc" -delete
|
find . -name "*.pyc" -delete
|
||||||
|
chown -R nobody:nogroup $BASE/log
|
||||||
|
|
||||||
|
# wait for postgresql start
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
n=0
|
||||||
|
while [ $n -lt 3 ]
|
||||||
|
do
|
||||||
python manage.py migrate
|
python manage.py migrate
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Can't start server"
|
echo "Can't start server, try again in 3 seconds.."
|
||||||
exit 1
|
sleep 3
|
||||||
|
let "n+=1"
|
||||||
|
continue
|
||||||
fi
|
fi
|
||||||
python manage.py initadmin
|
python manage.py initadmin
|
||||||
python manage.py runserver 0.0.0.0:8080
|
break
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $n -eq 3 ]; then
|
||||||
|
echo "Can't start server, please check log file for details."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec supervisord -c /app/deploy/supervisor.conf
|
||||||
|
|||||||
@ -11,7 +11,7 @@ childlogdir=/app/log/
|
|||||||
serverurl=unix:///tmp/supervisor.sock
|
serverurl=unix:///tmp/supervisor.sock
|
||||||
|
|
||||||
[program:gunicorn]
|
[program:gunicorn]
|
||||||
command=gunicorn oj.wsgi --user nobody -b 127.0.0.1:8080 --reload -w `grep -c ^processor /proc/cpuinfo`
|
command=sh -c "gunicorn oj.wsgi --user nobody -b 127.0.0.1:8080 --reload -w `grep -c ^processor /proc/cpuinfo`"
|
||||||
directory=/app/
|
directory=/app/
|
||||||
stdout_logfile=/app/log/gunicorn.log
|
stdout_logfile=/app/log/gunicorn.log
|
||||||
stderr_logfile=/app/log/gunicorn.log
|
stderr_logfile=/app/log/gunicorn.log
|
||||||
@ -21,7 +21,7 @@ startsecs=5
|
|||||||
stopwaitsecs = 5
|
stopwaitsecs = 5
|
||||||
killasgroup=true
|
killasgroup=true
|
||||||
|
|
||||||
[program:task_queue]
|
[program:celery]
|
||||||
command=celery -A oj worker -l warning
|
command=celery -A oj worker -l warning
|
||||||
directory=/app/
|
directory=/app/
|
||||||
user=nobody
|
user=nobody
|
||||||
|
|||||||
@ -26,6 +26,8 @@ ALLOWED_HOSTS = ["*"]
|
|||||||
|
|
||||||
TEST_CASE_DIR = "/tmp"
|
TEST_CASE_DIR = "/tmp"
|
||||||
|
|
||||||
|
LOG_PATH = "/tmp/"
|
||||||
|
|
||||||
STATICFILES_DIRS = [
|
STATICFILES_DIRS = [
|
||||||
os.path.join(BASE_DIR, "static"),
|
os.path.join(BASE_DIR, "static"),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -8,11 +8,11 @@ def get_env(name, default=""):
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
'HOST': get_env("POSTGRESQL_HOST", "postgresql"),
|
'HOST': get_env("POSTGRES_HOST", "postgres"),
|
||||||
'PORT': get_env("POSTGRESQL_PORT", "5433"),
|
'PORT': get_env("POSTGRES_PORT", "5433"),
|
||||||
'NAME': get_env("POSTGRESQL_DBNAME"),
|
'NAME': get_env("POSTGRES_DB"),
|
||||||
'USER': get_env("POSTGRESQL_USER"),
|
'USER': get_env("POSTGRES_USER"),
|
||||||
'PASSWORD': get_env("POSTGRESQL_PASSWORD")
|
'PASSWORD': get_env("POSTGRES_PASSWORD")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,4 +25,5 @@ DEBUG = False
|
|||||||
|
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ['*']
|
||||||
|
|
||||||
TEST_CASE_DIR = "/test_case"
|
TEST_CASE_DIR = "/app/test_case"
|
||||||
|
LOG_PATH = "log/"
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import os
|
|||||||
|
|
||||||
from .custom_settings import *
|
from .custom_settings import *
|
||||||
|
|
||||||
if os.environ.get("NODE_ENV") == "production":
|
if os.environ.get("OJ_ENV") == "production":
|
||||||
from .production_settings import *
|
from .production_settings import *
|
||||||
else:
|
else:
|
||||||
from .dev_settings import *
|
from .dev_settings import *
|
||||||
@ -108,7 +108,6 @@ USE_TZ = True
|
|||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
AUTH_USER_MODEL = 'account.User'
|
AUTH_USER_MODEL = 'account.User'
|
||||||
LOG_PATH = "log/"
|
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
'version': 1,
|
'version': 1,
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.11.3 on 2017-10-01 19:19
|
# Generated by Django 1.11.4 on 2017-10-23 08:11
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import jsonfield.fields
|
import django.contrib.postgres.fields.jsonb
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ class Migration(migrations.Migration):
|
|||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('key', models.CharField(db_index=True, max_length=128, unique=True)),
|
('key', models.CharField(db_index=True, max_length=128, unique=True)),
|
||||||
('value', jsonfield.fields.JSONField()),
|
('value', django.contrib.postgres.fields.jsonb.JSONField()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Generated by Django 1.11.4 on 2017-10-11 12:14
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import django.contrib.postgres.fields.jsonb
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('options', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='sysoptions',
|
|
||||||
name='value',
|
|
||||||
field=django.contrib.postgres.fields.jsonb.JSONField(),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
from account.models import AdminType, ProblemPermission, User, UserProfile
|
from account.models import AdminType, ProblemPermission, User, UserProfile
|
||||||
@ -9,12 +10,11 @@ class Command(BaseCommand):
|
|||||||
try:
|
try:
|
||||||
admin = User.objects.get(username="root")
|
admin = User.objects.get(username="root")
|
||||||
if admin.admin_type == AdminType.SUPER_ADMIN:
|
if admin.admin_type == AdminType.SUPER_ADMIN:
|
||||||
|
if os.environ.get("OJ_ENV") != "production":
|
||||||
self.stdout.write(self.style.WARNING("Super admin user 'root' already exists, "
|
self.stdout.write(self.style.WARNING("Super admin user 'root' already exists, "
|
||||||
"would you like to reset it's password?\n"
|
"would you like to reset it's password?\n"
|
||||||
"Input yes to confirm: "))
|
"Input yes to confirm: "))
|
||||||
if input() == "yes":
|
if input() == "yes":
|
||||||
# todo remove this in product env
|
|
||||||
# rand_password = rand_str(length=6)
|
|
||||||
rand_password = "rootroot"
|
rand_password = "rootroot"
|
||||||
admin.save()
|
admin.save()
|
||||||
self.stdout.write(self.style.SUCCESS("Successfully created super admin user password.\n"
|
self.stdout.write(self.style.SUCCESS("Successfully created super admin user password.\n"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user