Self-hosted static website using Docker

Since I was already migrating all projects running on my server into Docker containers, of course my private homepage needed to be migrated as well. This homepage is just a very basic static HTML page. This makes it rather easy to create a Docker container for it.┬áSo what I’m in the end just doing, is using a plain nginx image and injecting my homepage source code into the appropriate folder (/var/www/html).

I’m hosting my homepage source code on my private GitLab instance, which I clone into the same folder, where my docker-compose.yml is located. By defining the path to this cloned repository as a Docker volume mounted to /var/www/html, the configured nginx shows my homepage by default.

Apart from that, I added a nginx.conf file, mostly specifying nginx’ root folder and the server name.

worker_processes 1;

events { worker_connections 1024; }

http {
  server {
    root /var/www/html;
    server_name localhost;
version: "3"

    external: true
    external: false

    image: nginx:1.15.2
    restart: always
    hostname: ''
      - ./public_html:/var/www/html # the cloned repository
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - traefik.enable=true
      - internal
      - proxy
Leave a Reply

Your email address will not be published. Required fields are marked *