Sturdy and long-running, Drupal is one of the most popular CMS solutions on the web, especially for high-traffic websites. In this tutorial, we're going to set up a basic version for non-developers of Drupal and a corresponding MySQL database with the sloppy.io Web UI.
Step 1: Creating the project
By clicking "Create a New Project" on the sloppy.io Web UI dashboard, we get to define our Drupal project. Let's call this project "drupal-tutorial". You can of course choose your own layout of services, but here we're splitting our project into a backend service that will contain the app for our database management system and a frontend service that will consist of the Drupal app.
Step 1: Your project with backend and frontend service
Step 2: Setting up MySQL
Step 2.1: Select Docker image and tag
Starting with the app in our backend, we click on "Settings" to the right of the app. Drupal natively supports MySQL, PostgreSQL, and SQLite. For the purpose of this tutorial, we're going with the most popular choice: MySQL. That's what we also call the app at the top of the screen.
mysql into the "Image Path" field and an auto-suggestion with the official MySQL Docker image on Docker Hub will appear. If you're unsure about the image you've chosen, you can click on the button depicting the Docker whale to the right and you're forwarded to the Docker Hub page of your chosen image.
Since MySQL is regularly updating it's official Docker image, the current and latest version might not be supported by the app it's corresponding with. In this case (writing in July 2018), Drupal doesn't support MySQL 8, but works fine with older releases. Clicking into the "Image Tag" field to the right of "Image Path", sloppy.io already suggests some selectable versions of MySQL. In this case, we're going for
5.7.22. MySQL is not going to be reachable through the web, so we can tip off "web app".
Step 2.1: Docker image and tag added, web app tipped off
Step 2.2: Environment Variables
What we are going to need, though, are some environment variables. By setting a
MYSQL_ROOT_PASSWORD, we're defining root access that will come in handy if we ever need to work inside MySQL from the console. Also, we need a
MYSQL_USER that we call "postgres", a
MYSQL_PASSWORD for that user, and a
MYSQL_DATABASE called "drupal" in which Drupal will create its tables later.
Step 2.2: Environment Variables for MySQL
Step 2.3: Performance Update
Finally, since MySQL is a bit power hungry, head to the top and switch from the "Basic Setup" to the "Performance" tab to assign at least 512 MB of Memory to this app.
Step 2.3: Assign at least 512 MB Memory
Step 3: Setting up Drupal
Step 3.1: Select Docker image
Click the "Add App" button in our frontend service and then "Settings". Calling the app "drupal", we typ "drupal" into the "Image Path" field to select the official Docker image of Drupal from Docker Hub. This time, we go with the latest version, so no "Image Tag" is needed.
Step 3.1: Select Drupal Docker image
Step 3.2: Define web address
For testing purposes, you can set up any available subdomain of our
*.sloppy.zone which will then immediately be available for you. In this case, we choose
drupal-tutorial.sloppy.zone. When you're done testing, you can route your own domain to sloppy.io and your Drupal CMS.
Step 3.2: Defining a web address in the *.sloppy.zone
Step 3.3 Define volume
To be able to keep our individual setup, our themes, and uploaded images persistent, we need to define a volume. The folder that Drupal reserves for all individual content is
/var/www/html, so we head to the "Volumes" tab on top of the app menu and click the button "Add Volume", specifying the aforementioned path in the "Container Path" field. You could of course add more than 8 GB here, but we keep it simple.
Step 3.3: Adding a volume for persistent content
Step 4: Configure Drupal
Step 4.1: Check if everything is staged and running
You can click the "back" button to return to your project overview and there click on "Deploy project" in the upper right corner. You will then be forwarded to the status page of your project. Both apps should appear to be "staging" and after a few seconds, they should be running.
Step 4.1: Wait until Drupal and MySQL are running
Step 4.2: Copy MySQL database connection
Now, before we open the Drupal web configuration, we quickly head back to the settings of our MySQL app by clicking on the gear symbol to the right. There, we choose the "Advanced" tab und scroll down to the heading "Connect other containers". Click the "Copy" button right next to the hostname. We will need this hostname in the process of the web configuration. You can now go back to the project status page and click the "View" link next to Drupal app name (see screenshot from Step 4.1).
Step 4.2: Copy MySQL hostname
Step 4.3: MySQL web setup
Upon entering your test URL, the Drupal web configuration will open. Of crucial interest is the database selection you will encounter as one step of the process. Here, you can select MySQL and enter the values we have chosen above: database name and user name are both "drupal" and password is the password you've set. Next, you open the advanced settings ("Erweiterte Einstellungen" in the German language example below) and in the field for "Host", you paste the hostname copied in Step 4.2. When saving and continuing, Drupal should now proceed to the installation screen.
Step 4.3: Enter database details (German version)
Step 5: Where do we go from here?
At the end of the installation process, Drupal will ask for sitename, admin user name and password, email address, and so on. This you can then use to login to Drupal.
Since we defined a volume, we can always access the content in our "html" folder through the filebrowser in the sloppy.io Web UI. Here's how you can use it. This is a basic setup, so you won't be able to deploy changes in the image, be it your changes or Drupal updates. Instead, all changes require individual upload through the filebrowser. For turning this setup into a proper environment for development, you'd need to setup distinct volumes for the folders that need persistency.
If you have any questions regarding this tutorial or any other question about sloppy.io, don't hesitate to ask our staff by clicking on the chat icon in the bottom right.
Have fun creating content on Drupal. :-)