Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use /var/www/html rather than /opt/drupal to avoid breaking downstream projects after https://github.com/docker-library/drupal/pull/176 #13

Merged
merged 7 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions Dockerfile-8
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
FROM drupal:8

RUN curl -sS https://getcomposer.org/installer | php && \
mv composer.phar /usr/local/bin/composer && \
composer global require drush/drush:~8 && \
ln -s /root/.composer/vendor/drush/drush/drush /bin/drush && \
apt-get update && \
apt-get install -y --no-install-recommends mariadb-client git zip && \
rm -rf /var/lib/apt/lists/* && \
mkdir /var/www/latest-drupal && \
cd /var/www/latest-drupal && drush dl && \
cp -r /var/www/latest-drupal/drupal-*/* /var/www/html
COPY docker-resources/8/composer.json /composer-file/composer.json

# See "/var/www/html vs /opt/drupal" in ./README.md
# This code exists in ./Dockerfile-8, ./Dockerfile-8drush, ./Dockerfile-9
RUN rm /var/www/html && \
rm -rf /opt/drupal && \
mkdir /var/www/html
WORKDIR /var/www/html
RUN mv /composer-file/composer.json /var/www/html/composer.json && \
chown www-data:www-data /var/www/html && \
apt-get update && \
apt-get install -y --no-install-recommends mariadb-client git unzip && \
rm -rf /var/lib/apt/lists/* && \
export COMPOSER_MEMORY_LIMIT=-1 && \
composer install && \
cat /var/www/html/core/lib/Drupal.php|grep VERS && \
ln -s /var/www/html/vendor/bin/drush /bin/drush && \
drush -v

EXPOSE 80
20 changes: 12 additions & 8 deletions Dockerfile-8drush
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
FROM drupal:8

RUN curl -sS https://getcomposer.org/installer | php && \
mv composer.phar /usr/local/bin/composer && \
COPY docker-resources/8drush/composer.json /composer-file/composer.json

# See "/var/www/html vs /opt/drupal" in ./README.md
# This code exists in ./Dockerfile-8, ./Dockerfile-8drush, ./Dockerfile-9
RUN rm /var/www/html && \
rm -rf /opt/drupal && \
mkdir /var/www/html
WORKDIR /var/www/html
RUN mv /composer-file/composer.json /var/www/html/composer.json && \
chown www-data:www-data /var/www/html && \
apt-get update && \
apt-get install -y --no-install-recommends mariadb-client git unzip && \
rm -rf /var/lib/apt/lists/*

COPY docker-resources/8drush/composer.json /opt/drupal/composer.json

RUN rm composer.lock && \
rm -rf /var/lib/apt/lists/* && \
export COMPOSER_MEMORY_LIMIT=-1 && \
composer install && \
cat /var/www/html/core/lib/Drupal.php|grep VERS && \
ln -s /opt/drupal/vendor/bin/drush /bin/drush && \
ln -s /var/www/html/vendor/bin/drush /bin/drush && \
drush -v

EXPOSE 80
20 changes: 12 additions & 8 deletions Dockerfile-8drush9
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
FROM drupal:8

RUN curl -sS https://getcomposer.org/installer | php && \
mv composer.phar /usr/local/bin/composer && \
COPY docker-resources/8drush9/composer.json /composer-file/composer.json

# See "/var/www/html vs /opt/drupal" in ./README.md
# This code exists in ./Dockerfile-8, ./Dockerfile-8drush, ./Dockerfile-9
RUN rm /var/www/html && \
rm -rf /opt/drupal && \
mkdir /var/www/html
WORKDIR /var/www/html
RUN mv /composer-file/composer.json /var/www/html/composer.json && \
chown www-data:www-data /var/www/html && \
apt-get update && \
apt-get install -y --no-install-recommends mariadb-client git unzip && \
rm -rf /var/lib/apt/lists/*

COPY docker-resources/8drush9/composer.json /opt/drupal/composer.json

RUN rm composer.lock && \
rm -rf /var/lib/apt/lists/* && \
export COMPOSER_MEMORY_LIMIT=-1 && \
composer install && \
cat /var/www/html/core/lib/Drupal.php|grep VERS && \
ln -s /opt/drupal/vendor/bin/drush /bin/drush && \
ln -s /var/www/html/vendor/bin/drush /bin/drush && \
drush -v

EXPOSE 80
20 changes: 12 additions & 8 deletions Dockerfile-9
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
FROM drupal:8

RUN curl -sS https://getcomposer.org/installer | php && \
mv composer.phar /usr/local/bin/composer && \
COPY docker-resources/9/composer.json /composer-file/composer.json

# See "/var/www/html vs /opt/drupal" in ./README.md
# This code exists in ./Dockerfile-8, ./Dockerfile-8drush, ./Dockerfile-9
RUN rm /var/www/html && \
rm -rf /opt/drupal && \
mkdir /var/www/html
WORKDIR /var/www/html
RUN mv /composer-file/composer.json /var/www/html/composer.json && \
chown www-data:www-data /var/www/html && \
apt-get update && \
apt-get install -y --no-install-recommends mariadb-client git unzip && \
rm -rf /var/lib/apt/lists/*

COPY docker-resources/9/composer.json /opt/drupal/composer.json

RUN rm composer.lock && \
rm -rf /var/lib/apt/lists/* && \
export COMPOSER_MEMORY_LIMIT=-1 && \
composer install && \
cat /var/www/html/core/lib/Drupal.php|grep VERS && \
ln -s /opt/drupal/vendor/bin/drush /bin/drush && \
ln -s /var/www/html/vendor/bin/drush /bin/drush && \
drush -v

EXPOSE 80
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ The jenkins schedule is:

See [this image on the Docker Hub](https://hub.docker.com/r/dcycle/drupal/).

/var/www/html vs /opt/drupal
-----

This project is based on [the "official" Drupal Docker image](https://hub.docker.com/_/drupal/), which, in [this pull request](https://github.com/docker-library/drupal/pull/176), changed the location of Drupal from /var/www/html to /opt/drupal (with a symlink from /var/www/html).

This causes various issues with downstream projects which depend on the dcycle/drupal image (tags 8drush, 8drush9 and 9 only, not 7 and 8); it has therefore been decided that for the dcycle/drupal, Drupal would remain in /var/www/html, rather than be in /opt/drupal.

Thus, in ./Dockerfile-8drush, ./Dockerfile-8drush9 and ./Dockerfile-9, [code was added to completely remove /opt/drupal and /var/www/html, and reinstall with our own composer.json files at ./docker-resources/*/composer.json](https://github.com/dcycle/docker-drupal/pull/13).

Docker tags
-----

Expand Down
72 changes: 72 additions & 0 deletions docker-resources/8/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "drupal/recommended-project",
"description": "Project template for Drupal 8 projects with a relocated document root",
"type": "project",
"license": "GPL-2.0-or-later",
"homepage": "https://www.drupal.org/project/drupal",
"support": {
"docs": "https://www.drupal.org/docs/user_guide/en/index.html",
"chat": "https://www.drupal.org/node/314178"
},
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"drush/drush": "~8",
"composer/installers": "^1.2",
"drupal/core-vendor-hardening": "^8.8",
"drupal/core-composer-scaffold": "^8.8",
"drupal/core-project-message": "^8.8",
"drupal/core-recommended": "^8.8"
},
"require-dev": {
"drupal/core-dev": "^8.8"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true
},
"extra": {
"drupal-scaffold": {
"locations": {
"web-root": "."
}
},
"installer-paths": {
"./core": ["type:drupal-core"],
"./libraries/{$name}": ["type:drupal-library"],
"./modules/contrib/{$name}": ["type:drupal-module"],
"./profiles/contrib/{$name}": ["type:drupal-profile"],
"./themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/contrib/{$name}": ["type:drupal-drush"],
"./modules/custom/{$name}": ["type:drupal-custom-module"],
"./themes/custom/{$name}": ["type:drupal-custom-theme"]
},
"drupal-core-project-message": {
"include-keys": ["homepage", "support"],
"post-create-project-cmd-message": [
"<bg=blue;fg=white> </>",
"<bg=blue;fg=white> Congratulations, you’ve installed the Drupal codebase </>",
"<bg=blue;fg=white> from the drupal/recommended-project template! </>",
"<bg=blue;fg=white> </>",
"",
"<bg=yellow;fg=black>Next steps</>:",

" * Install the site: https://www.drupal.org/docs/8/install",
" * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
" * Get support: https://www.drupal.org/support",
" * Get involved with the Drupal community:",
" https://www.drupal.org/getting-involved",
" * Remove the plugin that prints this message:",
" composer remove drupal/core-project-message"
]
}
}
}
2 changes: 1 addition & 1 deletion docker-resources/8drush/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"extra": {
"drupal-scaffold": {
"locations": {
"web-root": "./web/"
"web-root": "."
}
},
"installer-paths": {
Expand Down
2 changes: 1 addition & 1 deletion docker-resources/8drush9/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"extra": {
"drupal-scaffold": {
"locations": {
"web-root": "./web/"
"web-root": "."
}
},
"installer-paths": {
Expand Down
2 changes: 1 addition & 1 deletion docker-resources/9/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"extra": {
"drupal-scaffold": {
"locations": {
"web-root": "./web/"
"web-root": "."
}
},
"installer-paths": {
Expand Down
3 changes: 1 addition & 2 deletions scripts/lib/smoke-test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
IMAGE="$1"
DIR="$2"

echo "*************"
echo "** SMOKE TEST ON IMAGE $1"
Expand All @@ -10,4 +9,4 @@ docker run --rm "$IMAGE" /bin/bash -c 'pwd'
echo ' => listing contents'
docker run --rm "$IMAGE" /bin/bash -c 'ls -lah'
echo ' => make sure .htaccess exists'
docker run --rm "$IMAGE" /bin/bash -c "ls -lah $DIR | grep .htaccess"
docker run --rm "$IMAGE" /bin/bash -c "ls -lah | grep .htaccess"
10 changes: 5 additions & 5 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ docker build -f="Dockerfile-8drush" -t test-drupal-8drush .
echo "Testing Dockerfile-9"
docker build -f="Dockerfile-9" -t test-drupal-9 .

source ./scripts/lib/smoke-test.sh test-drupal-7 .
source ./scripts/lib/smoke-test.sh test-drupal-8 .
source ./scripts/lib/smoke-test.sh test-drupal-8drush9 web
source ./scripts/lib/smoke-test.sh test-drupal-8drush web
source ./scripts/lib/smoke-test.sh test-drupal-9 web
source ./scripts/lib/smoke-test.sh test-drupal-7
source ./scripts/lib/smoke-test.sh test-drupal-8
source ./scripts/lib/smoke-test.sh test-drupal-8drush9
source ./scripts/lib/smoke-test.sh test-drupal-8drush
source ./scripts/lib/smoke-test.sh test-drupal-9