mirror of
https://github.com/opdavies/build-configs.git
synced 2025-03-24 13:48:21 +00:00
feat: add project_root
setting
Allow for overriding the project root from `/app` to something else, such as `/var/www/html`. The default is set within a new `build.defaults.yaml` file which the project specific file is merged into. Fixes #27
This commit is contained in:
parent
eeeb70df14
commit
6b5c1b5aee
resources
src
templates
1
resources/build.defaults.yaml
Normal file
1
resources/build.defaults.yaml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
project_root: /app
|
|
@ -55,7 +55,10 @@ final class BuildConfigurationCommand extends Command
|
||||||
|
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$configurationData = Yaml::parseFile($configFile);
|
$configurationData = array_merge(
|
||||||
|
Yaml::parseFile(__DIR__.'/../../../resources/build.defaults.yaml'),
|
||||||
|
Yaml::parseFile($configFile),
|
||||||
|
);
|
||||||
|
|
||||||
$violations = $this->configurationValidator->validate($configurationData);
|
$violations = $this->configurationValidator->validate($configurationData);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,11 @@ final class ConfigurationValidator implements ValidatorInterface
|
||||||
new Assert\Choice(['drupal-project', 'php-library']),
|
new Assert\Choice(['drupal-project', 'php-library']),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'project_root' => [
|
||||||
|
new Assert\NotNull(),
|
||||||
|
new Assert\Type('string'),
|
||||||
|
],
|
||||||
|
|
||||||
'database' => new Assert\Optional(),
|
'database' => new Assert\Optional(),
|
||||||
|
|
||||||
'drupal' => new Assert\Optional(),
|
'drupal' => new Assert\Optional(),
|
||||||
|
|
|
@ -8,14 +8,14 @@ RUN which composer && composer -V
|
||||||
ARG DOCKER_UID=1000
|
ARG DOCKER_UID=1000
|
||||||
ENV DOCKER_UID="${DOCKER_UID}"
|
ENV DOCKER_UID="${DOCKER_UID}"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR {{ project_root }}
|
||||||
|
|
||||||
RUN adduser --disabled-password --uid "${DOCKER_UID}" app \
|
RUN adduser --disabled-password --uid "${DOCKER_UID}" app \
|
||||||
&& chown app:app -R /app
|
&& chown app:app -R {{ project_root }}
|
||||||
|
|
||||||
USER app
|
USER app
|
||||||
|
|
||||||
ENV PATH="${PATH}:/app/bin:/app/vendor/bin"
|
ENV PATH="${PATH}:{{ project_root }}/bin:{{ project_root }}/vendor/bin"
|
||||||
|
|
||||||
COPY --chown=app:app composer.* ./
|
COPY --chown=app:app composer.* ./
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ RUN {% for command in dockerfile.stages.test.commands -%}
|
||||||
|
|
||||||
FROM caddy:2 as web
|
FROM caddy:2 as web
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR {{ project_root }}
|
||||||
|
|
||||||
COPY tools/docker/images/web/root /
|
COPY tools/docker/images/web/root /
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -90,7 +90,7 @@ FROM nginx:1 as web
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR {{ project_root }}
|
||||||
|
|
||||||
COPY tools/docker/images/web/root /
|
COPY tools/docker/images/web/root /
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
x-app: &default-app
|
x-app: &default-app
|
||||||
volumes:
|
volumes:
|
||||||
- "${DOCKER_WEB_VOLUME:-./{{ drupal.docroot }}:/app/{{ drupal.docroot }}}"
|
- "${DOCKER_WEB_VOLUME:-./{{ drupal.docroot }}:{{ project_root }}/{{ drupal.docroot }}}"
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
|
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
|
||||||
|
|
|
@ -6,7 +6,7 @@ export DOCKER_UID=1000
|
||||||
export COMPOSE_PROJECT_NAME={{ name }}
|
export COMPOSE_PROJECT_NAME={{ name }}
|
||||||
export COMPOSE_PROFILES=web,php,database
|
export COMPOSE_PROFILES=web,php,database
|
||||||
|
|
||||||
export DOCKER_WEB_VOLUME=.:/app
|
export DOCKER_WEB_VOLUME=.:{{ project_root }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if "drupal-project" == type %}
|
{% if "drupal-project" == type %}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# {{ managedText | raw }}
|
# {{ managedText | raw }}
|
||||||
|
|
||||||
:80
|
:80
|
||||||
root * /app/{{ drupal.docroot }}
|
root * {{ project_root }}/{{ drupal.docroot }}
|
||||||
file_server
|
file_server
|
||||||
php_fastcgi php:9000
|
php_fastcgi php:9000
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
server {
|
server {
|
||||||
server_name _;
|
server_name _;
|
||||||
|
|
||||||
root /app/{{ drupal.docroot }};
|
root {{ project_root }}/{{ drupal.docroot }};
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri /index.php?$query_string;
|
try_files $uri /index.php?$query_string;
|
||||||
|
|
Loading…
Reference in a new issue