This project is for for my private portfolio and posts webpage. The idea was to have a pure HTML+CSS (no JS) website build periodically from a bunch of markdown files and static html files.
$ docker build -t pure_cms -f Dockerfile.local --target=deploy .
$ docker run -p 8080:80 pure_cms
Builds the Dockerfile ment for local development deployment. Exposes port 80 onto the local port 8080. You can access the site via http://localhost:8080
$ docker-compose up -d
Builds the images from the two Dockerfiles (.build & .deploy). Makes sure the website service is in the external traefik network (called "proxy"). The website is then reachable with https://simon.gavris.dev.
I purposely decided against a multi-stage Dockerfile, because I want the build service to be triggered every 2 minutes or at least daily. This way, new blog-posts get automatically parsed and the website gets rebuild.
Rebuild is currently set to every 2 minutes which is probably way to often but doesn't take much resources anways.
.
├── blog
├── <date>_<title>.md
│ └── publish
│ ├── <date_<title>.md
│ └── <date>_<post_with_picture>
│ ├── <date>_<title>.md
│ └── <picture>.png
├── dist
│ └── <autogenerated_files>
├── docker-compose.yml
├── Dockerfile.build
├── Dockerfile.deploy
├── Dockerfile.local
├── nginx
│ └── nginx.conf
├── prototype.ipynb
├── README.md
├── requirements.txt
├── site_generator.py
├── static
│ ├── about.html
│ ├── favicon.ico
│ ├── index.html
│ ├── profile.png
│ └── style.css
└── templates
├── post.html.j2
└── posts.html.j2
Mounted from where the posts are created and stored. In production, this is my nextcloud instance.
Auto-generated, static files. Generated by site-generator.py from the files in static, templates and blog.
Compose file for production deployment. Contains two services:
- Builder: Runs the site_generator.py. Takes all the published posts, static files and templates and builds the dist content.
- Website: Nginx service that publishes all the files and takes care of the correct routing. Exposed to proxy/public.
For TLS certification and correct proxying, the website service is in the external proxy network. Proxing and certification is done via traefik, hence the traefik lables.
- Dockerfile.build: Dockerfile for the builder service (see docker-compose.yml)
- Dockerfile.deploy: Dockerfile for the website service (see docker-compose.yml)
- Dockerfile.local: For running the stack locally, otherwise the routings won't work and its hard to debug locally.
This is where i started prototyping the python script, since the process of generating the files was new to me. I kept it for now but might delete it in the future.
Takes the markdown files from blog and parses them to html with the template in templates. Dynamically builds the posts (post overview page). Copies all gneerated and static files to dist. Makes sure dist is empty before all of this operations.