From 4f906ef80162bb2f7714e14d4ad5db0c22b5f12d Mon Sep 17 00:00:00 2001 From: Pablo Ferreiro Date: Wed, 26 Jul 2023 21:41:37 +0200 Subject: [PATCH] new docker image --- .dockerignore | 13 +++++-------- Dockerfile | 39 ++++++++++++++++++--------------------- composer.json | 4 ++-- composer.lock | 9 +++------ docker-compose.yml | 2 +- misc/setup/docker/php.ini | 4 ++++ 6 files changed, 33 insertions(+), 38 deletions(-) create mode 100644 misc/setup/docker/php.ini diff --git a/.dockerignore b/.dockerignore index 0f5c25b..cb7f017 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,9 +1,6 @@ node_modules -/.env -/.git -/.vscode -/vendor -/cache/latte/* -!/cache/latte/.gitkeep -/cache/api/* -!/cache/api/.gitkeep +.env +.git +.vscode +vendor +cache diff --git a/Dockerfile b/Dockerfile index 8b7094e..73a7f39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,22 @@ -FROM php:8.2-apache -WORKDIR /var/www/html +FROM trafex/php-nginx:latest + +# Add composer COPY --from=composer /usr/bin/composer /usr/bin/composer -RUN apt update -y && apt upgrade -y \ - && apt install -y --no-install-recommends libzip-dev \ - && pecl install redis zip \ - && docker-php-ext-enable redis zip \ - && a2enmod rewrite headers \ - && mkdir /cache \ - && chown -R www-data:www-data /cache \ - && rm -rf /var/www/html/* -# Copy project to /var/www/html -COPY . . +# Copy config +COPY ./misc/setup/docker/php.ini /etc/php81/conf.d/settings.ini -# Run composer and clean -RUN composer update --no-cache \ - && composer install --no-interaction --optimize-autoloader --no-dev --no-cache \ - && apt autoclean -y \ - && apt autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ - && rm -rf /usr/bin/composer +USER root +# Create cache folder +RUN mkdir /cache && chown -R nobody:nogroup /cache +# Install deps +RUN apk add --no-cache php81-redis php81-zip php81-tokenizer +USER nobody -EXPOSE 80 -CMD apachectl -D FOREGROUND +# Copy source +COPY --chown=nobody . /var/www/html + +# Dependencies +RUN composer install --no-interaction --optimize-autoloader --no-dev --no-cache + +EXPOSE 8080 diff --git a/composer.json b/composer.json index 2aed83f..90c8f2f 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,8 @@ "ext-mbstring": "*", "latte/latte": "^2.11", "bramus/router": "^1.6", - "josegonzalez/dotenv": "dev-master", - "pablouser1/tikscraper": "^2.3" + "pablouser1/tikscraper": "^2.3", + "josegonzalez/dotenv": "^4.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 1c6e522..e81a484 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "92c34c828c921f4e49b6dc6ab9bf3d8b", + "content-hash": "f94f92790bfe52bdf38e6bd9ba80f40a", "packages": [ { "name": "bramus/router", @@ -99,7 +99,7 @@ }, { "name": "josegonzalez/dotenv", - "version": "dev-master", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/josegonzalez/php-dotenv.git", @@ -120,7 +120,6 @@ "php-mock/php-mock-phpunit": "~1.1||~2.0", "squizlabs/php_codesniffer": "~2.9||~3.7" }, - "default-branch": true, "type": "library", "autoload": { "psr-0": { @@ -678,9 +677,7 @@ "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "josegonzalez/dotenv": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/docker-compose.yml b/docker-compose.yml index ae98621..935b2de 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: container_name: proxitok-web image: ghcr.io/pablouser1/proxitok:master ports: - - 8080:80 + - 8080:8080 environment: - LATTE_CACHE=/cache - API_CACHE=redis diff --git a/misc/setup/docker/php.ini b/misc/setup/docker/php.ini new file mode 100644 index 0000000..3ae84f3 --- /dev/null +++ b/misc/setup/docker/php.ini @@ -0,0 +1,4 @@ +variables_order="EGPCS" +[Date] +date.timezone="UTC" +expose_php=Off