This article was originally published at: Qovery Blog
AWS (Amazon Web Services) is an amazing and reliable cloud service provider. AWS, like Google Cloud Platform and Microsoft Azure, provides everything you need to host an application without having to worry about running the underlying servers and network configuration. Everything you need to quickly begin hosting is provided as a packaged services.
However, deploying an application on AWS presents some challenges. The typical deployment workflow looks like this: write code, push it to Git, compile code, deploy code, validate your changes and repeat. Developers thus not only have to do all of this manually, but they also have to configure tons of services (VPC, database, cache, DNS, CDN, etc.) to make their application live on the web.
Qovery was created to solve this problem. In this blog post, I will show you how Qovery improves the developer experience to deploy staging and production NodeJS application with PostgreSQL database on AWS. You will be able to focus on writing the best code instead of managing complex services.
- Operating system: MacOS / Windows / Linux
- A Github account
Get a local copy of the NodeJS sample project by forking the project using your Github account and by executing the following command:
⚠️ Do not forget to fork the project and change the URL below with yours
git clone -b tutorial firstname.lastname@example.org:YOUR_GITHUB_USERNAME/simple-example-node-with-postgresql.git
The Qovery CLI is an open-source project that lets you deploy your applications directly on AWS, while taking advantage of well-known local tooling. We will use this tool to speed up our development cycle instead of using the typical development workflow (based on a CI/CD, Docker and other DevOps tools).
Install the Qovery CLI by running the following command:
brew tap Qovery/qovery-cli brew install qovery-cli
curl -s https://get.qovery.com | bash
scoop bucket add qovery https://github.com/Qovery/scoop-qovery-cli scoop install qovery-cli
Authenticate yourself before using it
To deploy the NodeJS application connected to a PostgreSQL database, you need to have a .qovery.yml file and a Dockerfile (already provided) at the root of your project. This file indicate the external resources (eg. PostgreSQL) that your application need to work properly.
To create the .qovery.yml file, run the following command:
The .qovery.yml file is created at the root of the project directory
application: name: simple-example-node-with-postgresql project: simple-example-node-with-postgresql cloud_region: aws/eu-west-3 publicly_accessible: true databases: - type: postgresql version: "11.5" name: my-postgresql-3498225 routers: - name: main routes: - application_name: simple-example-node-with-postgresql paths: - /*
Note: Qovery supports multiple databases (eg. PostgreSQL, MySQL, MongoDB, Redis, Memcached, Cassandra), brokers (eg. RabbitMQ, Kafka) and storage services(eg. S3).
Authorize the Qovery Github application to get access to your Github account through this link. After that, you just need to commit and push the .qovery.yml file in order to deploy your app.
git add .qovery.yml .gitignore git commit -m “add .qovery.yml and update .gitignore” git push -u origin tutorial
Voila! Qovery is now deploying your app!
⚠️ BETA: During the Beta phase, the first deployment requires 26 minutes (the database requires a longer processing time while being deployed for the first time due to AWS). After that, each update will take only 2 minutes. Wait a couple of minutes and type the following command to get your application endpoint:
Environment branch status endpoints applications databases brokers storage master LIVE https://x52d28s8iu22mwmi-main-gtw.qovery.io 1 1 0 0 Applications name status databases brokers storage simple-example-node-with-postgresql LIVE 1 0 0 Databases name status type version endpoint port username password application my-postgresql-3498225 LIVE POSTGRESQL 11.5 x52d28s8iu22mwmi-rq1xywcyi8wqqcmt-b5pcw97rq8456u5z.cnuxtlki1yn9.eu-west-3.rds.amazonaws.com 5432 superuser **************** simple-example-node-with-postgresql Brokers name status type version endpoint port username password application Storage name status type version endpoint port username password application
The Qovery motto is: if your application runs locally, then your application will run on Qovery. To test if your application is running locally, execute the following command:
Warning: Docker runtime required.
... Step 6/7 : EXPOSE 3000 ---> Running in a154409a60a7 ---> 572b7f72c640 Step 7/7 : CMD node ./bin/www ---> Running in e315a1fe7c35 ---> b8c8f6b25307 Successfully built b8c8f6b25307
Navigate to http://localhost:3000 through your web browser and you should see a Welcome message.
Note: qovery run connects your application to the PostgreSQL database on AWS.
Qovery has a very powerful feature known as “environment”. Qovery supports the deployment of isolated development environments from your branches, complete with exact copies of all of your data. This is useful for testing changes in isolation before merging them.
So, do you want to create a new feature, fix a bug or make a modification without impacting the production or any other important environment? Type the following commands:
git checkout -b feat_foo
Do your changes if required, and commit + push them
git push -u origin feat_foo qovery status
Environment branch status endpoints applications databases brokers storage feat_foo LIVE https://vvzwrr81194ksqaw-main-gtw.qovery.io 1 1 0 0 Applications name status databases brokers storage simple-example-node-with-postgresql LIVE 1 0 0 Databases name status type version endpoint port username password application my-postgresql-7972832 LIVE POSTGRESQL 11.5 vvzwrr81194ksqaw-fdhuc83ov12fayoz-kpxoosudsewqxs9b.cnuxtlki1yn9.eu-west-3.rds.amazonaws.com 5432 superuser **************** simple-example-node-with-postgresql Brokers name status type version endpoint port username password application Storage name status type version endpoint port username password application
Qovery and AWS together bring to developers the full power of simplicity and flexibility while deploying applications. Any developer can now take advantage of AWS in seconds instead of days.