Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

noire.munich
noire.munich

Posted on • Edited on

     

Lightsail to deploy your first RedwoodJS App

So you've been trying out RedwoodJS and are looking for some easy AWS hosting solution.

AWS Lightsail andRedwoodJS Baremetal have you covered.

For that we will assume you have your repo with your RedwoodJS app ready to be deployed.
This short tutorial should set you on the right path, however I have not yet covered theapi side. Come back later, as I intend to explore this as well.

At the end of this tutorial you will get an instance of Lightsail up & running with the web side of your application's current version served to a public static IP and bound to your domain.

Let's get this thing started:

Sign in AWS

Go to Lightsail and create your first instance

  • Pick the Linux/Unix platform
  • Select the Apps + OS blueprint category
  • Tick the Node.js blueprint

Make sure your ssh key is configured properly as we are not going to cover that here. You can change this later though.

Select yourinstance plan, but be aware that you will need at least1GB of RAM otherwise the deploy will fail to heap usage.

Name your instance and tag it if that's how you work.
Your instance is being created.

Create and assign a static IP

Go to the Lightsail > Networking tab and create a Static IP. Into the IP page, attach your newly created instance.
Copy the new IP, you will need it in a minute.
Disable IPv6 - this is not ideal but it will help you install a certificate later on with minimal effort.

Create a domain

If you don't have one, create a domain onAWS Route 53.
If you already have one, you will need to update the DNS of your domain provider to add the records.
Remove any IPv6 record from your domain's configuration that may be lingering - it would have to be an AAAA record.

Configure the DNS

Go to Route 53 > Hosted zones and select your domain.
Create a new Record of type 'A', leave its name empty and change its value to add the IP address you should still have in your clipboard - the static IP we created earlier in Lightsail.
Set the TTL at 60 if it is not already and save.

This solution doesn't feel ideal but getting it to work with Lightsail's DNS wasn't getting me anywhere. It is valid though and documented by AWShere


What happens next should happen in your instance, so please, SSH there now


Create a ssh key and add it to Github

In terminal usessh-keygen - passphrase is optional but recommended.
In~/.ssh usecat on the[your_keyname_file].pub (hence on the.pub) and add it to your Github settings. This will help your instance clone and update your app.

Manually add pm2

pm2 is necessary to deploy RedwoodJS baremetal and it is not included in the instance. That's going to be easy enough to fix, still in yourssh terminal:
sudo npm install pm2 -g

Create your certificate for HTTPS

You will use Bitnami's installed bncert tool, which will set you up with a Let's encrypt certificate in no time. The tool is preinstalled, so just run the following command. Make sure your domains are comma separated. We do not coverwww.[domain] in this tutorial so you are on your own for that.

$ sudo /opt/bitnami/bncert-tool --domains [domain1,domain2,...]

And follow on the instructions. It will install a certificate thanks tohttps://letsencrypt.org/fr/, so it's free.

Update Apache hosts

Now we need to fix our Apache hosts to make sure they will serve your app.
In terminal, open the file and update the path of the app to add the suffix/current/web/dist :

$ vim /opt/bitnami/apache2/conf/bitnami/bitnami.conf
Enter fullscreen modeExit fullscreen mode

That's good. For port:80, HTTP protocol.
You should report the same modification in here to support HTTPS:

$ sudo vim /opt/bitnami/apache2/conf/bitnami/bitnami-ssl.conf
Enter fullscreen modeExit fullscreen mode

Save and restart apache:

$ sudo /opt/bitnami/ctlscript.sh restart apache
Enter fullscreen modeExit fullscreen mode

Please leave your instance now and go back to your local terminal, astutely positioned to your app's root directory. We should stay local as of now.


Setup the baremetal deploy for your RedwoodJS app

Enter the command:

yarn rw setup deploy baremetal
Enter fullscreen modeExit fullscreen mode

It should create you the following files:

  • deploy.toml
  • ecosystem.config.js
  • web/src/maintenance.html

Updatedeploy.toml

Mine looks roughly like this:

[[production.servers]]host = "[static ip configured in Lightsail]"username = "bitnami"privateKeyPath = "[location to the default Lightsail SSH key file you would have configured while creating your Lightstail instance]"agentForward = truesides = ["api","web"]packageManagerCommand = "yarn"monitorCommand = "pm2"path = "/home/bitnami/htdocs"processNames = ["serve"]repo = "[path to your git repo]"branch = "main"keepReleases = 5
Enter fullscreen modeExit fullscreen mode

That should do the trick.host,privateKeyPath,path andrepo should be updated accordingly.

Change your redwood.toml to update the web port

Updateredwood.toml:

[web]  title = "Redwood App"-  port = 8910+  port = 80
Enter fullscreen modeExit fullscreen mode

Should be enough.

Now commit and push!

Run your first dpeloy

Back to terminal:

$ yarn rw deploy baremetal production --first-run
Enter fullscreen modeExit fullscreen mode

That's about it. Check your static IP, you should be good to go. If you just created your domain you're going to have to wait for a couple of days before you can check - AWS should notify you of its availability though and it can be way quicker.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Developing for a solid decade, both backend & frontend.Working a lot with RedwoodJS: you've heard about the early birds, I'm the egg in that story.
  • Location
    Paris
  • Joined

More fromnoire.munich

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp