Code Monkey home page Code Monkey logo

static_website's Introduction

Portfolio & Posts

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.

How to run the project

Locally

$ 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

Production - with traefik 1.7

$ 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.

Project Structure

.
├── 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

blog

Mounted from where the posts are created and stored. In production, this is my nextcloud instance.

dist

Auto-generated, static files. Generated by site-generator.py from the files in static, templates and blog.

docker-compose.yml

Compose file for production deployment. Contains two services:

  1. Builder: Runs the site_generator.py. Takes all the published posts, static files and templates and builds the dist content.
  2. 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

  • 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.

prototype.ipynb

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.

site_generatory.py

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.

static_website's People

Contributors

simongavris avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.