recipe_1_ADD_Angular_Drupal_DDEV 4.92 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
# -*- ENCODING: UTF-8 -*-

#
#-----------------------------------------------------------
# 
# Installing Complete  Environment 
# [David Rodríguez Vicente, @davidjguru] [davidjguru@gmail.com]
# Title: Drupal Installer
# Description: Download and install a Drupal codebase project inside a new environment based in docker - ddev. 
#
# davidjguru@gmail.com
#-----------------------------------------------------------
#

# Preparations 
echo -e "   \e[1;4;31mWelcome to the Docker Installer\e[0m"

## Search for docker packages previously installed 
echo -e "   \e[1;4;31mNow, we gotta search for installed docker packages: \e[0m"
apt list --installed |grep docker

## Uninstall the existing packages and stop Apache Server in Host
echo -e "   \e[1;4;31mAnd now uninstall all the docker packages: \e[0m"
David Rodríguez's avatar
David Rodríguez committed
25
sudo apt remove docker.io docker-ce docker-ce-cli docker-compose -y
26
27
28
29
30
31
32
33
34
35
sudo /etc/init.d/apache2 stop

## Confirm the uninstall
echo -e "   \e[1;4;31mConfirm the uninstall looking for the packages: \e[0m"
apt list --installed |grep docker 

# Installing resources 

## Update the list of packages
echo -e "   \e[1;4;31mUpdate the package list: \e[0m"
David Rodríguez's avatar
David Rodríguez committed
36
sudo apt  update
37
38
39

## Install prerequisite packages
echo -e "   \e[1;4;31mInstall previous packages: \e[0m"
David Rodríguez's avatar
David Rodríguez committed
40
sudo apt install -y build-essential apt-transport-https ca-certificates jq curl software-properties-common file
41
42
43

## Install docker
echo -e "   \e[1;4;31mInstalling docker resources: \e[0m"
44
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
45
46
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
David Rodríguez's avatar
David Rodríguez committed
47
sudo apt install -y docker-ce
48
sudo chmod 666 /var/run/docker*
49
50
echo -e "   \e[1;4;31mDocker has been installed in your system. Currently Docker is: \e[0m"
### Test if docker is running or not
51
systemctl is-active docker
52
53
54
55
56
57
58
59
60

## Install Docker Compose
echo -e "   \e[1;4;31mNow, install Docker - Compose: \e[0m"
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
DESTINATION=/usr/local/bin/docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o $DESTINATION
sudo chmod 755 $DESTINATION
echo -e "   \e[1;4;31mDocker Compose has been installed in your system.\e[0m"
docker-compose --version
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
echo -e "   \e[1;4;31mEnd of the Docker Initial installation \e[0m"

# Configure DDEV 

## Installing Linuxbrew
echo -e "   \e[1;4;31mNow, we're go to get Linuxbrew: \e[0m"
yes | sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
yes | test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
yes | test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
yes | test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile 

## Install ddev or update if exists  
echo -e "   \e[1;4;31mInstalling ddev in your sistem: \e[0m"
brew tap drud/ddev && brew install ddev
brew upgrade ddev

## Get the keyname of the project
echo -e "   \e[1;4;31mWrite your project name: \e[0m"
read -p $'   \e[1;36mKeyname of the project:\e[0m ' varkeyname
varkeyname=${varkeyname:-d8deploy}

# Build the Drupal project 

## Build a new Drupal-based project using ddev
86
87
echo -e "    \e[1;4;31mGo to build the Drupal codebase: \e[0m"
mkdir $varkeyname && cd $varkeyname && ddev config --project-type php --php-version 7.3 && ddev composer create drupal-composer/drupal-project:8.x-dev --stability dev --no-interaction && ddev config --project-type drupal8 && ddev exec drush site-install standard --site-name=$varkeyname --account-name=admin --account-pass=admin --account-mail=mail@example.com --yes && ddev start
88
89
90
91
92
93
94
95
96
97
98
99
100

## Install and enable some Basic Drupal Modules ready for work: devel, masquerade, admin_toolbar and webprofiler
echo -e "    \e[1;4;31mNow with a new Drupal, we want some basic modules: \e[0m"
ddev composer require drupal/devel drupal/masquerade drupal/admin_toolbar
ddev exec drush en devel masquerade admin_toolbar webprofiler
ddev exec drush cr
echo -e "    \e[1;4;31mBrowser will open Drupal in a new tab, but we're still here: \e[0m"
sensible-browser http://$varkeyname.ddev.local

# Install other resources 

## Install packages in the new system
echo -e "    \e[1;4;31mIn this block, we'll install some packages like sqlite, git-flow and others: \e[0m"
David Rodríguez's avatar
David Rodríguez committed
101
102
ddev exec sudo apt update
ddev exec sudo apt install -y sqlite3 git-flow
103
104
105
106

## Installing node, npm and Angular
echo -e "    \e[1;4;31mInstalling node, npm and Angular in our new system: \e[0m"
ddev exec curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash
David Rodríguez's avatar
David Rodríguez committed
107
ddev exec sudo apt install -y nodejs
108
109
110
111
112
113
ddev exec node -v
ddev exec npm -v
ddev exec sudo npm install @angular/cli -g
ddev exec ng version
echo -e "    \e[1;4;31mThe whole  installation has been completed, see you inside the new container...Happy Hacking!!! \e[0m"
ddev ssh