Skip to content
Snippets Groups Projects
cloud-init.yml 2.95 KiB
Newer Older
  • Learn to ignore specific revisions
  • Nathan RODET's avatar
    Nathan RODET committed
    #cloud-config
    
    # System update
    package_update: true
    package_upgrade: true
    
    # Install Packages
    packages:
      - curl
      - git
    
    write_files:
    #
    # Atrium config file
    #
      - content: |
          hostname: %atrium_hostname%.daag.alpha.grandlyon.com
          debug_mode: false
          letsencrypt_email: %atrium_letsencrypt_email%
          tls_mode: Auto
          apps: # optional : applications served by atrium
            - id: 1
              name: Code %atrium_count_index%
              icon: web_asset
              color: 4292030255
              is_proxy: true
              host: code-%atrium_count_index%
              target: localhost:8080
            - id: 2
              name: Desktop %atrium_count_index%
              icon: web_asset
              color: 4292030255
              is_proxy: true
              host: desktop-%atrium_count_index%
              target: localhost:8081
        path: /root/atrium.yaml
    #
    # Code-server config file
    #
      - content: |
          bind-addr: 0.0.0.0:8080
          auth: password
          password: %user_password%
          cert: false
        path: /root/config.yaml
    
    runcmd:
    #
    # Install Rust
    #
      - "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"
      - "source \"$HOME/.cargo/env\""
    #
    # Install Docker
    #
      - "curl -fsSL https://get.docker.com -o get-docker.sh"
      - "sh get-docker.sh"
    #
    # Install Atrium
    #
      - "mkdir -p /root/atrium/data && mkdir -p /root/atrium/letsencrypt_cache"
      - 'sed -i "s/%atrium_hostname%/$(scw-userdata atrium_hostname)/g" /root/atrium.yaml'
      - 'sed -i "s/%atrium_letsencrypt_email%/$(scw-userdata atrium_letsencrypt_email)/g" /root/atrium.yaml'
      - 'sed -i "s/%atrium_count_index%/$(scw-userdata atrium_count_index)/g" /root/atrium.yaml'
      - "mv /root/atrium.yaml /root/atrium/atrium.yaml"
      - "chown -Rf 1000:1000 /root/atrium"
    #
    # Run Atrium Container
    #
      - "docker run -d --name atrium --restart unless-stopped --net=host -v /root/atrium/atrium.yaml:/app/atrium.yaml -v /root/atrium/letsencrypt_cache:/app/letsencrypt_cache -v /root/atrium/data:/app/data nicolaspernoud/atrium:latest"
    #
    # Install And Run Code Server
    #
      - "export HOME=/root"
      - "export USER=root"
      - "mkdir -p  /root/.config/code-server/"
      - 'sed -i "s/%user_password%/$(scw-userdata user_password)/g" /root/config.yaml'
      - "mv /root/config.yaml /root/.config/code-server/config.yaml"
      - "curl -fsSL https://code-server.dev/install.sh | sh"
      - "sudo systemctl enable --now code-server@$USER"
    #
    # Run Webtop Container
    #
      - "docker run -d --name=webtop --security-opt seccomp=unconfined -e PUID=0 -e PGID=0 -e TZ=Europe/Paris -e SUBFOLDER=/ -e KEYBOARD=fr-fr-azerty -e AUTO_LOGIN=false -p 8081:3000 -v /root/webtop:/config -v /var/run/docker.sock:/var/run/docker.sock --shm-size=8gb --cap-add=NET_ADMIN --privileged --restart unless-stopped --sysctl net.ipv6.conf.all.disable_ipv6=0 lscr.io/linuxserver/webtop:ubuntu-xfce"
      - 'echo "$(scw-userdata user_password)\n$(scw-userdata user_password)" | docker exec -i webtop passwd abc'
    #
    # Install Repository
    #
      - "git clone https://github.com/NathanRodet/rust-axum-demo /root/rust-axum-demo"