From ef9747d1f6c318f842496da09935f4e721d0b330 Mon Sep 17 00:00:00 2001 From: Nick Dickinson Wilde Date: Wed, 9 Oct 2024 08:33:12 -0400 Subject: [PATCH] Improve base lagoon and lando setup --- assets/.env | 1 + assets/.lando.base.yml | 7 +++++++ assets/.lando.yml | 4 ++-- assets/docker-compose.yml | 23 ++++++++--------------- assets/lagoon/cli.dockerfile | 10 +++++----- assets/lagoon/drush-override.yml | 2 +- assets/lagoon/nginx.dockerfile | 2 +- assets/lagoon/php.dockerfile | 2 +- assets/lagoon/solr.dockerfile | 4 +--- composer.json | 7 ++++++- 10 files changed, 33 insertions(+), 29 deletions(-) create mode 100644 assets/.env diff --git a/assets/.env b/assets/.env new file mode 100644 index 0000000..05afe57 --- /dev/null +++ b/assets/.env @@ -0,0 +1 @@ +COMPOSER_PROJECT_NAME=site-name \ No newline at end of file diff --git a/assets/.lando.base.yml b/assets/.lando.base.yml index 612f22c..537523f 100644 --- a/assets/.lando.base.yml +++ b/assets/.lando.base.yml @@ -2,12 +2,19 @@ recipe: lagoon config: flavor: drupal env_file: + - .env - .lagoon.env services: appserver: webroot: web type: php:8.2 + build_as_root: + - mkdir -p /root/tmp + - chmod 666 /root/tmp + - mkdir -p /app/web/sites/simpletest/browser-output + - chmod 777 -R /app/web/sites/simpletest + - /usr/local/bin/composer self-update overrides: environment: PHP_IDE_CONFIG: serverName=localhost diff --git a/assets/.lando.yml b/assets/.lando.yml index 34a9d6b..e7408da 100644 --- a/assets/.lando.yml +++ b/assets/.lando.yml @@ -4,10 +4,10 @@ config: tooling: npm: - service: nodebuilder + service: cli cmd: npm dir: /app/web/themes/SITENAME gulp: - service: nodebuilder + service: cli cmd: gulp dir: /app/web/themes/SITENAME diff --git a/assets/docker-compose.yml b/assets/docker-compose.yml index 6957048..5e2a3ab 100644 --- a/assets/docker-compose.yml +++ b/assets/docker-compose.yml @@ -9,9 +9,7 @@ x-volumes: x-environment: &default-environment # Route that should be used locally, if you are using pygmy, this route *must* end with .docker.amazee.io - LAGOON_ROUTE: &default-url http://SITENAME.docker.amazee.io - COMPOSER_VERSION: '2.0.4' - COMPOSER_HASH_SHA256: '1cdc74f74965908d0e98d00feeca37c23b86da51170a3a11a1538d89ff44d4dd' + LAGOON_ROUTE: &default-url http://${COMPOSE_PROJECT_NAME:-taoti-amazee}.docker.amazee.io # Uncomment if you like to have the system behave like in production #LAGOON_ENVIRONMENT_TYPE: production # Uncomment to enable xdebug and then restart via `docker-compose up -d` @@ -34,7 +32,7 @@ services: build: context: . dockerfile: lagoon/cli.dockerfile - image: &cli-image SITENAME-cli # this image will be reused as `CLI_IMAGE` in subsequent Docker builds + image: &cli-image ${COMPOSE_PROJECT_NAME:-taoti-amazee}.-cli # this image will be reused as `CLI_IMAGE` in subsequent Docker builds labels: # Lagoon Labels lagoon.type: cli-persistent @@ -92,7 +90,7 @@ services: << : *default-environment # loads the defined environment variables from the top mariadb: - image: uselagoon/mariadb-drupal:latest + image: uselagoon/mysql-8.0:latest labels: lagoon.type: mariadb lando.type: mariadb-drupal @@ -101,16 +99,9 @@ services: << : *default-user # uses the defined user from top environment: << : *default-environment - - nodebuilder: - env_file: - - .lagoon.env - profiles: - - nodebuilder # setup a profile so that the node builder doesn't run by default - image: uselagoon/node-14-builder - labels: - lagoon.type: none - << : *default-volumes # loads the defined volumes from the top + MYSQL_DATABASE: drupal + MYSQL_USER: drupal + MYSQL_PASSWORD: drupal redis: image: amazeeio/redis:6-latest @@ -135,6 +126,8 @@ services: - cli environment: << : *default-environment + volumes: + - search:/var/solr networks: amazeeio-network: diff --git a/assets/lagoon/cli.dockerfile b/assets/lagoon/cli.dockerfile index bb2ac3c..da41f4c 100644 --- a/assets/lagoon/cli.dockerfile +++ b/assets/lagoon/cli.dockerfile @@ -1,11 +1,11 @@ -FROM uselagoon/node-14-builder:latest as nodebuilder +FROM uselagoon/node-20-builder:latest AS nodebuilder COPY . /app -RUN cd /app/web/themes/SITENAME && npm install --no-ansi && npx gulp --no-ansi +RUN cd /app/web/themes/SITENAME && npm ci --no-ansi && npm run gulp --no-ansi + +FROM uselagoon/php-8.2-cli-drupal:latest +RUN apk add screen -FROM uselagoon/php-7.4-cli-drupal:latest COPY --from=nodebuilder /app /app -RUN COMPOSER_MEMORY_LIMIT=-1 composer global remove hirak/prestissimo -RUN COMPOSER_MEMORY_LIMIT=-1 composer self-update --2 RUN COMPOSER_MEMORY_LIMIT=-1 composer install --no-interaction --no-progress --optimize-autoloader --no-dev --no-ansi RUN mkdir -p -v -m766 /app/web/sites/default/files/private RUN chmod 444 /app/web/sites/default/settings.php diff --git a/assets/lagoon/drush-override.yml b/assets/lagoon/drush-override.yml index d907462..4e5c4cc 100644 --- a/assets/lagoon/drush-override.yml +++ b/assets/lagoon/drush-override.yml @@ -1,5 +1,5 @@ # Lagoon global drush.yml file -# This file tells Drush 9 about the lagoon environment +# This file tells Drush about the lagoon environment options: root: '/app/${env.WEBROOT}' diff --git a/assets/lagoon/nginx.dockerfile b/assets/lagoon/nginx.dockerfile index a137c82..f4a4c39 100644 --- a/assets/lagoon/nginx.dockerfile +++ b/assets/lagoon/nginx.dockerfile @@ -1,5 +1,5 @@ ARG CLI_IMAGE -FROM ${CLI_IMAGE} as cli +FROM ${CLI_IMAGE} AS cli FROM uselagoon/nginx-drupal:latest diff --git a/assets/lagoon/php.dockerfile b/assets/lagoon/php.dockerfile index 1d830b8..63bbf80 100644 --- a/assets/lagoon/php.dockerfile +++ b/assets/lagoon/php.dockerfile @@ -1,5 +1,5 @@ ARG CLI_IMAGE -FROM ${CLI_IMAGE} as cli +FROM ${CLI_IMAGE} AS cli FROM uselagoon/php-8.2-fpm:latest diff --git a/assets/lagoon/solr.dockerfile b/assets/lagoon/solr.dockerfile index 3172ef9..6683399 100644 --- a/assets/lagoon/solr.dockerfile +++ b/assets/lagoon/solr.dockerfile @@ -1,7 +1,5 @@ ARG CLI_IMAGE -FROM ${CLI_IMAGE} as cli - -# Inspired by https://github.com/uselagoon/lagoon-images/pull/97 +FROM ${CLI_IMAGE} AS cli FROM uselagoon/solr-8-drupal:latest COPY --from=cli /app/config/solr-conf/ /solr-conf/conf diff --git a/composer.json b/composer.json index c4bb1dc..8196b11 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,12 @@ "mode": "replace", "path": "assets/docker-compose.yml", "overwrite": false - } + }, + "[project-root]/.env": { + "mode": "replace", + "path": "assets/.env", + "overwrite": false + }, } } }