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
Show whitespace changes
Inline
Side-by-side
Dockerfile
View file @
f8e0d2c5
FROM
ubuntu:20.04
FROM
ubuntu:20.04
MAINTAINER
Ricardo Amaro <mail_at_ricardoamaro.com>
MAINTAINER
Ricardo Amaro <mail_at_ricardoamaro.com>
ENV
DEBIAN_FRONTEND noninteractive
ENV
DEBIAN_FRONTEND noninteractive
ARG
DRUPALVER=9
ENV
DRUPALVER=9
RUN
apt-get update
;
\
RUN
apt-get update
;
\
dpkg-divert
--local
--rename
--add
/sbin/initctl
;
\
dpkg-divert
--local
--rename
--add
/sbin/initctl
;
\
...
...
files/start.sh
View file @
f8e0d2c5
...
@@ -4,10 +4,10 @@ export BASEHTML="/var/www/html"
...
@@ -4,10 +4,10 @@ export BASEHTML="/var/www/html"
export
DOCROOT
=
"/var/www/html/web"
export
DOCROOT
=
"/var/www/html/web"
export
GRPID
=
$(
stat
-c
"%g"
/var/lib/mysql/
)
export
GRPID
=
$(
stat
-c
"%g"
/var/lib/mysql/
)
export
DRUSH
=
"
${
DOCROOT
}
/vendor/bin/drush"
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
HOSTIP
=
$(
/sbin/ip route |
awk
'/default/ { print $3 }'
)
export
DRUPALVER
=
9.1.x
export
DRUPALVER
=
${
DRUPALVER
:-
'9'
}
echo
"
${
HOSTIP
}
dockerhost"
>>
/etc/hosts
echo
"
${
HOSTIP
}
dockerhost"
>>
/etc/hosts
echo
"Started Container:
$(
date
)
"
echo
"Started Container:
$(
date
)
"
# Create a basic mysql install
# Create a basic mysql install
...
@@ -24,14 +24,17 @@ supervisord -c /etc/supervisor/conf.d/supervisord.conf -l /tmp/supervisord.log
...
@@ -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 there is no index.php, download drupal
if
[
!
-f
${
DOCROOT
}
/index.php
]
;
then
if
[
!
-f
${
DOCROOT
}
/index.php
]
;
then
echo
"**** No Drupal found. Downloading latest to
${
DOCROOT
}
/ ****"
echo
"**** No Drupal found. Downloading latest to
${
DOCROOT
}
/ ****"
cd
${
BASEHTML
}
;
cd
${
BASEHTML
}
# ${DRUSH} -vy dl drupal --default-major=${DRUPALVER} --drupal-project-rename="web"
# Get the latest version number
git clone
--depth
1
--single-branch
-b
${
DRUPALVER
}
\
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
)
https://git.drupalcode.org/project/drupal.git web
;
git clone
--depth
1
--single-branch
-b
${
DV
}
\
https://git.drupalcode.org/project/drupal.git web
# TODO: also require drupal/memcache
# TODO: also require drupal/memcache
cd
web
;
composer require drush/drush:~10
;
composer
install
cd
web
chmod
a+w
${
DOCROOT
}
/sites/default
;
composer require drush/drush:~10
mkdir
${
DOCROOT
}
/sites/default/files
;
composer
install
chmod
a+w
${
DOCROOT
}
/sites/default
mkdir
${
DOCROOT
}
/sites/default/files
wget
"http://www.adminer.org/latest.php"
-O
${
DOCROOT
}
/adminer.php
wget
"http://www.adminer.org/latest.php"
-O
${
DOCROOT
}
/adminer.php
chown
-R
www-data:
${
GRPID
}
${
DOCROOT
}
chown
-R
www-data:
${
GRPID
}
${
DOCROOT
}
chmod
-R
ug+w
${
DOCROOT
}
chmod
-R
ug+w
${
DOCROOT
}
...
@@ -40,23 +43,24 @@ else
...
@@ -40,23 +43,24 @@ else
fi
fi
# Setup Drupal if services.yml or settings.php is missing
# 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
# Generate random passwords
DRUPAL_DB
=
"drupal"
DRUPAL_DB
=
"drupal"
DEBPASS
=
$(
grep
password /etc/mysql/debian.cnf |head
-n1
|
awk
'{print $3}'
)
DEBPASS
=
$(
grep
password /etc/mysql/debian.cnf |
head
-n1
|
awk
'{print $3}'
)
ROOT_PASSWORD
=
`
pwgen
-c
-n
-1
12
`
ROOT_PASSWORD
=
$(
pwgen
-c
-n
-1
12
)
DRUPAL_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
${
ROOT_PASSWORD
}
>
/var/lib/mysql/mysql/mysql-root-pw.txt
echo
${
DRUPAL_PASSWORD
}
>
/var/lib/mysql/mysql/drupal-db-pw.txt
echo
${
DRUPAL_PASSWORD
}
>
/var/lib/mysql/mysql/drupal-db-pw.txt
# Wait for mysql
# Wait for mysql
echo
-n
"Waiting for mysql "
echo
-n
"Waiting for mysql "
while
!
mysqladmin status
>
/dev/null 2>&1
;
do
while
!
mysqladmin status
>
/dev/null 2>&1
;
do
echo
-n
.
;
sleep
1
;
echo
-n
.
done
;
sleep
1
echo
;
done
echo
# Create and change MySQL creds
# Create and change MySQL creds
mysqladmin
-u
root password
${
ROOT_PASSWORD
}
2>/dev/null
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
\
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';
GRANT ALL ON *.* TO 'debian-sys-maint'@'localhost';
...
@@ -85,7 +89,10 @@ chmod -R ug+w ${DOCROOT}/sites/default/
...
@@ -85,7 +89,10 @@ chmod -R ug+w ${DOCROOT}/sites/default/
chown
-R
mysql:
${
GRPID
}
/var/lib/mysql/
chown
-R
mysql:
${
GRPID
}
/var/lib/mysql/
chmod
-R
ug+w /var/lib/mysql/
chmod
-R
ug+w /var/lib/mysql/
find
-type
d
-exec
chmod
+xr
{}
\;
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
echo
"---------------------- USERS CREDENTIALS (
$(
date
+%T
)
) -------------------------------"
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