This repository has been archived by the owner on Apr 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Dockerfile and docker-compose.yml * Fix flask import error * Fix redis error and flask autodoc import * Update feature news get content * Fix bus and user info error Remove: login limit Add: bus data is None judgement * Add login limit * Add SSL setting * Update host to nkust host * Fix kuas to nkust * Fix error text * Fix python error * Update for return is login * Fix image path to nkust * Add gunicorn and caddy Add: fake ssl cert * Update redis cookies rules Update: caddy settings docker-compose.yml * Reset gunicorn settings Fix: nkust image path * Fix docker-compose error * Fix ssl port error * Update redis setting * Update feature get user info * Update deploy config * Update docker-compose.yml Remove: docker-compose useless config Update: docker-hub source for web image * Fix http router error and update deploy config * Update README.md * Update README.md * Fix get_semester_list error * fix get_semester_list and use redis. * fix import error in ap.py. * fix leave login issues * Fix leave approved >= 2 * Update README.md and docker-compose.yml * Update README.md
- Loading branch information
Showing
26 changed files
with
374 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,3 +226,9 @@ test_page.html | |
html/ | ||
src/config.py | ||
src/gunicorn_cfg.py | ||
|
||
\.vscode/ | ||
|
||
\.idea/ | ||
caddy/Caddyfile | ||
\.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Base image | ||
FROM python:3.6 | ||
# Create app directory | ||
RUN mkdir -p /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
COPY . /usr/src/app | ||
|
||
RUN pip3 install -r ./requirements.txt | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y nodejs | ||
|
||
WORKDIR /usr/src/app/src |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,89 @@ | ||
[![Build Status](https://travis-ci.org/kuastw/AP-API.svg?branch=master)](https://travis-ci.org/kuastw/AP-API) | ||
[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/) | ||
|
||
KUAS - API | ||
NKUST - API | ||
========== | ||
|
||
高雄應用科技大學 API Server | ||
KUAS API Server | ||
高雄科技大學 API Server NKUST API Server | ||
--------------------------- | ||
Requirement | ||
--- | ||
- Ubuntu (18.04 or previous version) | ||
- Python 3.6 | ||
- Redis server | ||
- NodeJS (if host by python venv) | ||
|
||
How to use? | ||
--- | ||
### Clone project | ||
``` | ||
$ git clone https://github.com/kuastw/AP-API | ||
$ git clone https://github.com/NKUST-ITC/AP-API | ||
$ cd AP-API | ||
``` | ||
By python venv | ||
--- | ||
``` | ||
$ python -m venv venv | ||
$ source venv/bin/activate | ||
$ pip install -r requirement.txt | ||
$ pip install -r requirements.txt | ||
$ redis-server & | ||
$ python src/web-server.py | ||
``` | ||
By docker | ||
--- | ||
Requirement | ||
* Redis instance running on localhost | ||
|
||
Need to add environment variable **-e REDIS_URL=redis://127.0.0.1:6379/0** | ||
|
||
or by export | ||
|
||
``` | ||
$ export REDIS_URL=redis://127.0.0.1:6379/0 | ||
``` | ||
|
||
And let docker run host network need add **--network="host"** | ||
|
||
Otherwise redis config by docker network(see docker-compose.yml config) | ||
|
||
Arguments **gunicorn_cfg.py web-server:app** is production flask uWSGI | ||
``` | ||
$ sudo docker run --network="host" nkustitc/ap-api:latest gunicorn -c gunicorn_cfg.py web-server:app | ||
``` | ||
or replace by **python3 web-server.py** | ||
``` | ||
$ sudo docker run --network="host" nkustitc/ap-api:latest python3 web-server.py | ||
``` | ||
By docker-compose | ||
--- | ||
Copy .env example | ||
- CADDY_HOST_HTTPS_PORT -> caddy https host port | ||
- REDIS_URL -> python request redis url | ||
``` | ||
$ cp env.example .env | ||
``` | ||
Copy caddy host config example | ||
``` | ||
$ cd caddy | ||
$ cp Caddyfile.example Caddyfile | ||
``` | ||
Edit **Caddyfile**'s host config**(Production)** | ||
- line 1 **0.0.0.0:2087** replace by you want host domain and port | ||
``` | ||
0.0.0.0:2087 { | ||
proxy / https://web:14769 { | ||
transparent | ||
insecure_skip_verify | ||
} | ||
gzip | ||
tls [email protected] | ||
} | ||
``` | ||
start docker-compose (if need re download package, can add **--build** build by Dockerfile) | ||
``` | ||
$ sudo docker-compose up | ||
``` | ||
--- | ||
Fixed APIBlueprint | ||
--- | ||
You must fixed manually about flask_apiblueprint | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
0.0.0.0:2087 { | ||
proxy / https://web:14769 { | ||
transparent | ||
insecure_skip_verify | ||
} | ||
gzip | ||
tls [email protected] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
version: '3.6' | ||
services: | ||
web: | ||
image: "nkustitc/ap-api:latest" | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
volumes: | ||
- .:/usr/src/app | ||
ports: | ||
- "2087":2087" | ||
environment: | ||
- REDIS_URL=${REDIS_URL} | ||
command: [ "gunicorn","-c","gunicorn_cfg.py","web-server:app"] | ||
networks: | ||
- redis-net | ||
- front-end | ||
depends_on: | ||
- redis | ||
redis: | ||
image: "redis:alpine" | ||
volumes: | ||
- redis-data:/data | ||
networks: | ||
- redis-net | ||
caddy: | ||
image: "abiosoft/caddy:latest" | ||
volumes: | ||
- ./caddy/Caddyfile:/etc/Caddyfile | ||
- ./caddy/path:/root/.caddy | ||
ports: | ||
- "2015:2015" | ||
- "80:80" | ||
- "443:443" | ||
- "${CADDY_HOST_HTTPS_PORT}:2087" | ||
environment: | ||
- ACME_AGREE=true | ||
depends_on: | ||
- web | ||
networks: | ||
- front-end | ||
networks: | ||
redis-net: | ||
front-end: | ||
volumes: | ||
redis-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CADDY_HOST_HTTPS_PORT=2087 | ||
|
||
REDIS_URL=redis://redis:6379/0 | ||
# if use docker => redis://redis:6379/0 | ||
# else => redis://localhost:6379/0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIEUjCCArqgAwIBAgIQKIdZXn4Uzzcwr6Wwj3SPMDANBgkqhkiG9w0BAQsFADB/ | ||
MR4wHAYDVQQKExVta2NlcnQgZGV2ZWxvcG1lbnQgQ0ExKjAoBgNVBAsMIXJhaW52 | ||
aXNpdG9yQFJheS1NYWNCb29rLVByby5sb2NhbDExMC8GA1UEAwwobWtjZXJ0IHJh | ||
aW52aXNpdG9yQFJheS1NYWNCb29rLVByby5sb2NhbDAeFw0xOTAyMDUwOTE2MTha | ||
Fw0yOTAyMDUwOTE2MThaMFcxJzAlBgNVBAoTHm1rY2VydCBkZXZlbG9wbWVudCBj | ||
ZXJ0aWZpY2F0ZTEsMCoGA1UECwwjcmFpbnZpc2l0b3JAUmF5LU1hY0Jvb2stUHJ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NOHTfV+IHYIMSFymGDrJh9ge6McsUvP3 | ||
w8Jy8j30guFmgTA0Q3I2ohLe8uPhN0Fk9sSrV+I/sEYcIbQkrr2Z0bNOfISPl5fs | ||
xgKfEVpC | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC036vGvUvo4sDP | ||
KmbPogPpEAlZm3wBrxqNpLmpwzLUpdLcNNQc76hJdIA0vQr3PTwrtJNKHSwk2glg | ||
NNCvOPm2tkoTQ0nFUQftamcec5WFpEh9fIeSCQYp148ppCbrKFZzHjiaw5nvKNi4 | ||
9nFvGl9lpiHaCpiX/EEblS1RVDFbfgR+i74YlKEm/+hgtYExuoBLpNY5wmM3qe7o | ||
c0+H3qNH1YTIU33nF/w5IZy+3n+2oQ9CouO/I3sWVcBldRwaJm79QYcyPP8Rubr/ | ||
HfZXFmOh2FH4iPzjED8o+RZpJlWj5GV/nh9JbrS1ty7Nrm8rWRaPPcP0SUEp3J5v | ||
jH220FZ9AgMBAAECggEAVv28gDlK6Rcl5H1gNTyW5ODxnkdJvQWan8U6Bov7Ror6 | ||
fy5pVgFtzuZZQwQo4gBxkBOpQ1wEfzTejYbZV2zvrRC/T8RtFpmCVo12Sw8MOtpo | ||
gvIBwhrU/ArQsBZjIXalHXjLgKPSxVO/6DWfGPB2MU1Vuqid+3s3VSzKPvNfScDj | ||
Go64l1FiVD0rMOw4jVcjMNVOSB/HVfaaexHX+CeHaZ9cKHkGxxDUscBbJieKp2nc | ||
dz4pFDZBsVVQx/jn1uF8p5FqLweJw5yMhVXovYZfQd/06ImDppTzHn/JUoadmMy+ | ||
U3eZOERIIm6tSw0kOWNuUTrPOth8ezRxuOiPG5DPgQKBgQDcuacCnPmy++7mYVLv | ||
iH9q+AnMB4LfFjqpxW0nnESeyJtwIL1y6+vCx4WdsBLU5ia7mt3fWpCiIg9ZCzXP | ||
YFyA+VGjm6SNkuxjrMIUD+crMpAJqUL23HcBUqPDUhXBRrhNiTpGOhOzn6sH0IaM | ||
XgPKZA/B+07TUgMAoCpap+1Y1wKBgQDRx5uLnMqLGerOruLhwxfc3Sch3i/L8iZd | ||
bHmn+BSxczdvS6t9mHq/h8onSgfTwcHEcTwMTO2iUFojioJ8KLCPmUOxKhLp/2aM | ||
2HJheHFCw37vnYQKUDXAaICqAeIvybnPcvaWZal9heDhpZ1+8rJHUpwzb/L2Y8xB | ||
spTAheu8ywKBgQCTgK2PHX/wkFOyOU/HKxybS26gnlRi6OQDGCA93DwvMDhP0lFI | ||
P0iqPdOY8VVkWPmBXZjv7gHBl6lSBB/NmcO3nOVlxFlPEuROJ+D6rzX4tC11h1ts | ||
xR/yDlvJ500KgEwh5JbA34bS/ty4uC1yGFHIKt4s79hZd/DxthcXxijiuQKBgH35 | ||
CswE5JAxiRKCbNY7rInB+CzbWwJysF0rtcaLMAn7cU+RNjMerJ91cIy1ZQvhb3WC | ||
theA3ra439g15fOfD5+73q114ZPI/hEYLV+gzwrTkNddVJxI3G5lktYEeYpO7hjI | ||
JZHdDLHHAmseY/yGy04PKqOs107kURUmozMVeKGPAoGAS+jcQ8cTUZDEH4L11SY2 | ||
Md5jmA7NMkPsz0Iz1xr6yDLMl4tc0NDLDcMp1P7ctZJlEV9gU88cKMhMfXxOJ+U7 | ||
1PBJJa5tRsYVzgXcbQX56Hmbte6PbQpWcmQ5Cu1ZP8kdmNL/QNmHxHNkWDto73NC | ||
WHz8l7Z0xZnmpZO6amvlIrM= | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.