Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Baiyuetribe/kamiFaka
Browse files Browse the repository at this point in the history
  • Loading branch information
Baiyuetribe committed Nov 26, 2020
2 parents 2d481f7 + 6200c50 commit 8fde9fd
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
8 changes: 4 additions & 4 deletions Heroku → Heroku.dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM python:3.8-slim
LABEL 维护者="佰阅 [email protected]"

# 备选数据库Sqlite \Mysql
ENV DATABASE_TYPE='Mysql'
# 备选数据库Sqlite \Mysql \ PostgreSQL
ENV DB_TYPE='PostgreSQL'

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
RUN sed -i 's#mysql:\\/\\/${MYSQL_USER}:${MYSQL_PASSWORD}@${MYSQL_HOST}:${MYSQL_PORT}\\/${MYSQL_DATABASE}#$JAWSDB_URL#g' docker-entrypoint.sh && \
sed -i 's/8000/$PORT/g' docker-entrypoint.sh && \
RUN sed -i 's|postgresql+psycopg2://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}|$DATABASE_URL|g' docker-entrypoint.sh && \
sed -i 's|8000|$PORT|g' docker-entrypoint.sh && \
chmod +x docker-entrypoint.sh

EXPOSE $PORT
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"stack": "container",
"addons": [
{
"plan": "jawsdb:kitefin"
"plan": "heroku-postgresql:hobby-dev"
}
]
}
5 changes: 3 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ echo '欢迎使用佰阅发卡(KAMIFAKA)程序'


if [ ${DB_TYPE} = 'Mysql' ];then
sed -i "s/'sqlite:\/\/\/'+os.path.join(SQL_PATH,'kamifaka.db')/'mysql+pymysql:\/\/${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}\/${DB_DATABASE}\?charset=utf8mb4'/g" /usr/src/app/service/api/db.py
sed -i "s|'sqlite:///'+os.path.join(SQL_PATH,'kamifaka.db')|'mysql+pymysql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}\?charset=utf8mb4'|g" /usr/src/app/service/api/db.py
elif [ ${DB_TYPE} = 'PostgreSQL' ];then
sed -i "s/'sqlite:\/\/\/'+os.path.join(SQL_PATH,'kamifaka.db')/'postgresql+psycopg2:\/\/${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}\/${DB_DATABASE}'/g" /usr/src/app/service/api/db.py
sed -i 's|postgresql://|postgresql+psycopg2://|g' /usr/src/app/docker-entrypoint.sh
sed -i "s|'sqlite:///'+os.path.join(SQL_PATH,'kamifaka.db')|'postgresql+psycopg2://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}'|g" /usr/src/app/service/api/db.py
fi

# 处理文件夹
Expand Down
2 changes: 1 addition & 1 deletion heroku.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
build:
docker:
web: Heroku
web: Heroku.dockerfile
12 changes: 6 additions & 6 deletions pwd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ services:
image: baiyuetribe/kamifaka
restart: always
environment:
DATABASE_TYPE: Sqlite
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
MYSQL_USER: root
MYSQL_PASSWORD: password
MYSQL_DATABASE: kamifaka
DB_TYPE: Sqlite
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: password
DB_DATABASE: kamifaka
# volumes:
# - /opt/kamifaka:/usr/src/app/public
ports:
Expand Down
26 changes: 13 additions & 13 deletions 正式环境搭建教程.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ docker run -d \
-p 8000:8000 \
--restart=always \
--name=kmfaka \
-e DATABASE_TYPE=Mysql \
-e MYSQL_HOST=数据库ip地址或容器地址"172.17.0.1" \
-e MYSQL_PORT=数据库端口 \
-e MYSQL_USER=数据库用户名 \
-e MYSQL_PASSWORD=数据库用密码 \
-e MYSQL_DATABASE=数据库名 \
-e DB_TYPE=Mysql \
-e DB_HOST=数据库ip地址或容器地址"172.17.0.1" \
-e DB_PORT=数据库端口 \
-e DB_USER=数据库用户名 \
-e DB_PASSWORD=数据库用密码 \
-e DB_DATABASE=数据库名 \
-v /opt/kamifaka:/usr/src/app/public \
baiyuetribe/kamifaka
```
Expand All @@ -64,19 +64,19 @@ docker run -d \
-p 8000:8000 \
--restart=always \
--name=kmfaka \
-e DATABASE_TYPE=Mysql \
-e MYSQL_HOST="172.17.0.1" \
-e MYSQL_PORT=3306 \
-e MYSQL_USER=faka \
-e MYSQL_PASSWORD=GxJn7ZPHwYrE366j \
-e MYSQL_DATABASE=faka \
-e DB_TYPE=Mysql \
-e DB_HOST="172.17.0.1" \
-e DB_PORT=3306 \
-e DB_USER=faka \
-e DB_PASSWORD=GxJn7ZPHwYrE366j \
-e DB_DATABASE=faka \
-v /opt/kamifaka:/usr/src/app/public \
baiyuetribe/kamifaka
```
完整复制并粘贴到终端回车即可执行完毕。
然后通过ip地址加上端口号8000即可访问,后台加上`/admin`,默认管理员账号`[email protected]`,密码:`123456`

备注:上述内容,根据`DATABASE_TYPE`指定数据库类型为Mysql,然后添加相关的数据库信息。
备注:上述内容,根据`DB_TYPE`指定数据库类型为Mysql,然后添加相关的数据库信息。

### 方法3:Heroku 无服务器部署

Expand Down

0 comments on commit 8fde9fd

Please sign in to comment.