Comment on page
Install on AWS EC2 using Docker
Learn how to deploy Squidex on an AWS EC2 instance using Docker containers
The instructions provided here help you get Squidex running on an AWS EC2 instance using Docker containers. It uses an EC2 instance running Docker and deploys Squidex along with NGINX for reverse proxy and MongoDB as the database. The data is stored outside of the containers for persistence but on the same instance (single volume).
This tutorial does not cover the basics of AWS. You should be familiar with them before you begin with the instructions. We have attempted to keep them simple enough so they can be followed by anyone.
This tutorial runs all containers i.e. Squidex, MongoDB and NGINX in a single EC2 instance and may not be recommended for production environments.
Before you start ensure you have:
- 1.An active AWS account.
- 2.A domain name to be used with Squidex.
To launch an instance, login to AWS Console and select the desired region (1) from the drop down on the right. For this demonstration us-east-1 has been used.
Login to AWS and select a Region
Click Launch instance (2) to begin.
This demonstration uses a lot of the default values and is just a quick way to get an EC2 instance running. One can always customize the network, storage and other parameters which is beyond the scope of this guide.
Launch an instance
Start by giving a name for the EC2 instance (3).
Name the EC2 instance
Next, select Ubuntu (4) as the AMI.
Select an AMI
Select an Instance type (5). We recommend at least the m5.large. But for sandbox/experimental requirements you can choose a lower configuration.
Select an Instance type
Select a Key pair (6) to be able to connect to the EC2 instance later.
You must have an AWS Key Pair and select here, otherwise you will not be able to login to the EC2 instance later. If required, click Create new key pair to create one and then select it from the list.
Select a Key pair
For Network settings ensure Allow HTTP and Allow HTTPS (7) traffic is checked. For this demonstration we will leave the rest to their defaults.
Select Network settings
Similarly, for this guide we will not make any changes to storage but one can choose a larger disk size based on requirements. Click Launch instance (8) when ready.
Configure Storage and Launch
This should initiate the launch the EC2 instance. Click on the instance ID (9) to navigate to the instance details.
EC2 instance successfully initiated
Once the instance is ready, copy its Public IPv4 (1) address and configure the DNS mapping i.e ensure that the domain you wish to use with Squidex is pointing to this IP. This typically involves creating an A record to the domain/subdomain you wish to use for Squidex. It is recommended to wait for the DNS changes to propagate before proceeding further.
The mapping is necessary for successful deployment of Squidex and is also used to request SSL certificates.
Retrieve Public IP
Next, connect to the EC2 instance using SSH. Use the key pair selected during instance launch.
ssh -i path/to/keypair.pem ubuntu@[PUBLIC IPv4]
ubuntu is the default username for Ubuntu AMI.
At this point the instance does not have Docker. We will go ahead and install it by running the following commands:
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
# Add current user to docker group
sudo usermod -aG docker $USER
Next, logout and login back to the EC2 instance and verify that Docker commands run without the need for sudo.
It is important to logout and login to apply the changes made earlier where the current user was added to docker group.
In the demonstration below we will run Squidex with NGINX and MongoDB using the
docker-compose-nginx.ymlfile. Start by downloading the required files.
// Download the yml file
// Download the environment file
.envfile and set the following variables:
The rest variables can be empty for now.
The data files, such as assets and the MongoDB database files will be stored, outside of the Docker container for persistence and to simplify backups. The default path
/etc/squidexwill be created by Docker automatically.
Run the docker-compose file with the following command:
docker compose -f docker-compose-nginx.yml up -d
-f docker-compose-nginx.yml(or providing absolute path of the yaml file) is mandatory else the command will fail.
Docker compose will download all images and start them in the right order.