From 13945dcaec7d0bcbda2c65af39ec83d205c297f3 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 10 May 2024 23:55:32 +0200 Subject: [PATCH] Update build configuration files --- .dockerignore | 1 + .env.example | 8 +++ .gitignore | 59 +++++++++------- .hadolint.yaml | 2 + Dockerfile | 53 ++++++++++++++ docker-compose.yaml | 69 +++++++++++++++++++ .../root/usr/local/bin/docker-entrypoint-php | 7 ++ .../images/php/root/usr/local/etc/php/php.ini | 4 ++ 8 files changed, 180 insertions(+), 23 deletions(-) create mode 100644 .dockerignore create mode 100644 .env.example create mode 100644 .hadolint.yaml create mode 100644 Dockerfile create mode 100644 docker-compose.yaml create mode 100755 tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php create mode 100644 tools/docker/images/php/root/usr/local/etc/php/php.ini diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..42366c5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +/README.md diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..f112d29 --- /dev/null +++ b/.env.example @@ -0,0 +1,8 @@ +# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. + +export DOCKER_UID=1000 + + +export MYSQL_DATABASE=app +export MYSQL_PASSWORD=app +export MYSQL_USER=app diff --git a/.gitignore b/.gitignore index 68b52d3..dc4f724 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,40 @@ # Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. -* -!*/ +.editorconfig +.env +.gitattributes +.phpunit.result.cache +vendor/ +web/.csslintrc +web/.eslintignore +web/.eslintrc.json +web/.ht.router.php +web/.htaccess +web/INSTALL.txt +web/README.md +web/autoload.php +web/core/ +web/example.gitignore +web/index.php +web/modules/README.txt +web/modules/contrib/ +web/profiles/README.txt +web/robots.txt +web/sites/*/files/ +web/sites/*/private/ +web/sites/*/services*.yml +web/sites/*/settings*.php +web/sites/README.txt +web/sites/default/default.services.yml +web/sites/default/default.settings.php +web/sites/development.services.yml +web/sites/example.settings.local.php +web/sites/example.sites.php +web/sites/simpletest/ +web/themes/README.txt +web/themes/contrib/ +web/update.php +web/web.config -!/.dockerignore -!/.env.example -!/.githooks/** -!/.github/** -!/.gitignore -!/.hadolint.yaml -!/Dockerfile -!/build.yaml -!/composer.{json,lock} -!/docker-compose.yaml -!/phpcs.xml.dist -!/phpstan.neon.dist -!/phpunit.xml.dist -!/run -!/run.local -!/tools/** -!/web/*/custom/** - -!/_lessons/** -!/phpstan.neon -!/tests/** +.dir-env/ diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 0000000..d87bf88 --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,2 @@ +ignore: + - DL3059 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1bbd1c8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. + +FROM php: AS base + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer +RUN which composer && composer -V + +ARG DOCKER_UID=1000 +ENV DOCKER_UID="${DOCKER_UID}" + +WORKDIR /app + +RUN adduser --disabled-password --uid "${DOCKER_UID}" app \ + && chown app:app -R /app + +USER app + +ENV PATH="${PATH}:/app/bin:/app/vendor/bin" + +COPY --chown=app:app composer.* ./ + +################################################################################ + +FROM base AS build + +USER root + + +RUN apt-get update -yqq \ + && apt-get install -yqq --no-install-recommends \ + git libpng-dev libjpeg-dev libzip-dev mariadb-client unzip \ + && rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \ + && apt-get clean + +RUN docker-php-ext-configure gd --with-jpeg + +RUN docker-php-ext-install gd opcache pdo_mysql zip + +COPY --chown=app:app phpunit.xml* ./ + + + +USER app + + +COPY --chown=app:app tools/docker/images/php/root / + +ENTRYPOINT ["/usr/local/bin/docker-entrypoint-php"] +CMD ["php-fpm"] + + + + diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..63d7163 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,69 @@ +# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. + +x-proxy: &default-proxy + networks: + - default + - web + labels: + - "traefik.enable=true" + - "traefik.docker.network=traefik_proxy" + - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host( + `${COMPOSE_PROJECT_NAME}.docker.localhost`, + )" + - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.tls=true" + +x-app: &default-app + volumes: + - "${DOCKER_WEB_VOLUME:-./web:/app/web}" + env_file: + - .env + restart: "${DOCKER_RESTART_POLICY:-unless-stopped}" + networks: + - default + deploy: + resources: + limits: + cpus: "${DOCKER_MYSQL_CPUS:-0}" + memory: "${DOCKER_MYSQL_MEMORY:-0}" + labels: + - "traefik.enable=false" + tty: true + +services: + + php: + <<: [*default-app] + build: + context: . + target: build + args: + - "DOCKER_UID=${DOCKER_UID:-1000}" + volumes: + - .:/app + profiles: [php] + + database: + image: : + deploy: + resources: + limits: + cpus: "${DOCKER_MYSQL_CPUS:-0}" + memory: "${DOCKER_MYSQL_MEMORY:-0}" + volumes: + - db-data:/var/lib/mysql + + env_file: + - .env + labels: + - "traefik.enable=false" + environment: + MYSQL_RANDOM_ROOT_PASSWORD: true + profiles: [database] + +volumes: + db-data: {} + +networks: + web: + external: true + name: traefik_proxy diff --git a/tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php b/tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php new file mode 100755 index 0000000..dbd9900 --- /dev/null +++ b/tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. + +[[ -f composer.json && ! -d vendor ]] && composer install + +eval "$@" diff --git a/tools/docker/images/php/root/usr/local/etc/php/php.ini b/tools/docker/images/php/root/usr/local/etc/php/php.ini new file mode 100644 index 0000000..aa883a1 --- /dev/null +++ b/tools/docker/images/php/root/usr/local/etc/php/php.ini @@ -0,0 +1,4 @@ +# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. + +max_vars_input = 1000 +memory_limit = 128M