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. 

Banner

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 and 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

FROM strapi/base

WORKDIR /strapi-app

COPY ./package.json ./
COPY ./yarn.lock ./

RUN yarn install

COPY . .

ENV NODE_ENV staging

RUN yarn build

EXPOSE 1337

CMD ["yarn", "start"]

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

Local Result

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

Take note to choose t2.small minimally for it to work. t2.micro will not work.

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