static-sites/bases/do-blog/resources/documents/project-hosting-setup.org

2.1 KiB

Project hosting setup

Quick and simple code hosting and CI on a local rasobery pi or in the cloud I use a cheap digitalocen droplet, if you decide to sign up and do the same please use this link and help me out. https://m.do.co/c/f05b87f9fec9

First create a docker-compose.yml file, you will need to specify some config in a separate env file. This compose file brings up caddy as a http server and postgres as the database to persist your data.

It then uses drone ci linked with gitea for code hosting and continuous integration.

version: '2'

volumes:
  sockets:
    driver: local
  postgres_data:
    driver: local
  postgres_backup:
    driver: local

services:
  caddy:
    image: caddy
    volumes:
      - /var/www:/var/www
      - /var/www/project-hosting-setup/data/caddy/:/data
      - /var/www/project-hosting-setup/Caddyfile:/etc/caddy/Caddyfile
      - sockets:/data/sockets
    ports:
      - "80:80"
      - "443:443"

  postgres:
    image: postgres:9.6
    mem_limit: 256m
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - postgres_backup:/backups
    env_file: .env

  gitea:
    image: gitea/gitea:1.18.3
    depends_on:
      - postgres
    ports:
      - "10022:22"
    volumes:
      - ./data/gitea:/data
    restart: always

  drone-server:
    image: drone/drone:2.16
    volumes:
      - /root/.docker/config.json:/root/.docker/config.json
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data/dronenew:/var/lib/drone/
    depends_on:
      - gitea
    env_file: .env

Create a Caddyfile which will reverse proxy through to your git and ci containers.

ci.mydomain.com:443 {
  reverse_proxy * drone-server:80
}

git.mydomain.com:443 {
  reverse_proxy * gitea:3000
}

https://caddy.community/t/serving-tens-of-thousands-of-domains-over-https-with-caddy/11179

Finally create a .env file to store your configuration