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

feat: changed the next and previous and made progress on railway page #50

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
docs/.vitepress/cache
docs/.vitepress/dist
.vscode/
4 changes: 4 additions & 0 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ function boringStackGuide() {
text: 'Deploy',
collapsed: false,
items: [
{
text: 'Railway',
link: 'boring-stack/railway'
},
{
text: 'Render',
link: 'boring-stack/render'
Expand Down
2 changes: 1 addition & 1 deletion docs/boring-stack/file-uploads.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ prev:
link: '/boring-stack/session'
next:
text: 'Deploy on Render'
link: '/boring-stack/render'
link: '/boring-stack/railway'
editLink: true
---

Expand Down
127 changes: 127 additions & 0 deletions docs/boring-stack/railway.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
head:
- - meta
- property: 'og:image'
content: https://docs.sailscasts.com/boring-stack-social.png
title: Deploy on Railway
titleTemplate: The Boring JavaScript Stack 🥱
description: Deploy your app on Railway
prev:
text: 'Session'
link: '/boring-stack/file-uploads'
next:
text: Type checking JS files
link: '/boring-stack/render'
editLink: true
---

# Deploy on Railway

Let's deploy your app on [Railway](https://railway.com) :rocket:

## GitHub Repo

Push your app to a repo on GitHub.

## Create database

Create the database you want to use for production on Railway and take note of the connection url.
::: info Database creation guides
See guides for [MySQL](https://docs.railway.com/guides/mysql), [PostgreSQL](https://docs.railway.com/guides/postgresql), and, [MongoDB](https://docs.railway.com/guides/mongodb) on the Railway docs.
:::

## Create Redis instance

Create the production Redis instance and take note of the connection url.
::: info Redis instance guide
See the [guide to create a Redis instance](https://docs.railway.com/guides/redis) on the Railway docs.
:::

## Set up database

Depending on the database you want to use for production, [set up that adapter](/boring-stack/database) in `config/environment/production.js`
::: code-group

```js [PostgreSQL]
module.exports = {
datastores: {
default: {
adapter: 'sails-postgresql',
url: process.env.DATABASE_URL
}
}
}
```

```js [MySQL]
module.exports = {
datastores: {
default: {
adapter: 'sails-mysql',
url: process.env.DATABASE_URL
}
}
}
```

```js [MongoDB]
module.exports = {
datastores: {
default: {
adapter: 'sails-mongo',
url: process.env.DATABASE_URL
}
}
}
```

:::

::: warning
Don't forget to install the adapter if you haven't already. See the [database](/boring-stack/database) docs for more info.
:::

## Set up Redis

::: info
[Create a new Redis instance](https://docs.railway.com/guides/redis) on Railway by following the Railway docs.
:::
Set up the Redis adapter in `config/environment/production.js`

```js
module.exports = {
session: {
secret: process.env.REDIS_SECRET
adapter: '@sailshq/connect-redis',
url: process.env.REDIS_URL
}
}
```

## Create a web service

Create a new [Web Service](https://docs.railway.com/quick-start) on Railway, and give Railway permission to access the repo of your app.

If necessary, use the following values during creation:

- **Runtime**: `Node`
- **Build command**: `npm i`
- **Start command**: `npm start`

However, Railway is capable of configuring things automatically for you.

## Set environment variables

Add the following evironment variables to your web service:

- `DATABASE_URL`: This should point to the connection string of the database you created.
- `REDIS_URL`: This should point to the connection string to the Redis instance you created.
- `SESSION_SECRET`: A unique production session secret to override the one in `config/session.js`.

That’s it! Your app will be live on your Railway URL as soon as the build finishes :tada:

## Celebrate with a :star:

::: tip Star The Boring JavaScript Stack repo on GitHub :star:
Let's celebrate deploying your app on Railway by giving **The Boring JavaScript Stack** [a star on GitHub](https://github.com/sailscastshq/boring-stack).
:::
2 changes: 1 addition & 1 deletion docs/boring-stack/render.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ titleTemplate: The Boring JavaScript Stack 🥱
description: Deploy your app on Render
prev:
text: 'Session'
link: '/boring-stack/session'
link: '/boring-stack/railway'
next:
text: Type checking JS files
link: '/boring-stack/type-checking-js-files'
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.