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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
worker_processes 1;

events { worker_connections 1024; }

http {
  server {
    root /var/www/html;
    server_name localhost domain.net www.domain.net;
  }
}

docker-compose.yml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
version: "3"
networks:
  proxy:
    external: true
  internal:
    external: false
services:
  homepage:
    image: nginx:1.15.2
    restart: always
    hostname: 'domain.net'
    volumes:
      - ./public_html:/var/www/html # the cloned repository
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    labels:
      - traefik.enable=true
      - traefik.backend=domain.net
      - traefik.admin.frontend.rule=Host:domain.net
      - traefik.docker.network=proxy
    networks:
      - internal
      - proxy