Nextcloud: 4. Create the service

This documentation is part of the Automating with the CLI guide. You can view the complete guide here: Start Nextcloud, retrieve its credentials, and programmatically update its configuration using the Stackhero CLI.

👋 Welcome to the Stackhero documentation!

Stackhero offers a Nextcloud cloud solution for your files and your team:

  • Unlimited users, apps, and transfers: no per-user fees.
  • Euro-Office (Nextcloud Office) to edit your documents, spreadsheets, and presentations directly in your browser, available on the 1T and 5T plans.
  • Effortless updates: keep Nextcloud up to date with just one click.
  • Custom domain name with HTTPS: run Nextcloud at a secure, branded URL, such as https://cloud.your-company.com.
  • High performance and enhanced security: your data is hosted on private, dedicated infrastructure.

With Stackhero, you can deploy Nextcloud in just a few minutes. Try our Nextcloud cloud hosting to share and edit your files without the need to manage a server.

Below is a sample script that creates a stack, adds your Nextcloud service to it, waits for it to start, retrieves its configuration (including generated credentials), and then applies a new configuration.

#!/bin/bash
set -e

export STACKHERO_TOKEN="usr-xxxxxx:your-token"

serviceStore="nextcloud"   # The Nextcloud service store name (see step 2)
instance="..."                # An instance size from step 3
region="europe"               # A region name from step 3

# Create a stack for your service (uses your default organization; add --organization if needed)
stackId=$(stackhero --format=script stack-create \
  --name="My Nextcloud stack")
echo "Stack created: ${stackId}"

# Add Nextcloud to the stack (names are resolved automatically)
serviceId=$(stackhero --format=script service-add \
  --stack="My Nextcloud stack" \
  --service-store="${serviceStore}" \
  --instance="${instance}" \
  --region="${region}")
echo "Service added: nextcloud"

# Wait for the service to be fully running (this may take a couple of minutes)
stackhero service-wait-for --service="nextcloud"

# Retrieve the service configuration, including generated credentials
stackhero service-configuration-get --service="nextcloud" --format=json