diff --git a/gitea_cloud_init.yml b/gitea_cloud_init.yml index 5ffbd83..8e1a9b9 100644 --- a/gitea_cloud_init.yml +++ b/gitea_cloud_init.yml @@ -30,7 +30,8 @@ write_files: restart: always volumes: - - ./gitea:/data + - /mnt/VOLUME_NAME/data:/var/lib/gitea + - /mnt/VOLUME_NAME/config:/etc/gitea - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro @@ -47,4 +48,11 @@ runcmd: - chmod +x /usr/local/bin/docker-compose - systemctl start docker - systemctl enable docker + - 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 - cd /root/ && docker-compose up -d \ No newline at end of file diff --git a/gitea_config.py b/gitea_config.py index 32ed60f..eb1cfd2 100644 --- a/gitea_config.py +++ b/gitea_config.py @@ -43,16 +43,29 @@ print(f"Serwer: {db_server.data_model.name}\n\tpubliczne IP: {db_server.data_mod +volume_name = f"{PREFIX}-gitea-vol" + +volume = client.volumes.create( + name=volume_name, + size=10, + format='ext4', + location=Location("hel1") +) +print(f"Created data volume: {volume.volume.name}") + with open("gitea_cloud_init.yml", 'r', encoding='utf-8') as file: cloud_init_wp1 = file.read() +cloud_init_wp1.replace("VOLUME_NAME", volume_name) + wp1_server = client.servers.create( name=f"{PREFIX}-gitea", server_type=ServerType("cpx11"), image=Image(name="ubuntu-22.04"), ssh_keys=[ssh_key], networks=[vnet], + volumes=[volume.volume], location=Location("hel1"), user_data=cloud_init_wp1 )