How to deploy Strapi on AWS Elastic Beanstalk using Docker

Yin Ji Sheng
3 min readJun 7, 2020

--

Why use Strapi? 🤔

Strapi is an open-source headless content management system (CMS). The use case that I found for using Strapi is when I want to create a very customised website that would be challenging to build on traditional CMS like WordPress and Wix, and yet at the same time, be able to give business users the power to be able to freely change the content on the website.

The outcome?

Beautiful customised UI + Full Content Control

Strapi has a bunch of helpful tutorials but they didn’t document how to deploy the application onto AWS Elastic Beanstalk. So I have put down the step by step guide below on how you can deploy Strapi onto Elastic Beanstalk using Docker. Hope this helps!

Before you start … 🤚

  1. Install the EB CLI by following the guide here
  2. You need to have Docker installed and running. If not, head over here
  3. Of course, you need to have a Strapi project. if not, head over here

Step 1: Add Dockerfile 🐳

Let’s add a Dockerfile in your Strapi project. You can use the configuration below. Take note that you might want to change the NODE_ENV depending on which environment you want to deploy it to. In this example, we are deploying to the staging environment.

Step 2: Initialise & Testing Locally ✅

Run eb init -p docker <name> and you should see a folder called .elasticbeanstalk getting created with a config.yml file inside. You can run eb init -i to modify any other fields.

(Optional) Run eb local run --port 1337 and then head over to http://localhost:1337 to see if our Docker container is running as expected or not. Take note that this command is not supported on Windows

Strapi serving on localhost:1337

Step 3: Deploying to Elastic Beanstalk 🌱

Run eb create and you will be prompted the following:

Enter Environment Name: 
enter your name or choose the default
Enter DNS CNAME prefix:
choose the default
Select a load balancer type:
choose the default
Would you like to enable Spot Fleet requests for this environment?
(y/N):
y
Enter a list of one or more valid EC2 instance types separated by commas (at least two instance types are recommended):
t2.small, t2.medium

Make sure to choose t2.small minimally as the EC2 instance size for this to work. t2.micro will not work.

Head over to your AWS console and your Strapi project should be successfully deployed 🎉

Need to add databases and plugins to your project and not sure how? Feel free to reach out to me and I’ll be happy to help!

--

--

Yin Ji Sheng
Yin Ji Sheng

Written by Yin Ji Sheng

Technical Consultant at Telstra Purple | Certified AWS, Azure, GCP Solutions Architect | SharePoint

Responses (4)