forked from govcms-tests/tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.ci
More file actions
55 lines (45 loc) · 2.51 KB
/
Dockerfile.ci
File metadata and controls
55 lines (45 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Set the PHP and GovCMS versions as arguments
ARG PHP_VERSION=8.3
ARG GOVCMS_VERSION=10.x-beta
# Use multi-stage builds for better optimization
FROM govcmstesting/tests:latest-php${PHP_VERSION} AS tests
FROM govcms/govcms:${GOVCMS_VERSION} AS govcms
FROM govcmstesting/php:${PHP_VERSION}-apache
# Set the working directory to "/app/"
WORKDIR /app/
# Set environment variables
ENV PATH="${PATH}:/app/tests/vendor/bin:/app/vendor/bin:/app/bin" \
SIMPLETEST_BASE_URL="http://localhost" \
SIMPLETEST_DB="sqlite://sites/default/files/.ht.sqlite"
# Create govcms user and set permissions, configure Apache
RUN set -eux; \
groupadd -r govcms && useradd -r -g govcms -G root,www-data govcms; \
mkdir -p /app/config/default && chown -R govcms:govcms /app; \
mkdir -p /home/govcms/.cache/composer && chown -R govcms:govcms /home/govcms; \
echo 'govcms ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# Copy govcms and test files with correct ownership
COPY --chown=govcms:govcms --from=govcms /app /app
COPY --chown=govcms:govcms --from=tests /tests /app/tests
# Configure Apache for Drupal
RUN set -eux; \
echo '<VirtualHost *:80>' > /etc/apache2/sites-available/000-default.conf; \
echo ' ServerAdmin webmaster@localhost' >> /etc/apache2/sites-available/000-default.conf; \
echo ' DocumentRoot /app/web' >> /etc/apache2/sites-available/000-default.conf; \
echo ' <Directory /app/web>' >> /etc/apache2/sites-available/000-default.conf; \
echo ' Options Indexes FollowSymLinks' >> /etc/apache2/sites-available/000-default.conf; \
echo ' AllowOverride All' >> /etc/apache2/sites-available/000-default.conf; \
echo ' Require all granted' >> /etc/apache2/sites-available/000-default.conf; \
echo ' </Directory>' >> /etc/apache2/sites-available/000-default.conf; \
echo ' ErrorLog ${APACHE_LOG_DIR}/error.log' >> /etc/apache2/sites-available/000-default.conf; \
echo ' CustomLog ${APACHE_LOG_DIR}/access.log combined' >> /etc/apache2/sites-available/000-default.conf; \
echo '</VirtualHost>' >> /etc/apache2/sites-available/000-default.conf
# Switch to govcms user
USER govcms
# Update Drupal
RUN --mount=type=cache,target=/root/.composer/cache \
composer update --with-all-dependencies
# Require the SimpleSAMLphp Auth module for Drupal using Composer
RUN --mount=type=cache,target=/root/.composer/cache \
composer require 'drupal/simplesamlphp_auth:^4.0' --with-all-dependencies
# Default command (can be overridden by docker-compose)
CMD ["apache2-foreground"]