Skip to content

Commit

Permalink
Merge pull request #9 from NTUT-NPC/docker-compose
Browse files Browse the repository at this point in the history
Build web preview with Docker, Docker Compose, and add README.md
  • Loading branch information
kevinlee-06 authored Dec 17, 2024
2 parents 295673d + 7a6fcc5 commit f64ff8b
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 7 deletions.
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.9-slim
RUN apt update
RUN apt install -y pandoc
RUN pip install Flask
WORKDIR /var/www/html
COPY docs .
COPY build .
RUN pandoc aoa.md -o index.html
EXPOSE 5000
CMD ["python", "app.py"]
97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Contributing

The document [`docs/aoa.md`](docs/aoa.md) serves as the Articles of Association for our club. All members are encouraged to contribute by making updates or suggestions to the [`docs/aoa.md`](docs/aoa.md) file.

If you would like to contribute, please follow these steps:

1. **Fork the Repository**: Click the "Fork" button at the top right of the repository page to create your own copy of the repository.

2. **Make Changes**: Edit the [`docs/aoa.md`](docs/aoa.md) file to propose changes or updates to the Articles of Association.

3. **Submit a Pull Request**: Once you have made your changes, submit a pull request to the main repository. Please include a brief description of the changes you made and the reasons for them.

> Alternatively, if you have suggestions or issues that you would like to discuss without making direct changes, feel free to open an issue in the repository. Your feedback is valuable and helps ensure that our Articles of Association remain accurate and up-to-date!


# Web Preview with Docker and Docker Compose

This project sets up a Flask web application that serves an HTML preview generated from a Markdown file. The application is containerized using Docker and orchestrated with Docker Compose.

## Project Structure

```
.
├── assets
│ ├── edukai-5.0.ttf
│ └── Iansui-Regular.ttf
├── build
│ └── app.py
├── compose.yml
├── Dockerfile
├── docs
│ ├── aoa.md
│ ├── CNAME
│ └── index.html
├── licenses
│ ├── OFL.txt
│ └── README.md
└── README.md
```

## Prerequisites

Before you begin, ensure you have the following installed on your machine:

- [Docker](https://www.docker.com/get-started) (version 20.10 or later)
- [Docker Compose](https://docs.docker.com/compose/install/) (version 1.27 or later)

## Setup

1. **Clone the repository**:

```bash
git clone [email protected]:NTUT-NPC/AoA.git
cd AoA
```

2. **Build and start the application**:

Use Docker Compose to build the image and start the container:

```bash
docker compose up
```

This command will build the Docker image defined in the `Dockerfile` and start the Flask application.

## Preview the Changes

Once the application is running, you can preview the changes by opening your web browser and navigating to:

http://127.0.0.1:5000

You should see the HTML content generated from the `aoa.md` Markdown file.

### Get the HTML Source

To download the HTML source of the generated page, you can use the following command:

```bash
wget http://127.0.0.1:5000/index.html
```

This command will save the `index.html` file to your current directory.

## Stopping the Application

To stop the application, you can press `Ctrl+C` in the terminal where Docker Compose is running.

## License

Please see [licenses](https://github.com/NTUT-NPC/AoA/tree/main/licenses).

## Acknowledgments

- [Flask](https://flask.palletsprojects.com/) for the web framework.
- [Pandoc](https://pandoc.org/) for converting Markdown to HTML.
11 changes: 11 additions & 0 deletions build/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from flask import Flask, send_from_directory

app = Flask(__name__)

@app.route('/')
def serve_index():
return send_from_directory('.', 'index.html')

if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)

6 changes: 6 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
aoa-preview:
build: .
ports:
- "5000:5000"

7 changes: 1 addition & 6 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,9 @@ <h3 id="壹拾-附則">壹拾、 附則</h3>
列印
</button>
<style>
/* @font-face {
font-family: 'iansui';
src: url('../assets/Iansui-Regular.ttf') format('truetype')
} */

@font-face {
font-family: 'edukai';
src: url('../assets/edukai-5.0.ttf') format('truetype')
src: url('https://github.com/NTUT-NPC/AoA/raw/refs/heads/main/assets/edukai-5.0.ttf') format('truetype')
}

@media print {
Expand Down

0 comments on commit f64ff8b

Please sign in to comment.