Drupal is an open source content management platform powering millions of websites and applications.
We will see how you can easily deploy a simple Drupal website on Docker to the cloud with ScaleDynamics.
Introduction
Drupal is one of the most popular CMS (Content Management Software).
Build with PHP, It is a versatile open source platform for building amazing digital experiences.
Drupal is used to make many of the websites and applications you use every day, see the official showcases.
Drupal has great standard features, like easy content authoring, reliable performance, and excellent security.
But what sets it apart is its flexibility; modularity is one of its core principles.
Prerequisites
To follow this tutorial, we will need:
- Node.js <= 12, we recommend to install the latest LTS version
- Basic knowledge of Docker, and more specifically about Dockerfile
Init your Drupal application
From your terminal, start by creating a new folder named drupal-app
and change directory into it:
mkdir drupal-app
cd drupal-app
Then create a new file named Dockerfile
and paste the following code into it, in order to build you container from an official image of Drupal downloaded from Docker Hub:
# drupal-app/Dockerfile
FROM drupal:latest
EXPOSE 80
In this configuration, we have chosen the official Drupal image with the latest
tag. For a production use case, we recommend setting a stable version with a specified number, like drupal:9.3
for example.
Configure your cloud deployment
The application is ready, now let's look at the deployment part.
Account creation and resource selection
To deploy this application on ScaleDynamics's cloud, you need an account and create an environment with a resource for it. The cloud resource provides virtual CPU and storage capacities used to execute the app. In this tutorial we will use a free shared resource available on ScaleDynamics’s cloud. These are the best one for testing. In this tutorial we will see later how you can upgrade to a dedicated production resource on the public cloud provider and region of your choice.
If you don't have an account, feel free to create one here (it's free and no credit card are required). Once your account is created, sign in.
Let's create a project and an environment on the ScaleDynamics's Console. Select your organization, create a new project, then create a new environment. Now you need to choose what kind of service is required for your deployment. There are four types:
- Managed HTTP Docker
- Managed Node.js server
- Managed Node.js module
- Static assets hosting
For this Drupal project, we need a Docker container to run the PHP server. Let's pick the managed HTTP Docker. You can learn more on the other types in the ScaleDynamics documentation.
Configuration file
Now let's add a configuration to tell the SDK what type of application we want to deploy.
At the root of the project, create a new file named warp.config.js
with the following content:
// drupal-app/warp.config.js
module.exports = {
docker: "drupal-app",
};
Deploy your Drupal container
Next to deploy your container on the ScaleDynamics platform, you have to use the CLI from SDK.
Install SDK
First, install once our public SDK called warp
and available on the official npm registry: https://www.npmjs.com/package/warp
Install the library as development dependency in your project:
npm init -y
npm install --save-dev warp
Or, install it as an npm global dependency on your system:
npm install -g warp
For the next steps, we will use the npx
command to run each warp
command.
The npx
command allows you to run an arbitrary command from an npm package (either one installed locally, or fetched remotely), in a similar context as running it via npm run
.
If you need help on the warp
CLI, just run the help command as below:
npx warp --help
See more about SDK installation and its use in the ScaleDynamics documentation.
Login to ScaleDynamics
For the first time, you must login to the ScaleDynamics platform. So run once the warp login
command to enter your account credentials:
npx warp login
Note that the prompt will ask you to select an organization, only if you have more than one!
Run deployment
Now it's time to deploy your awesome Drupal project on your managed cloud resource.
To achieve that step, you just need to run the warp deploy
simple command line:
npx warp deploy
The deploy command will detect that your application needs to be deployed as Docker resource. The interactive mode will ask you to pick a project and an environnement, in order to deploy your Drupal container on cloud. Then you will have to choose a domain name as public URL. Leave blank if you want a generate random one.
Your Drupal container is now deployed and ready to use from the returned public URL! On the next step, you will have to configure your Drupal website.
In addition, you can automate your deployment and avoid interactive mode with the following options. It can be useful to run that operation from your CI/CD pipeline by example.
npx warp deploy --project <project-name> --env <env-name>
See more about warp deploy
command in the SDK documentation
Setup your Drupal website
Open your browser, go the URL of your managed Docker resource that now serves your Drupal container and start the setup "set-by-step" of your website.
The first load will show you the Drupal interactive initial setup. First, pick your language on form and continue.
Then select the "Demo: Umami Food Magazine" as current installation profile. This option will generate a ready-to-use website sample built from the Drupal CMS that show off some of its most common capabilities. If you are already familiar with the Drupal platform, choose a "Standard" or "Minimal" profile according to your needs.
Next step, select the "SQLite" database for this sample and set your admin password. For production usage, we recommend using an external database, like MySQL or PostgreSQL. You can easily find a DBaaS (Database-as-a-Service) provider to host your data.
Finally step, just wait for the complete installation...
Well done! Your new Drupal website is now live on the cloud provider of your choice.
You can go in the "Log in" section of your published website, enter your admin credentials and try the awesome features offered by the Drupal platform 🚀
Note that you can easily import, export, and synchronize your Drupal configuration from the administration page. See details on the Drupal documentation.
Go further with dedicated resources
If you need a powerful resource with more vCPU, RAM or storage to host your production server, you can upgrade dynamically to a dedicated resource from your ScaleDynamics Console. As shown below it's as simple as a few clicks.
What’s next
At this stage, you have an awesome Drupal website published on cloud with Docker.
You can learn more on the ScaleDynamics documentation, like how to get the logs of your server, use a custom domain, implement a CI/CD pipeline, etc.
Enjoy!
Top comments (0)