Merge development image into a single Dockerfile
Changes based on PR review
This commit is contained in:
parent
53fd5ebbbb
commit
3774afee32
|
@ -48,7 +48,7 @@ jobs:
|
|||
# farmOS Composer project 3.x branch is always used.
|
||||
- name: Build and save farmOS dev Docker image
|
||||
run: |
|
||||
docker build --build-arg FARMOS_REPO=https://github.com/${FARMOS_REPO} --build-arg FARMOS_VERSION=${FARMOS_VERSION} -t farmos/farmos:3.x-dev docker/dev
|
||||
docker build --build-arg FARMOS_REPO=https://github.com/${FARMOS_REPO} --build-arg FARMOS_VERSION=${FARMOS_VERSION} -t farmos/farmos:3.x-dev --target dev docker
|
||||
docker save farmos/farmos:3.x-dev > /tmp/farmos-dev.tar
|
||||
- name: Cache farmOS dev Docker image
|
||||
uses: actions/cache@v3
|
||||
|
|
|
@ -4,7 +4,6 @@ FROM drupal:10.1 as baseimage
|
|||
# Define common paths.
|
||||
ENV FARMOS_PATH=/var/farmOS
|
||||
ENV DRUPAL_PATH=/opt/drupal
|
||||
ENV COMPOSER_HOME=${FARMOS_PATH}
|
||||
|
||||
##
|
||||
# Build PHP extensions, GEOS and bcmath.
|
||||
|
@ -38,6 +37,7 @@ ARG PROJECT_REPO=https://github.com/farmOS/composer-project/raw/${PROJECT_VERSIO
|
|||
ENV COMPOSER_MEMORY_LIMIT=-1
|
||||
# Allow root to install plugins.
|
||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||
ENV COMPOSER_NO_INTERACTION=1
|
||||
|
||||
# Install apt dependencies.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends\
|
||||
|
@ -62,7 +62,14 @@ RUN composer install --no-dev
|
|||
RUN sed -i "s|version: 3.x|version: ${FARMOS_VERSION}|g" ${FARMOS_PATH}/web/profiles/farm/farm.info.yml
|
||||
|
||||
##
|
||||
# Build final image.
|
||||
# Create layer with farmOS dev sources.
|
||||
FROM farmos-sources as farmos-dev-sources
|
||||
|
||||
# Install sources.
|
||||
RUN composer update
|
||||
|
||||
##
|
||||
# Dependencies layer.
|
||||
FROM baseimage as farmos-baseimage
|
||||
|
||||
# Set Apache ServerName directive globally to suppress AH00558 message.
|
||||
|
@ -76,11 +83,13 @@ RUN docker-php-ext-enable geos bcmath
|
|||
COPY conf.d/ /usr/local/etc/php/conf.d
|
||||
|
||||
# Install apt dependencies and clean up.
|
||||
RUN apt-get update && apt-get install -y \
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends\
|
||||
# Install postgresql-client so Drush can connect to the database.
|
||||
postgresql-client \
|
||||
# Install libgeos-c1v5 so geos php extension can use libgeos_c.so.1.
|
||||
libgeos-c1v5 \
|
||||
# Install git and unzip (needed by Composer).
|
||||
git unzip \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& apt-get clean \
|
||||
# Clean up ${DRUPAL_PATH}.
|
||||
|
@ -95,6 +104,35 @@ WORKDIR ${DRUPAL_PATH}
|
|||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
CMD ["apache2-foreground"]
|
||||
|
||||
##
|
||||
# Development image.
|
||||
FROM farmos-baseimage as dev
|
||||
|
||||
# Change the user/group IDs of www-data inside the image to match the ID of the
|
||||
# developer's user on the host machine. This allows Composer to create files
|
||||
# owned by www-data inside the container, while keeping those files editable by
|
||||
# the developer outside of the container.
|
||||
# This defaults to 1000, based on the assumption that the developer is running
|
||||
# as UID 1000 on the host machine. It can be overridden at image build time with:
|
||||
# --build-arg WWW_DATA_ID=$(id -u)
|
||||
ARG WWW_DATA_ID=1000
|
||||
RUN usermod -u ${WWW_DATA_ID} www-data && groupmod -g ${WWW_DATA_ID} www-data
|
||||
|
||||
# Install and configure XDebug.
|
||||
RUN yes | pecl install xdebug \
|
||||
&& docker-php-ext-enable xdebug
|
||||
|
||||
# Add opcache revalidation frequency configuration.
|
||||
COPY dev/conf.d/ /usr/local/etc/php/conf.d
|
||||
|
||||
# Add Configurations for PHP CodeSniffer, PHPStan
|
||||
COPY --chown=www-data:www-data ./dev/files/ ${FARMOS_PATH}
|
||||
|
||||
# Add farmOS dev sources.
|
||||
COPY --from=farmos-dev-sources --chown=www-data:www-data ${FARMOS_PATH} ${FARMOS_PATH}
|
||||
|
||||
# Configure PHPUnit.
|
||||
RUN ${FARMOS_PATH}/phpunit.sh
|
||||
|
||||
##
|
||||
# Final image.
|
||||
|
@ -102,6 +140,3 @@ FROM farmos-baseimage
|
|||
|
||||
# Add farmOS sources.
|
||||
COPY --from=farmos-sources --chown=www-data:www-data ${FARMOS_PATH} ${DRUPAL_PATH}
|
||||
|
||||
# Add the build-farmOS.sh script to keep compatibility with dev image.
|
||||
COPY build-farmOS.sh /usr/local/bin/
|
||||
|
|
|
@ -53,7 +53,3 @@ allowedPlugins=(
|
|||
for plugin in ${allowedPlugins[@]}; do
|
||||
composer config --no-plugins allow-plugins.$plugin true
|
||||
done
|
||||
|
||||
# Create folder for composer installations.
|
||||
mkdir -p ${FARMOS_PATH}/web/sites
|
||||
mkdir -p ${FARMOS_PATH}/vendor
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
# Inherit from the farmOS 3.x image.
|
||||
FROM farmos/farmos:3.x
|
||||
|
||||
# Set the farmOS and composer project repository URLs and versions.
|
||||
ARG FARMOS_REPO=https://github.com/farmOS/farmOS.git
|
||||
ARG FARMOS_VERSION=3.x
|
||||
ARG PROJECT_VERSION=3.x
|
||||
ARG PROJECT_REPO=https://github.com/farmOS/composer-project/raw/${PROJECT_VERSION}/composer.json
|
||||
|
||||
# Install and enable XDebug extension.
|
||||
RUN yes | pecl install xdebug \
|
||||
&& docker-php-ext-enable xdebug
|
||||
|
||||
# Add opcache revalidation frequency configuration.
|
||||
COPY conf.d/ /usr/local/etc/php/conf.d
|
||||
|
||||
# Change the user/group IDs of www-data inside the image to match the ID of the
|
||||
# developer's user on the host machine. This allows Composer to create files
|
||||
# owned by www-data inside the container, while keeping those files editable by
|
||||
# the developer outside of the container.
|
||||
# This defaults to 1000, based on the assumption that the developer is running
|
||||
# as UID 1000 on the host machine. It can be overridden at image build time with:
|
||||
# --build-arg WWW_DATA_ID=$(id -u)
|
||||
ARG WWW_DATA_ID=1000
|
||||
RUN usermod -u ${WWW_DATA_ID} www-data && groupmod -g ${WWW_DATA_ID} www-data
|
||||
|
||||
# Create a fresh ${FARMOS_PATH} directory owned by www-data.
|
||||
# We do this in two steps because of a known issue with Moby.
|
||||
# @see https://github.com/farmOS/farmOS/pull/440
|
||||
RUN rm -rf ${FARMOS_PATH}
|
||||
RUN mkdir ${FARMOS_PATH} && chown www-data:www-data ${FARMOS_PATH}
|
||||
|
||||
# Install apt dependencies, they are not part of baseimage after decouple composer.
|
||||
RUN apt-get update && apt-get install -y \
|
||||
# Install git and unzip (needed by Composer).
|
||||
git unzip
|
||||
|
||||
# Change to the www-data user.
|
||||
USER www-data
|
||||
|
||||
# Work on FarmOS folder.
|
||||
WORKDIR ${FARMOS_PATH}
|
||||
|
||||
# Build the farmOS codebase in ${FARMOS_PATH}.
|
||||
RUN /usr/local/bin/build-farmOS.sh && composer install
|
||||
RUN sed -i "s|version: 3.x|version: ${FARMOS_VERSION}|g" ${FARMOS_PATH}/web/profiles/farm/farm.info.yml
|
||||
|
||||
|
||||
# Add Configurartions for PHP CodeSniffer, PHPStan.
|
||||
COPY --chown=www-data ./files/ ${FARMOS_PATH}/
|
||||
|
||||
# Configure PHPUnit.
|
||||
RUN ${FARMOS_PATH}/phpunit.sh
|
||||
|
||||
# Change back to the root user.
|
||||
USER root
|
||||
|
||||
# Copy the farmOS codebase into ${DRUPAL_PATH}.
|
||||
RUN rm -r ${DRUPAL_PATH} && cp -rp ${FARMOS_PATH} ${DRUPAL_PATH}
|
||||
|
||||
# Create a Composer config directory for the www-data user.
|
||||
RUN mkdir /var/www/.composer && chown www-data:www-data /var/www/.composer
|
||||
|
||||
|
||||
# Setup DRUPAL working path.
|
||||
WORKDIR ${DRUPAL_PATH}
|
|
@ -12,4 +12,8 @@ sed -i 's|\./|\./web/core/|g' ${FARMOS_PATH}/phpunit.xml
|
|||
sed -i 's|\.\./web/core/|\./web/|g' ${FARMOS_PATH}/phpunit.xml
|
||||
sed -i 's| </php>| <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>'"\n"' </php>|g' ${FARMOS_PATH}/phpunit.xml
|
||||
|
||||
# Create output directory for phpunit tests and permissions for testing user.
|
||||
mkdir -p ${FARMOS_PATH}/web/sites/simpletest/browser_output
|
||||
chown -R www-data:www-data ${FARMOS_PATH}/web/sites/simpletest
|
||||
|
||||
rm ${FARMOS_PATH}/phpunit.sh
|
||||
|
|
|
@ -17,7 +17,9 @@ Available arguments and their default values are described below:
|
|||
check out.
|
||||
- Default: `3.x`
|
||||
|
||||
The `3.x-dev` image also provides the following:
|
||||
## Development image
|
||||
|
||||
The `3.x-dev` image also provides the following build arguments:
|
||||
|
||||
- `WWW_DATA_ID` - The ID to use for the `www-data` user and group inside the
|
||||
image. Setting this to the ID of the developer's user on the host machine
|
||||
|
@ -26,3 +28,8 @@ The `3.x-dev` image also provides the following:
|
|||
container. If your user ID is not `1000`, build the image with:
|
||||
`--build-arg WWW_DATA_ID=$(id -u)`
|
||||
- Default: `1000`
|
||||
|
||||
To build the development image, you will have to define the target dev,
|
||||
for example:
|
||||
|
||||
`docker build --build-arg WWW_DATA_ID=$(id -u) -t farmos/farmos:3.x-dev --target dev docker`
|
||||
|
|
Loading…
Reference in New Issue