Move codebase to /opt/drupal, symlink /var/www/html to /opt/drupal/web, don't override Apache document root. All to mimic upstream drupal:9 image.

This commit is contained in:
Michael Stenta 2020-08-11 20:01:12 -04:00
parent 78b94b9f02
commit ef09c1fd82
8 changed files with 18 additions and 19 deletions

View File

@ -21,7 +21,7 @@ jobs:
- name: Build farmOS 2.x Docker image
run: docker build --build-arg FARMOS_REPO=https://github.com/${GITHUB_REPOSITORY} --build-arg FARMOS_VERSION=${FARMOS_VERSION} -t farmos/farmos:2.x docker
- name: Run farmOS Docker container
run: docker run --rm -v /tmp/farmOS:/var/www/html farmos/farmos:2.x true
run: docker run --rm -v /tmp/farmOS:/var/farmOS farmos/farmos:2.x true
- name: Create artifact
run: cd /tmp && tar -czf farmOS-${FARMOS_VERSION}.tar.gz farmOS
- name: Create GitHub release

View File

@ -13,7 +13,7 @@ FROM farmos/farmos:2.x-dev as build
FROM farmos/farmos:2.x-base
# Copy prebuilt codebase into the container.
# We copy both /var/farmOS and /var/www/html so that docker-entrypoint.sh
# We copy both /var/farmOS and /opt/drupal so that docker-entrypoint.sh
# can replace files in mounted volumes as necessary.
COPY --from=build /var/farmOS/ /var/farmOS/
COPY --from=build /var/www/html/ /var/www/html/
COPY --from=build /opt/drupal/ /opt/drupal/

View File

@ -11,7 +11,7 @@ into a new directory on your server, rename it to `docker-compose.yml` and run
`docker-compose up`.
This example mounts a local `www` directory on the host as a volume in the
container at `/var/www/html`, which allows for local development with an IDE.
container at `/opt/drupal`, which allows for local development with an IDE.
## Production environment
@ -21,7 +21,7 @@ include a database. It is assumed that in production environments the database
will be managed outside of Docker.
This example mounts a local `sites` directory on the host as a volume in the
container at `/var/www/html/sites`, which contains the site-specific settings
container at `/opt/drupal/web/sites`, which contains the site-specific settings
and uploaded files. This allows a production farmOS instance to be updated by
simply pulling a new image (and then manually running database updates via Drush
or `/update.php`). Everything outside of the `sites` directory will not be

View File

@ -65,10 +65,9 @@ RUN apt-get update \
# Create a directory for the farmOS codebase.
RUN mkdir /var/farmOS && chown www-data:www-data /var/farmOS
# Configure Apache to use /var/www/html/web as the document root.
ENV APACHE_DOCUMENT_ROOT=/var/www/html/web
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \
&& sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Create /opt/drupal and symlink /var/www/html to /opt/drupal/web
# (to mimic upstream drupal:9 image).
RUN mkdir /opt/drupal && rm -r /var/www/html && ln -s /opt/drupal/web /var/www/html
# Set the entrypoint.
COPY docker-entrypoint.sh /usr/local/bin/

View File

@ -7,16 +7,16 @@ set -e
# populate them from the pre-built farmOS codebase in the image.
###
# If the /var/www/html directory is empty, populate it from pre-built files.
if [ -d /var/www/html ] && ! [ "$(ls -A /var/www/html/)" ]; then
# If the Drupal directory is empty, populate it from pre-built files.
if [ -d /opt/drupal ] && ! [ "$(ls -A /opt/drupal/)" ]; then
echo "farmOS codebase not detected. Copying from pre-built files in the Docker image."
cp -rp /var/farmOS/. /var/www/html
cp -rp /var/farmOS/. /opt/drupal
fi
# If the sites directory is empty, populate it from pre-built files.
if [ -d /var/www/html/web/sites ] && ! [ "$(ls -A /var/www/html/web/sites/)" ]; then
if [ -d /opt/drupal/web/sites ] && ! [ "$(ls -A /opt/drupal/web/sites/)" ]; then
echo "farmOS sites directory not detected. Copying from pre-built files in the Docker image."
cp -rp /var/farmOS/web/sites/. /var/www/html/web/sites
cp -rp /var/farmOS/web/sites/. /opt/drupal/web/sites
fi
# Execute the arguments passed into this script.

View File

@ -51,7 +51,7 @@ RUN cp web/core/phpunit.xml.dist phpunit.xml \
&& sed -i 's|bootstrap="tests/bootstrap.php"|bootstrap="web/core/tests/bootstrap.php"|g' phpunit.xml \
&& sed -i 's|name="SIMPLETEST_BASE_URL" value=""|name="SIMPLETEST_BASE_URL" value="http://localhost"|g' phpunit.xml \
&& sed -i 's|name="SIMPLETEST_DB" value=""|name="SIMPLETEST_DB" value="pgsql://farm:farm@db/farm"|g' phpunit.xml \
&& sed -i 's|name="BROWSERTEST_OUTPUT_DIRECTORY" value=""|name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/html/web/sites/simpletest/browser_output"|g' phpunit.xml \
&& sed -i 's|name="BROWSERTEST_OUTPUT_DIRECTORY" value=""|name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/html/sites/simpletest/browser_output"|g' phpunit.xml \
&& sed -i 's|\./|\./web/core/|g' phpunit.xml \
&& sed -i 's|\.\./web/core/|\./web/|g' phpunit.xml \
&& mkdir -p /var/farmOS/web/sites/simpletest/browser_output
@ -60,8 +60,8 @@ RUN cp web/core/phpunit.xml.dist phpunit.xml \
WORKDIR /var/www/html
USER root
# Copy /var/farmOS to /var/www/html.
RUN rm -r /var/www/html && cp -rp /var/farmOS /var/www/html
# Copy /var/farmOS to /opt/drupal.
RUN rm -r /opt/drupal && cp -rp /var/farmOS /opt/drupal
# Install and configure XDebug.
RUN yes | pecl install xdebug \

View File

@ -16,7 +16,7 @@ services:
- db
image: farmos/farmos:2.x-dev
volumes:
- './www:/var/www/html'
- './www:/opt/drupal'
ports:
- '80:80'
environment:

View File

@ -3,6 +3,6 @@ services:
www:
image: farmos/farmos:2.x
volumes:
- './sites:/var/www/html/web/sites'
- './sites:/opt/drupal/web/sites'
ports:
- '80:80'