Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overhaul and add section on kickback program #369

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 94 additions & 46 deletions src/docs/reference/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,68 @@
title: Templates
---

Templates allow you to deploy a fully configured project that is automatically
connected to infrastructure. Examples of templates are:
Templates provide a way to jumpstart a project by giving users the means to package a service or set of services into a reusable and distributable format.

- NextJS app with Prisma
- Django app connected to Postgres
- Elixir Phoenix webserver
- Discord/Telegram bots
There are two main ways to interact with templates in Railway - creation and deployment.

You can find featured templates on our
[dedicated templates page](https://railway.app/templates).
## Creation

## Updatable Templates
Creating a template allows you to capture your infrastructure in a reusable and distributable format. By defining services, environment configuration, network settings, etc., you lay the foundation for others to deploy the same software stack with the click of a button.

Every time you visit a project deployed from a template, we will check to see if the project it is based on has been updated by its creator.
### How to Create a Template

If it has received an upstream update, we will create a branch on the GitHub repo that was created when deploying the template, allowing for you to test it out within a PR deploy. If you are happy with the changes, you can merge the pull request, and we will automatically deploy it to your production environment.
You can either create a template from scratch or base it off of an existing project.

<Banner variant="info">
If you're curious, you can read more about how we built updatable templates in this <Link href="https://blog.railway.app/p/updatable-starters">blog post</Link>.
</Banner>
#### Starting from Scratch

## Creating a Template
The [Railway button page](https://railway.app/button) allows you to create templates to offer a 1-click deploy on Railway experience.

The [Railway button page](https://railway.app/button) allows you to create templates to offer a 1-click deploy on Railway experience. Services within a template can point to any public repository.
Services within a template can be deployed from any public Github repository, or directly from a Docker image in Docker Hub or Github Container Registry.

<Image src="https://res.cloudinary.com/railway/image/upload/v1656470421/docs/template-editor_khw8n6.png"
alt="Template Editor"
layout="intrinsic"
width={1218} height={1120} quality={80} />

Configure your own button at
[railway.app/button](https://railway.app/button) where you can define the repo
to deploy, plugins to install, and required env vars.
Simply name the template, add and configure the services and click `Create Template`.

### Specifying a Branch
#### Convert a Project into a Template

When adding services to a template, you can enter a url to a GitHub repo's branch to have a user clone that instead of the `main` branch.
You can also convert an existing project into a template by heading over to your project settings page. We will automatically identify and add all the required services.

### Additional Configuration
<Image
src="https://res.cloudinary.com/railway/image/upload/v1680277820/CleanShot_2023-03-31_at_19.47.55_2x_yvr9hb.png"
alt="Generate template from project"
layout="intrinsic"
width={1599}
height={899}
quality={80}
/>

Within the Project Settings, you can convert your project into a ready-made Template for other users by pressing the `Create Template` button.

Once the template has been generated, you will be taken to the template creation page to confirm the settings and finalize the template creation.

### Configuring Services

You can configure the following fields to enable successful deploys for template users:
Whether you are building from scratch or have started from an existing project, once you are on the [template creation page](https://railway.app/button), you will see various configuration options for each service added to your template.

- Root Directory (Helpful for monorepos)
- Start command
- Healthcheck Path
- Variables (with an optional description default value)
In addition to the Source, you can configure the following fields to enable successful deploys for template users:

- [Enable Public Networking](/deploy/exposing-your-app)
- [Root Directory (Helpful for monorepos)](/deploy/monorepo)
- [Start command](/deploy/deployments#start-command)
- [Healthcheck Path](/deploy/healthchecks)
- [Volume mount path](/reference/volumes)
- [Variables](/develop/variables) (with an optional description default value)

#### Specifying a Branch

When adding services to a template, you can enter a url to a GitHub repo's branch to have a user clone that instead of the `main` branch.

### Template Variable Functions
#### Template Variables Functions

Template variable functions allows you to dynamically generate variables (or parts of a variable) on demand when the template is deployed.
Template variable functions allow you to dynamically generate variables (or parts of a variable) on demand when the template is deployed.

<Image src="https://res.cloudinary.com/railway/image/upload/v1690581532/docs/screenshot-2023-07-28-15.31.42_tjgp1e.png"
alt="Template Variable Functions"
Expand All @@ -69,22 +81,7 @@ The current template variable functions are:

- `randomInt(min?: number, max?: number)`: Generates a random integer between min and max (defaults to 0 and 100)

## Convert a Project into a Template

You can also convert an existing project into a template by heading over to your project settings page. We will automatically identify and add all the required services and plugins.

<Image
src="https://res.cloudinary.com/railway/image/upload/v1680277820/CleanShot_2023-03-31_at_19.47.55_2x_yvr9hb.png"
alt="Generate template from project"
layout="intrinsic"
width={1599}
height={899}
quality={80}
/>

Within the Project Settings, you can convert your project into a ready-made Template for other users by pressing the "Create Template" button.

## Publishing a Template
### Publishing a Template

Once you create a template, you have the option to publish it. Publishing a template will add it to our [templates page](https://railway.app/templates). Simply click the publish button and fill out the form to publish your template.

Expand All @@ -96,7 +93,7 @@ Once you create a template, you have the option to publish it. Publishing a temp
quality={80}
/>

## Managing your Templates
### Managing your Templates

You can see all of your templates on your [Account's Templates page](https://railway.app/account/templates). Templates are separated into Personal and Published templates. You can edit, publish/unpublish and delete templates whenever you'd like!

Expand All @@ -107,3 +104,54 @@ You can see all of your templates on your [Account's Templates page](https://rai
width={3100}
quality={80}
/>

### Sharing your Templates

After you create your template, you may want to share your work with the public and let others clone your project.

#### Deploy on Railway Button

Upon template creation, you are provided with the Template URL where your template can be found and deployed.

To complement your template, we also provide a `Deploy on Railway` button which you can include in your README or embed it into a website.
![https://railway.app/button.svg](https://railway.app/button.svg)
The button is located at [https://railway.app/button.svg](https://railway.app/button.svg).

For examples and more information about the button, head over to our [Deploy On Railway Button](/deploy/deploy-on-railway-button) page.

#### Kickback program
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved

If your published template is deployed into other users' projects, you are immediately eligible for a 25% kickback, in the form of Railway credits, of the usage cost incurred by those users. That means if a user deploys your template, and the usage of the services cost the user $100, you could receive $25 in Railway credits.

Important things to note:
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved
- Your template must be published to the marketplace to be eligible for kickback.
- For Hobby users with a $5 discount, only usage in excess of the discount is counted in the kickback.
- Platform fees are not included in the kickback, but usage fees of the platform are included. E.g. if a user pays $20 in platform fees, then incurs $200 of usage from your template, you are eligible for a $50 kickback (25% of $200).
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved
- All service types and resource usage of those services (compute, volume, egress, etc) *do count* towards the kickback.

Read more about the kickback program [here](https://railway.app/open-source-kickback).

## Deployment

Templates allow you to deploy a fully configured project that is automatically
connected to infrastructure. Examples of templates are -

- NextJS app with Prisma
- Django app connected to Postgres
- Elixir Phoenix webserver
- Discord/Telegram bots

You can find featured templates on our
[dedicated templates page](https://railway.app/templates).

### Updatable Templates
melissa-hale marked this conversation as resolved.
Show resolved Hide resolved

Every time you visit a project deployed from a template, we will check to see if the project it is based on has been updated by its creator.

If it has received an upstream update, we will create a branch on the GitHub repo that was created when deploying the template, allowing for you to test it out within a PR deploy.

If you are happy with the changes, you can merge the pull request, and we will automatically deploy it to your production environment.

<Banner variant="info">
If you're curious, you can read more about how we built updatable templates in this <Link href="https://blog.railway.app/p/updatable-starters">blog post</Link>.
</Banner>