Creating a drupal site with extra modules

Creating a Drupal site with extra modules

You can create a drupal site with extra drupal modules by following a few simple steps.

For adding extra drupal modules to your site, you’ll need to use:

  • Composer: A tool for managing dependencies in PHP.

  • A GitLab repository: A place to store your code and change it with version control.

This is part of the recommended workflow to add local modules: Composer will install libraries and dependencies automatically. Most Drupal modules require Composer-based installation.

Legacy, unsupported workflow: if you would like to add Drupal modules in the old way without composer, please read Adding local modules through WebDAV.

1. Create a repository with composer.json

Click “FORK” on this repository to have a template to start from:

Every module that you want to install has to be included as a composer dependency. This can be done in two ways:

  • by editing composer.json on GitLab and adding a line in the require section.
  • by running composer require <module> on the terminal.

2. Using Private repos

For security/ privacy related concerns, you may want to use a private gitlab repository.
For this, you need to setup an Access Token on your gitlab repo. Use the following steps to generate an ‘Access Token’ and make sure to modify the ‘Extra configs repo’ URL in step 4

  • On you gitlab repo, go to Settings>AccessTokens. You will find these in the navigation bar on the left

  • In the ‘Project Access Tokens’ page, fill the following fields

    • Token name - Provide a custom name here, which will be used to refer to the token usage. The name is not very important and can be something simple like drupal
    • Expiration date - This can be left empty, for the token to never expire. Or you can set a custom date. Note that, if you set a custom date, the workflow might not work post the specific date
    • Select a role - Select the reporter role from the dropdown list
    • Select scopes - In the scopes, make sure to only select read_repository checkbox
    • Then click on Create project access token button at the bottom. This will refresh the page and display an Access token at the top of the page. Make sure to copy and save this somewhere, as it is displayed only once. If you lose the token, repeat the steps again to create a new one

3. Follow the Creating a drupal site guide till Step 7

4. Fill the Extra configs repo field

If you have a repository that is not public. In the Extra configs repo field, add gitlab username:accesstoken after https:// and before
So, it should look as follows
Make sure to provide the right access token created in Step 2

If you have a public repository, you can simply provide your gitlab URL in the Extra configs repo field

5. Continue with Step 8 and Step 9 of the Creating a drupal site guide

6. Adding webhook triggers to your gitlab repo (In development)

In order for the changes in your gitlab repo to be reflected on the site i.e for new builds to be created, this step is important.

  • From your site management page, on the site you just created, find the “webhook URL” listed and copy it

    • The URL can be found under the Advanced tab of the environment in the portal
  • On your gitlab repo, go to Settings>Webhooks You will find these in the navigation bar on the left

  • Paste the URL you copied in the “URL” field and make sure only Push Events is checked in the Trigger section. Also uncheck the Enable SSL verification in the SSL verification section. And then click on Add webhook

With this setup, every time you push a commit to your repo, will trigger a new build i.e new image will built and be deployed with the changes.

Your drupal site is ready to go.

Hi @dchatzic
Concerning “Creating a drupal site”, is that page publicly visible ?

Because I’m logged in, but I get this :

The link wasn’t correct. I’ve just updated it in the docs.