s464979-hetzner/gitea_cloud_init.yml

58 lines
2.0 KiB
YAML
Raw Normal View History

2024-11-20 18:09:07 +01:00
#cloud-config
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
write_files:
- path: /root/docker-compose.yml
content: |
version: "3.9"
services:
server:
image: gitea/gitea:latest
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- GITEA__database__DB_TYPE=mysql
- GITEA__database__HOST="10.10.10.2:3306"
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=gitea
restart: always
volumes:
2024-11-20 19:11:39 +01:00
- /mnt/VOLUME_NAME/data:/var/lib/gitea
- /mnt/VOLUME_NAME/config:/etc/gitea
2024-11-20 18:09:07 +01:00
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
runcmd:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
- add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- apt-get update -y
- apt-get install -y docker-ce docker-ce-cli containerd.io
- curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- systemctl start docker
- systemctl enable docker
2024-11-20 19:11:39 +01:00
- sudo mkfs.ext4 -F /dev/disk/by-id/scsi-0HC_Volume_{volume.volume.id}
- mkdir /mnt/{volume_name}
- mount -o discard,defaults /dev/disk/by-id/scsi-0HC_Volume_{volume.volume.id} /mnt/{volume_name}
- echo "/dev/disk/by-id/scsi-0HC_Volume_{volume.volume.id} /mnt/{volume_name} ext4 discard,nofail,defaults 0 0" >> /etc/fstab
- mkdir /mnt/{volume_name}/data
- mkdir /mnt/{volume_name}/config
- sudo chown 1000:1000 /mnt/{volume_name}/config/ /mnt/{volume_name}/data
2024-11-20 18:09:07 +01:00
- cd /root/ && docker-compose up -d