Skip to content

Migrate from Render to Coherence

This guide shows you how to easily migrate your application from Render to Coherence.

By running your app in your own cloud account on Amazon Web Services (AWS) or Google Cloud Platform (GCP), you get the compliance, cost, and customization benefits that only the large public cloud providers can offer. Read more about Coherence vs. platform-as-a-service (PaaS) provider hosting here.

Coherence offers the features you love on Render, like built-in CI/CD and preview environments, while also delivering a great developer experience with a user-friendly developer portal and CLI. When you use Coherence, you don't need to be a DevOps expert to manage a world-class deployment platform - leave that part to us. Additionally, you can use your cloud credits with Coherence, making it the perfect choice for startups.

What You'll Learn

This guide will show you how to:

  1. Prepare an application deployed on Render for deployment on Coherence
  2. Deploy the application on Coherence
  3. Migrate the data from your Render database to Coherence
  4. Transfer your domain from Render to Coherence

Prerequisites

To follow along, you'll need:

1. Prepare your Render application for migration

Coherence gives you flexible options for building and deploying your application.

If you don't have a Dockerfile, Coherence will automatically use Nixpacks to build your container. This means you don't need to make any changes to your application structure.

Option B: Use an existing Dockerfile

If you've been using a Dockerfile with Render, Coherence will use that Dockerfile to deploy your application. No additional preparation is needed.

Option C: Write a Dockerfile (if necessary)

If your application doesn't have a Dockerfile and you prefer not to use Nixpacks, you'll need to write a Dockerfile for your application. Here's an example for a Django application:

FROM python:3.12

WORKDIR /app

COPY requirements.txt /app/
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

COPY . /app/

RUN python manage.py collectstatic --no-input

Update Django settings for Coherence

Remove Render-specific configuration and update your project settings to ensure your app works correctly in a Coherence environment, including proper handling of AWS Application Load Balancer (ALB) health checks. For GCP, the health check IP will not apply (but the ALLOWED_HOSTS still needs to know what domain you are serving on). Django is used in this example, and your application may or may not have a similar setting depending on the framework you're using.

In your Django project's settings.py file, replace Render-specific code with Coherence-specific settings:

import os
from socket import gethostbyname, gethostname

DEBUG = False

ALLOWED_HOSTS = [
    os.environ.get('CNC_ENVIRONMENT_DOMAIN'),
    gethostbyname(gethostname()),  # This allows AWS ALB health checks
]

# If you're using a custom domain, add it to ALLOWED_HOSTS as well
if os.environ.get('CNC_CUSTOM_DOMAIN'):
    ALLOWED_HOSTS.append(os.environ.get('CNC_CUSTOM_DOMAIN'))

# If you have additional allowed hosts set in an environment variable
if os.environ.get('ADDITIONAL_ALLOWED_HOSTS'):
    ALLOWED_HOSTS.extend(os.environ.get('ADDITIONAL_ALLOWED_HOSTS').split(','))

This configuration does the following:

  1. Sets DEBUG to False for production environments
  2. Adds the Coherence environment domain to ALLOWED_HOSTS
  3. Includes the container's private IP address in ALLOWED_HOSTS to allow AWS ALB health checks
  4. Conditionally adds a custom domain to ALLOWED_HOSTS if one is set in the environment variables
  5. Allows for additional hosts to be added via an environment variable, if needed

Remember to set the ADDITIONAL_ALLOWED_HOSTS environment variable in your Coherence environment if you're using other domains or need to allow additional hosts.

Note on AWS ALB health checks

The AWS Application Load Balancer (ALB) performs health checks by sending requests to the container's private IP address. Django's ALLOWED_HOSTS setting needs to include this IP address to accept these health-check requests. The gethostbyname(gethostname()) function call dynamically retrieves the container's IP address, ensuring that health checks will succeed even if the IP changes.

Configure the database

This configuration uses the DATABASE_URL environment variable, which Coherence will provide, just as Render did. Ensure your settings.py file includes the following database configuration:

import dj_database_url

DATABASES = {
    'default': dj_database_url.config(
        default=os.environ.get('DATABASE_URL'),
        conn_max_age=600
    )
}

Save your startup command

Note the command used to start your application. For a Django application, it might look like this:

python -m gunicorn mysite.asgi:application -k uvicorn.workers.UvicornWorker

You'll need this command when configuring your service in Coherence.

2. Deploy your application on Coherence

Now that your code is prepared, let's set up your application on Coherence.

Create a new application

  1. In the Coherence dashboard, click New application
  2. Give the application a name
  3. Select Google Cloud as the provider and Cloud Run as the architecture
  4. Click Continue

Create a collection

  1. On the application's landing page, click Create collection
  2. Give the collection a name
  3. Click Create Collection

Configure an environment

  1. In the collection, click New Environment
  2. Give the environment a name
  3. Select the appropriate environment type (Staging is recommended for initial testing)
  4. Click Create

Add Coherence services

Create a backend service

  1. Click the environment name to enter the environment homepage
  2. Go to the Services tab
  3. Click New service and select the framework for your project under Container
  4. Configure the service:
  5. Name: Give the service a name
  6. Start Command: Enter the command you saved earlier
  7. Enter "/" under URL path
  8. Container source: Choose Repository
  9. Click Add one under Repo
  10. Paste in the link to your GitHub code repository
  11. Enter "/" under Context
  12. If you're using a Dockerfile, enter "Dockerfile" under Dockerfile. Otherwise, leave it blank to use Nixpacks
  13. Select your track branch (e.g., main)
  14. Click Create service

After creating the service, add the necessary environment variables in the Variables tab. You can bulk import variables using the Coherence UI. The Coherence CLI offers environment variable management capability for scripting.

Create a database service

  1. In the Services tab, click New service and select Postgres
  2. Configure the database:
  3. Name: Give the service a name
  4. Engine: Enter "postgres"
  5. Version: Choose the appropriate version
  6. Click Create service

Connect to your cloud provider

Follow the steps in our Google Cloud guide or AWS guide to connect Coherence to your cloud account.

Start a provisioning task

When Coherence has been granted access to your cloud account, submit a provisioning task so that Coherence can automatically set up and manage the necessary cloud resources for your collection.

  1. Select the Provision Tasks tab for the collection
  2. Click Submit new task to submit a provisioning task

Wait for this step to complete before moving on. It should take several minutes.

Start a build and deploy pipeline

  1. Go to the Deployments tab for the environment
  2. Click New deployment
  3. Select the branch and commit to submit from
  4. Click Submit deployment to start the build & deploy pipeline

View your deployed application

Once the build is complete:

  1. In your Coherence dashboard, navigate to your environment
  2. Click the URL at the top of the environment details page to open your deployed application

Coherence app deployed

3. Migrate the data

This is a crucial step in the migration process. Don't hesitate to contact the Coherence team if you need assistance.

Export data from Render

  1. In your Render dashboard, go to your PostgreSQL database
  2. Click the Connection tab
  3. Copy the External Database URL
  4. Use pg_dump to export your data:
pg_dump "your-render-external-database-url" > render_db_dump.sql

Choose a migration method

You can migrate data to Coherence in two ways:

  1. Using the Coherence CLI (cocli)
  2. Migrating directly to your cloud database

Set up a CNC toolbox

Set up a CNC toolbox to interact with your Coherence environment from your local machine:

gcloud auth application-default login
gcloud auth login

Start a toolbox

First, set up authentication.

  • In the Coherence dashboard, navigate to your profile
  • Click Create token
  • Give the token a name and select an expiration period
  • Click Create token
  • Copy the token value
  • Run the following command on your local machine with your access token:
export COHERENCE_ACCESS_TOKEN="your-access-token-here"

Next, set your app ID and collection ID to variables.

In your terminal, add your app name and collection name to the command below:

app_id=$(cocli apps list | jq '.[] | select(.title=="Your App Name") | .id')

collection_id=$(cocli collections list -a $app_id | jq '.data[] | select(.name=="your-collection-name") | .id')

To start a toolbox, replace main with your environment name in the following command:

cocli cnc -c $collection_id -- toolbox start main --proxy-only

Keep the toolbox running while you migrate the data in a new terminal.

Migrate the data to the Coherence project

To import your data to your new Coherence-managed database:

  • Open a new terminal in the folder containing the render_db_dump.sql file
  • Get the psql database connection string from Coherence by copying the value of the DATABASE_URL variable found in the Variables tab on your environment homepage
  • Run the following command, replacing <database-connection-string> with your database connection string and path/to/render_db_dump.sql with the path to your migration file:
psql -d <database-connection-string> < path/to/render_db_dump.sql

To migrate your data directly to GCP, first authorize your public IP.

  • Get your public IP. Find your public IP here.
  • Navigate to your GCP console
  • Navigate to SQL in the left menu
  • Navigate to Connections and open the Networking tab
  • Scroll down to Authorized networks
  • In New network, give your network a name and add your public IP address in the Network field
  • Click Add network, then click Save at the bottom of the page

Connect to your Cloud SQL database on your local machine with the following command:

psql -d <database-connection-string> < path/to/render_db_dump.sql

Verify the data migration

Check your application to ensure your data has been successfully migrated.

4. Migrate the domain

The final step is to update your domain settings to point to your Coherence-hosted application.

Remove the domain from Render

  1. In your Render dashboard, go to your web service
  2. Navigate to the Settings tab
  3. Remove the custom domain from your Render service

Change DNS settings for the domain

  1. Log in to your domain registrar's dashboard
  2. In the Coherence dashboard, navigate to your environment homepage and select the Custom domains tab
  3. Add your custom domain to the Domain field
  4. Copy the provided DNS record and add it to your domain registrar's settings
  5. Click Add domain to save the configuration

Coherence migrate domain

Wait for DNS propagation (up to 48 hours).

Once DNS propagation is complete, visit your domain to verify that your website is accessible and your migrated data is functioning correctly.

Conclusion

Congratulations! You've successfully migrated your application from Render to Coherence. Enjoy the benefits of running your application on your own cloud infrastructure while maintaining the ease of use you're accustomed to with PaaS providers.

If you encounter any issues or have questions during the migration process, don't hesitate to reach out to the Coherence support team. We're here to ensure your migration is smooth and successful.