mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-28 08:02:11 +00:00
增加数据库初始化脚本
This commit is contained in:
parent
f2f6b48d69
commit
efddadb898
1
.gitignore
vendored
1
.gitignore
vendored
@ -76,3 +76,4 @@ data/config/*
|
|||||||
http_locations.conf
|
http_locations.conf
|
||||||
https_locations.conf
|
https_locations.conf
|
||||||
|
|
||||||
|
venv/
|
||||||
|
@ -2,15 +2,11 @@ language: python
|
|||||||
python:
|
python:
|
||||||
- "3.6"
|
- "3.6"
|
||||||
services:
|
services:
|
||||||
- redis-server
|
|
||||||
- docker
|
- docker
|
||||||
before_install:
|
|
||||||
- docker pull postgres:10
|
|
||||||
- docker run -it -d -e POSTGRES_DB=onlinejudge -e POSTGRES_USER=onlinejudge -e POSTGRES_PASSWORD=onlinejudge -p 127.0.0.1:5433:5432 postgres:10
|
|
||||||
install:
|
install:
|
||||||
- pip install -r deploy/requirements.txt
|
- pip install -r deploy/requirements.txt
|
||||||
- echo `cat /dev/urandom | head -1 | md5sum | head -c 32` > data/config/secret.key
|
- echo `cat /dev/urandom | head -1 | md5sum | head -c 32` > data/config/secret.key
|
||||||
- sleep 10 && python manage.py migrate
|
- ./init_db.sh
|
||||||
script:
|
script:
|
||||||
- docker ps -a
|
- docker ps -a
|
||||||
- flake8 .
|
- flake8 .
|
||||||
|
19
init_db.sh
Executable file
19
init_db.sh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
set -x
|
||||||
|
|
||||||
|
if [[ ! -f manage.py ]]; then
|
||||||
|
echo "No manage.py, wrong location"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 2
|
||||||
|
docker rm -f oj-postgres-dev oj-redis-dev
|
||||||
|
docker run -it -d -e POSTGRES_DB=onlinejudge -e POSTGRES_USER=onlinejudge -e POSTGRES_PASSWORD=onlinejudge -p 127.0.0.1:5435:5432 --name oj-postgres-dev postgres:10
|
||||||
|
docker run -it -d -p 127.0.0.1:6380:6379 --name oj-redis-dev redis:4.0-alpine
|
||||||
|
|
||||||
|
if [ "$1" = "--migrate" ]; then
|
||||||
|
sleep 3
|
||||||
|
echo `cat /dev/urandom | head -1 | md5sum | head -c 32` > data/config/secret.key
|
||||||
|
python manage.py migrate
|
||||||
|
python manage.py inituser --username root --password rootroot --action create_super_admin
|
||||||
|
fi
|
@ -7,7 +7,7 @@ DATABASES = {
|
|||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
'HOST': '127.0.0.1',
|
'HOST': '127.0.0.1',
|
||||||
'PORT': 5433,
|
'PORT': 5435,
|
||||||
'NAME': "onlinejudge",
|
'NAME': "onlinejudge",
|
||||||
'USER': "onlinejudge",
|
'USER': "onlinejudge",
|
||||||
'PASSWORD': 'onlinejudge'
|
'PASSWORD': 'onlinejudge'
|
||||||
@ -16,7 +16,7 @@ DATABASES = {
|
|||||||
|
|
||||||
REDIS_CONF = {
|
REDIS_CONF = {
|
||||||
"host": "127.0.0.1",
|
"host": "127.0.0.1",
|
||||||
"port": "6379"
|
"port": "6380"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user