Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Marcelo Silva
drupal9-docker-app
Commits
f8e0d2c5
Commit
f8e0d2c5
authored
Aug 08, 2021
by
Ricardo Amaro
Browse files
Drupal 9 version always stable
parent
a23c4dfb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Dockerfile
View file @
f8e0d2c5
FROM
ubuntu:20.04
MAINTAINER
Ricardo Amaro <mail_at_ricardoamaro.com>
ENV
DEBIAN_FRONTEND noninteractive
ARG
DRUPALVER=9
ENV
DRUPALVER=9
RUN
apt-get update
;
\
dpkg-divert
--local
--rename
--add
/sbin/initctl
;
\
...
...
files/start.sh
View file @
f8e0d2c5
...
...
@@ -4,10 +4,10 @@ export BASEHTML="/var/www/html"
export
DOCROOT
=
"/var/www/html/web"
export
GRPID
=
$(
stat
-c
"%g"
/var/lib/mysql/
)
export
DRUSH
=
"
${
DOCROOT
}
/vendor/bin/drush"
export
LOCAL_IP
=
$(
hostname
-I
|
awk
'{print $1}'
)
export
LOCAL_IP
=
$(
hostname
-I
|
awk
'{print $1}'
)
export
HOSTIP
=
$(
/sbin/ip route |
awk
'/default/ { print $3 }'
)
export
DRUPALVER
=
9.1.x
echo
"
${
HOSTIP
}
dockerhost"
>>
/etc/hosts
export
DRUPALVER
=
${
DRUPALVER
:-
'9'
}
echo
"
${
HOSTIP
}
dockerhost"
>>
/etc/hosts
echo
"Started Container:
$(
date
)
"
# Create a basic mysql install
...
...
@@ -24,14 +24,17 @@ supervisord -c /etc/supervisor/conf.d/supervisord.conf -l /tmp/supervisord.log
# If there is no index.php, download drupal
if
[
!
-f
${
DOCROOT
}
/index.php
]
;
then
echo
"**** No Drupal found. Downloading latest to
${
DOCROOT
}
/ ****"
cd
${
BASEHTML
}
;
# ${DRUSH} -vy dl drupal --default-major=${DRUPALVER} --drupal-project-rename="web"
git clone
--depth
1
--single-branch
-b
${
DRUPALVER
}
\
https://git.drupalcode.org/project/drupal.git web
;
cd
${
BASEHTML
}
# Get the latest version number
DV
=
$(
curl
-s
https://git.drupalcode.org/project/drupal/-/tags?format
=
atom |
grep
-e
'<title>'
|
grep
-Eo
'[0-9\.]+'
|
sort
-nr
|
grep
^
${
DRUPALVER
}
|
head
-n1
)
git clone
--depth
1
--single-branch
-b
${
DV
}
\
https://git.drupalcode.org/project/drupal.git web
# TODO: also require drupal/memcache
cd
web
;
composer require drush/drush:~10
;
composer
install
chmod
a+w
${
DOCROOT
}
/sites/default
;
mkdir
${
DOCROOT
}
/sites/default/files
;
cd
web
composer require drush/drush:~10
composer
install
chmod
a+w
${
DOCROOT
}
/sites/default
mkdir
${
DOCROOT
}
/sites/default/files
wget
"http://www.adminer.org/latest.php"
-O
${
DOCROOT
}
/adminer.php
chown
-R
www-data:
${
GRPID
}
${
DOCROOT
}
chmod
-R
ug+w
${
DOCROOT
}
...
...
@@ -40,25 +43,26 @@ else
fi
# Setup Drupal if services.yml or settings.php is missing
if
(
!
grep
-q
'database.*=>.*drupal'
${
DOCROOT
}
/sites/default/settings.php 2>/dev/null
)
;
then
if
(!
grep
-q
'database.*=>.*drupal'
${
DOCROOT
}
/sites/default/settings.php 2>/dev/null
)
;
then
# Generate random passwords
DRUPAL_DB
=
"drupal"
DEBPASS
=
$(
grep
password /etc/mysql/debian.cnf |head
-n1
|
awk
'{print $3}'
)
ROOT_PASSWORD
=
`
pwgen
-c
-n
-1
12
`
DRUPAL_PASSWORD
=
`
pwgen
-c
-n
-1
12
`
echo
${
ROOT_PASSWORD
}
>
/var/lib/mysql/mysql/mysql-root-pw.txt
echo
${
DRUPAL_PASSWORD
}
>
/var/lib/mysql/mysql/drupal-db-pw.txt
DEBPASS
=
$(
grep
password /etc/mysql/debian.cnf |
head
-n1
|
awk
'{print $3}'
)
ROOT_PASSWORD
=
$(
pwgen
-c
-n
-1
12
)
DRUPAL_PASSWORD
=
$(
pwgen
-c
-n
-1
12
)
echo
${
ROOT_PASSWORD
}
>
/var/lib/mysql/mysql/mysql-root-pw.txt
echo
${
DRUPAL_PASSWORD
}
>
/var/lib/mysql/mysql/drupal-db-pw.txt
# Wait for mysql
echo
-n
"Waiting for mysql "
while
!
mysqladmin status
>
/dev/null 2>&1
;
do
echo
-n
.
;
sleep
1
;
done
;
echo
;
echo
-n
.
sleep
1
done
echo
# Create and change MySQL creds
mysqladmin
-u
root password
${
ROOT_PASSWORD
}
2>/dev/null
echo
-e
"[client]
\n
password=
${
ROOT_PASSWORD
}
\n
"
>
/root/.my.cnf
echo
-e
"[client]
\n
password=
${
ROOT_PASSWORD
}
\n
"
>
/root/.my.cnf
mysql
-e
\
"CREATE USER 'debian-sys-maint'@'localhost' IDENTIFIED WITH mysql_native_password BY '
${
DEBPASS
}
';
"CREATE USER 'debian-sys-maint'@'localhost' IDENTIFIED WITH mysql_native_password BY '
${
DEBPASS
}
';
GRANT ALL ON *.* TO 'debian-sys-maint'@'localhost';
CREATE DATABASE drupal;
CREATE USER 'drupal'@'%' IDENTIFIED WITH mysql_native_password BY '
${
DRUPAL_PASSWORD
}
';
...
...
@@ -67,8 +71,8 @@ if ( ! grep -q 'database.*=>.*drupal' ${DOCROOT}/sites/default/settings.php 2>/d
cd
${
DOCROOT
}
cp
sites/default/default.settings.php sites/default/settings.php
${
DRUSH
}
site-install standard
-y
--account-name
=
admin
--account-pass
=
admin
\
--db-url
=
"mysql://drupal:
${
DRUPAL_PASSWORD
}
@localhost:3306/drupal"
\
--site-name
=
"Drupal9 docker App"
|
grep
-v
'continue?'
2>/dev/null
--db-url
=
"mysql://drupal:
${
DRUPAL_PASSWORD
}
@localhost:3306/drupal"
\
--site-name
=
"Drupal9 docker App"
|
grep
-v
'continue?'
2>/dev/null
#${DRUSH} -y en memcache | grep -v 'continue?' | grep -v error 2>/dev/null
else
echo
"****
${
DOCROOT
}
/sites/default/settings.php database found ****"
...
...
@@ -85,7 +89,10 @@ chmod -R ug+w ${DOCROOT}/sites/default/
chown
-R
mysql:
${
GRPID
}
/var/lib/mysql/
chmod
-R
ug+w /var/lib/mysql/
find
-type
d
-exec
chmod
+xr
{}
\;
(
sleep
3
;
drush
--root
=
${
DOCROOT
}
/ cache-rebuild 2>/dev/null
)
&
(
sleep
3
drush
--root
=
${
DOCROOT
}
/ cache-rebuild 2>/dev/null
)
&
echo
echo
"---------------------- USERS CREDENTIALS (
$(
date
+%T
)
) -------------------------------"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment