diff --git a/deploy.py b/deploy.py index 9c352a7..b1a3ac2 100644 --- a/deploy.py +++ b/deploy.py @@ -55,8 +55,53 @@ def create_db_server(client: Client, vnet: BoundNetwork, ssh_key: BoundSSHKey) - print( f"Serwer: {db_server.data_model.name}\n\tpubliczne IP: {db_server.data_model.public_net.ipv4.ip}\n\tprywatne IP: {db_server.data_model.private_net[0].ip}") return db_server - with open(CLOUD_INIT_DB_FNAME) as f: - cloud_init_db = f.read() + # with open(CLOUD_INIT_DB_FNAME) as f: + # cloud_init_db = f.read() + + cloud_init_db = r'''#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: + db: + image: mysql:5.7 + restart: always + ports: + - "10.10.10.2:3306:3306" + environment: + MYSQL_ROOT_PASSWORD: gitea + MYSQL_DATABASE: gitea + MYSQL_USER: gitea + MYSQL_PASSWORD: gitea + volumes: + - db_data:/var/lib/mysql + phpmyadmin: + image: phpmyadmin + restart: always + ports: + - "8080:80" + + volumes: + db_data: {} +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 + - cd /root/ && docker-compose up -d +''' + db_server_resp = client.servers.create( name=DB_SERVER_NAME, server_type=ServerType(MACHINE_TYPE),