Skip to content

Commit 095d10b

Browse files
committed
Feat: Build web preview with Docker and Docker Compose
1 parent c63fb8a commit 095d10b

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

.github/workflows/markdown-to-html.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
pandoc docs/aoa.md -o docs/index.html
1919
- name: Commit and push changes
2020
run: |
21-
git config --local user.name "許景企鵝"
22-
git config --local user.email "[email protected]"
21+
git config --local user.name "kevinlee-06"
22+
git config --local user.email "[email protected]"
2323
git add docs/index.html
24-
git commit -m "景夾已從 /docs/aoa.md 構建新的 /docs/index.html" || echo "景夾表示沒有改變"
24+
git commit -m "已從 /docs/aoa.md 構建新的 /docs/index.html" || echo "沒有改變"
2525
git push
2626
env:
2727
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.9-slim
2+
WORKDIR /var/www/html
3+
RUN apt update
4+
RUN apt install -y pandoc tree
5+
RUN pip install Flask
6+
COPY docs .
7+
COPY assets ./assets
8+
COPY build .
9+
RUN pandoc aoa.md -o index.html
10+
EXPOSE 5000
11+
RUN tree .
12+
CMD ["python", "app.py"]

build/app.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from flask import Flask, send_from_directory
2+
3+
app = Flask(__name__)
4+
5+
@app.route('/')
6+
def serve_index():
7+
return send_from_directory('.', 'index.html')
8+
9+
@app.route('/assets/<path:filename>')
10+
def serve_assets(filename):
11+
return send_from_directory('assets', filename)
12+
13+
if __name__ == '__main__':
14+
app.run(host='0.0.0.0', port=5000)
15+

compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
aoa-preview:
3+
build: .
4+
ports:
5+
- "5000:5000"
6+

0 commit comments

Comments
 (0)