simple docker compose setup with Caddy
This commit is contained in:
		
							
								
								
									
										5
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					/caddy/config
 | 
				
			||||||
 | 
					/caddy/data
 | 
				
			||||||
 | 
					/caddy/static/
 | 
				
			||||||
 | 
					/postgres
 | 
				
			||||||
 | 
					/pgadmin
 | 
				
			||||||
							
								
								
									
										19
									
								
								caddy/Caddyfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								caddy/Caddyfile
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
						email user@gmail.com
 | 
				
			||||||
 | 
						servers {
 | 
				
			||||||
 | 
							metrics
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					blog.site.com {
 | 
				
			||||||
 | 
						root * /static
 | 
				
			||||||
 | 
						encode zstd gzip
 | 
				
			||||||
 | 
						file_server
 | 
				
			||||||
 | 
						log
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					git.site.com {
 | 
				
			||||||
 | 
						reverse_proxy gitea:3000
 | 
				
			||||||
 | 
						encode zstd gzip
 | 
				
			||||||
 | 
						log
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										46
									
								
								docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					services:
 | 
				
			||||||
 | 
					  ###
 | 
				
			||||||
 | 
					  # PUBLIC WEB SERVICES
 | 
				
			||||||
 | 
					  ###
 | 
				
			||||||
 | 
					  caddy: # https://github.com/caddyserver/caddy/releases
 | 
				
			||||||
 | 
					    image: caddy:2.8.4
 | 
				
			||||||
 | 
					    ports:
 | 
				
			||||||
 | 
					      - "80:80"
 | 
				
			||||||
 | 
					      - "443:443"
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - ./caddy/data:/data
 | 
				
			||||||
 | 
					      - ./caddy/config:/config
 | 
				
			||||||
 | 
					      - ./caddy:/etc/caddy
 | 
				
			||||||
 | 
					      - ./caddy/static:/static
 | 
				
			||||||
 | 
					    restart: always
 | 
				
			||||||
 | 
					  gitea: # https://github.com/go-gitea/gitea/releases
 | 
				
			||||||
 | 
					    image: gitea/gitea:1.22.1
 | 
				
			||||||
 | 
					    environment:
 | 
				
			||||||
 | 
					      - USER_UID=113
 | 
				
			||||||
 | 
					      - USER_GID=119
 | 
				
			||||||
 | 
					    ports:
 | 
				
			||||||
 | 
					      - "127.0.0.1:2222:22"
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - /home/git/gitea/data:/data
 | 
				
			||||||
 | 
					      - /etc/timezone:/etc/timezone:ro
 | 
				
			||||||
 | 
					      - /etc/localtime:/etc/localtime:ro
 | 
				
			||||||
 | 
					    restart: always
 | 
				
			||||||
 | 
					  postgres:
 | 
				
			||||||
 | 
					    image: postgres:15.7-alpine
 | 
				
			||||||
 | 
					    restart: always
 | 
				
			||||||
 | 
					    user: 1000:1000
 | 
				
			||||||
 | 
					    environment:
 | 
				
			||||||
 | 
					      - POSTGRES_USER=postgres
 | 
				
			||||||
 | 
					      - POSTGRES_PASSWORD=<password>
 | 
				
			||||||
 | 
					      - POSTGRES_DB=postgres
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - ./postgres/data:/var/lib/postgresql/data
 | 
				
			||||||
 | 
					      - /etc/passwd:/etc/passwd:ro
 | 
				
			||||||
 | 
					  pgadmin:
 | 
				
			||||||
 | 
					    image: dpage/pgadmin4:8.10
 | 
				
			||||||
 | 
					    restart: always
 | 
				
			||||||
 | 
					    environment:
 | 
				
			||||||
 | 
					      - PGADMIN_DEFAULT_EMAIL=admin@site.com
 | 
				
			||||||
 | 
					      - PGADMIN_DEFAULT_PASSWORD=<password>
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - ./pgadmin:/var/lib/pgadmin
 | 
				
			||||||
							
								
								
									
										29
									
								
								readme.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								readme.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					# setting up the server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
 | 
				
			||||||
 | 
					curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
 | 
				
			||||||
 | 
					sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
 | 
				
			||||||
 | 
					sudo apt update
 | 
				
			||||||
 | 
					sudo apt install docker-ce docker-ce-cli docker-compose containerd.io
 | 
				
			||||||
 | 
					sudo docker run hello-world
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					create git user for gitea:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
 | 
				
			||||||
 | 
					id git
 | 
				
			||||||
 | 
					sudo touch /usr/local/bin/gitea
 | 
				
			||||||
 | 
					sudo chmod +x /usr/local/bin/gitea
 | 
				
			||||||
 | 
					sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key"
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					gitea runs as the `git` user; the files are in `/home/git/gitea/data`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`/usr/local/bin/gitea` contents:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```sh
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					ssh -p 2222 -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@"
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
							
								
								
									
										8
									
								
								static/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								static/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					<html>
 | 
				
			||||||
 | 
					  <head>
 | 
				
			||||||
 | 
					    <title>Hello World</title>
 | 
				
			||||||
 | 
					  </head>
 | 
				
			||||||
 | 
					  <body>
 | 
				
			||||||
 | 
					    <h1>Hello from Caddy!</h1>
 | 
				
			||||||
 | 
					  </body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user