|
|
# Drupal Platform Stack
|
|
|
Drupal codebase is tested and supported for LEMP stack composing below.
|
|
|
|
|
|
1. Ubuntu 20 LTS
|
|
|
1. PHP-FPM 8.x version from repo https://launchpad.net/~ondrej/+archive/ubuntu/php
|
|
|
1. Opensource MariaDB Stable 10.x version from https://downloads.mariadb.org/
|
|
|
1. Opensource Nginx Stable from repo https://launchpad.net/~nginx/+archive/ubuntu/stable
|
|
|
|
|
|
## Steps to Create Local/Dev Environment:
|
|
|
Please note that in the commands below you will need to replace text inside angle braces `<something>` including angle braces with appropriate values.
|
|
|
|
|
|
We've used the `MBDA Drupal 9` project as an example below - but these steps can be used to setup your local dev environment for any of our projects in Gitlab.
|
|
|
|
|
|
## Initial local codebase setup
|
|
|
|
|
|
1. Create a fork of the project codebase (E.g. `EA/MBDA Drupal 9`) in Gitlab repo:
|
|
|
1. Visit https://git.commerce.gov/enterprise_applications/mbda8 (path was set to end at `mbda8` based on original setup on D8)
|
|
|
1. Click on the fork link at the top of that repo project page.
|
|
|

|
|
|
1. Choose your namespace/account to create a fork.
|
|
|

|
|
|
1. This newly created fork will be something like `https://git.commerce.gov/<your namespace>/mbda8` . Hereafter this is referred as `MBDA Drupal 9 Fork` in these instructions. This will be your downstream project where we will be working on and committing changes to the upstream project - https://git.commerce.gov/enterprise_applications/mbda8
|
|
|
1. Setup your SSH Key for pulling and pushing code from your local environment to our our code repositories in GitLab (see [Gitlab and SSH Keys](https://git.commerce.gov/publicgroup/documentation/-/blob/master/documents/authentication_with_ssh_keys.md)) **PLEASE REACH OUT TO OUR SYSADMIN IF YOU NEED ASSISTANCE WITH THIS STEP**
|
|
|
1. Create and navigate to a local `Sites` directory and clone your `MBDA Drupal 9 Fork` by running the command:
|
|
|
`git clone git@git.commerce.gov:<yourforkname>/mbda8.git mbda_d9`
|
|
|
* This will clone your `MBDA Drupal 9 Fork` codebase inside your local `Sites` directory entitled `mbda_d9` and defaults to [Master] branch. E.g `Sites/mbda_d9`
|
|
|
1. Navigate to your new `mbda_d9` directory and set your upstream remote to the Master MBDA Drupal 9 branch (https://git.commerce.gov/enterprise_applications/mbda8) repo by running the commands:
|
|
|
`git remote add upstream git@git.commerce.gov:enterprise_applications/mbda8.git`
|
|
|
1. Confirm both your origin (your MBDA Drupal 9 fork) and upstream (master d9 repo) remotes are present.
|
|
|
`git remote -v`
|
|
|
* Output should look like this:
|
|
|
|
|
|
```
|
|
|
origin git@git.commerce.gov:<yourforkname>/mbda8.git (fetch)
|
|
|
origin git@git.commerce.gov:<yourforkname>/mbda8.git (push)
|
|
|
upstream git@git.commerce.gov:enterprise_applications/mbda8.git (fetch)
|
|
|
upstream git@git.commerce.gov:enterprise_applications/mbda8.git (push)
|
|
|
```
|
|
|
## Important note regarding Docker and Windows GFE
|
|
|
The organization does not currently support Docker on Windows GFE. This document needs to be updated to use a WAMP stack--or obtain permission to install Docker on Windows GFE.
|
|
|
|
|
|
Notes regarding setting up a non-Docker Drupal development environment on a Windows GFE:
|
|
|
1. Installed XAMPP
|
|
|
1. Installed MySQL 8.3 instead of using MariaDB w XAMPP
|
|
|
1. Created databases for Drupal from docker details in XAMPP
|
|
|
1. Installed Drupal 9.5.10 baseline
|
|
|
1. Enabled gd and opcache for PHP
|
|
|
1. Setup Drupal through UI
|
|
|
1. All successful
|
|
|
1. Forked from Master and pulled down the code repo
|
|
|
1. Got backups of Drupal DB
|
|
|
1. Imported database into baseline build of Drupal
|
|
|
1. Merged in code from web folder in repo to root folder on local
|
|
|
1. Broke Drupal.
|
|
|
1. Reinstalled advanced scheduler module
|
|
|
1. Required to install USWDS but unsuccessful because can't make it the base theme through command line and also can't install NPM due to permission restrictions
|
|
|
|
|
|
|
|
|
|
|
|
## Docker container setup
|
|
|
Combining the Drupal platform stack together a docker image is created and made available on [Dockerhub](https://hub.docker.com/r/docwebsolutions/doc_drupal) (This docker image is tested on Ubuntu, MAC, and Windows operating systems.)
|
|
|
|
|
|
# Instructions to start working based on this Docker image, to create a Docker Container for Drupal project:
|
|
|
## Pre-requisites:
|
|
|
1. MAC or Windows Machine with `git` installed.
|
|
|
1. Docker-CE installed from https://docs.docker.com/desktop/
|
|
|
1. Create a `docker` directory in the same level of above mentioned mbda8 forked directory, which was created in step 2 above.
|
|
|
1. Inside your `docker` directory, create a `mbda_d9.yml` file with the following code (be sure to correct the path to your local MBDA Drupal 9 codebase in the first part of Line 9).
|
|
|
|
|
|
```
|
|
|
version: "3"
|
|
|
services:
|
|
|
########################################
|
|
|
# MBDA D9 #
|
|
|
########################################
|
|
|
mbda01:
|
|
|
image: docwebsolutions/doc_drupal:php8.1-v4.1
|
|
|
volumes:
|
|
|
- [path to your MBDA code base locally]:/var/www/docker_platform:delegated
|
|
|
# - /path/to/.ssh:/root/.ssh:ro
|
|
|
entrypoint: /root/entrypoint.sh --dbusername=mbdadbuser01 --dbpassword=admin01 --dbname=mbdadb01 --dbhost=db --dbport=3306 --project=mbda --sitemail=admin@example.com --accountmail=admin@example.com --adminpassword=admin --drupalversion=9 --mariadbpassword=admin
|
|
|
ports:
|
|
|
- 443
|
|
|
- 80
|
|
|
depends_on:
|
|
|
- db
|
|
|
links:
|
|
|
- db
|
|
|
|
|
|
#############################################################
|
|
|
## External Services ##
|
|
|
#############################################################
|
|
|
db:
|
|
|
image: mariadb
|
|
|
restart: always
|
|
|
environment:
|
|
|
MYSQL_ROOT_PASSWORD: admin
|
|
|
portainer:
|
|
|
image: portainer/portainer
|
|
|
ports:
|
|
|
- 9000
|
|
|
volumes:
|
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
|
command: -H unix:///var/run/docker.sock --no-auth
|
|
|
#############################################################
|
|
|
```
|
|
|
|
|
|
* Line 3: Name of your container
|
|
|
* Line 6: Name of our DocDrupal9 docker image
|
|
|
* Line 7: Local path to your mbda_d9 code base: location of mounted docker container
|
|
|
* Line 9: Site-specific details: DB name, install profile we use for our MBDA D8 installations
|
|
|
* Line 12: Localhost to access the site after install (e.g. https://localhost:8085)
|
|
|
|
|
|
## Site installation via Docker
|
|
|
1. Navigate to your `Sites/mbda_d9` repo and make sure that you are on your `master` branch using `git branch` command. You should be on your `[Master]` branch.
|
|
|
|
|
|
1. Run the following Docker command to install your new local mbda D8 site:
|
|
|
`docker-compose -f mbda_d9.yml up -d`
|
|
|
|
|
|
1. Wait 5-10 minutes for site install to complete.
|
|
|
Other useful Docker commands:
|
|
|
`docker ps` (shows the full list of running containers)
|
|
|
`docker ps -a` (shows the full list of both running and stopped containers)
|
|
|
|
|
|
1. Visit https://localhost:8085 to confirm your site is up and running.
|
|
|
|
|
|
## Post site installation
|
|
|
1. Based on our use of the Configuration Split module, activate our “dev” configuration split on your local install by adding the following lines of code to your settings.php file `web/sites/default/settings.php` (need to use sudo to edit and save changes)
|
|
|
|
|
|
```php
|
|
|
$config['config_split.config_split.dev']['status']= TRUE;
|
|
|
$config['config_split.config_split.prod']['status']= FALSE;
|
|
|
$config['config_split.config_split.qa_and_feature']['status']= FALSE;
|
|
|
```
|
|
|
|
|
|
1. Login to local site at https://localhost:8085/user (username: admin; pw: admin)
|
|
|
|
|
|
1. Rebuild permissions if asked and flush the cache.
|
|
|
|
|
|
1. Import menu at `/admin/config/development/menu_export/import`. Flush cache.
|
|
|
|
|
|
1. Navigate to `/admin/config/development/configuration` and import “dev” split configuration (e.g. Devel module config)
|
|
|
|
|
|
## Setting up NPM to use for SASS/USWDS
|
|
|
|
|
|
1. Install both `node.js` and `npm` on with either of the instructions below
|
|
|
* https://treehouse.github.io/installation-guides/mac/node-mac.html
|
|
|
* or here: npm is installed with Node.js. Pretty straight forward link to install node and npm
|
|
|
https://www.npmjs.com/get-npm
|
|
|
1. In the command line, change directory to the subtheme directory (e.g. `/web/themes/mbda`)
|
|
|
1. Run the command: `npm install`
|
|
|
1. After NPM installs, you should be able to run `npm run build` to have it watch for changes and automatically compile
|
|
|
|
|
|
**Important note:**
|
|
|
If the latest versions of `npm` and `node` do not work, please use the following:
|
|
|
* node 12.18.2
|
|
|
* npm 6.14.8
|
|
|
|
|
|
## Optional Task: Set up local portainer
|
|
|
|
|
|
See [wiki instructions here](https://git.commerce.gov/enterprise_applications/documentation/wikis/home/portainer#set-up-portainer-on-your-local) |
|
|
\ No newline at end of file |