From 77c7ce56ed93d6864bc37a72f8383c5d542dc8c6 Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Wed, 10 Jan 2024 22:23:55 +0100 Subject: [PATCH] Finish up moving to docker --- .dockerignore | 16 ++++++++++++ .gitignore | 2 ++ Dockerfile | 59 +++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 2 +- docker/php/.env | 1 - docker/php/Dockerfile | 39 ---------------------------- docker/php/log.conf | 2 -- package.json | 2 +- 8 files changed, 79 insertions(+), 44 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile delete mode 100644 docker/php/.env delete mode 100644 docker/php/Dockerfile delete mode 100644 docker/php/log.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..035b1ce --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +###> symfony/framework-bundle ### +/.env.local +/.env.local.php +/.env.*.local +/config/secrets/prod/prod.decrypt.private.php +/public/bundles/ +/var/ +/vendor/ +###< symfony/framework-bundle ### + +###> symfony/webpack-encore-bundle ### +/node_modules/ +/public/build/ +npm-debug.log +yarn-error.log +###< symfony/webpack-encore-bundle ### diff --git a/.gitignore b/.gitignore index 7fdcc07..7b34889 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ npm-debug.log yarn-error.log ###< symfony/webpack-encore-bundle ### + +/assets/fontawesome diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8e6b3a3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,59 @@ +# syntax=docker/dockerfile:1 +FROM node:12 as assets + +WORKDIR /appsource + +# First copy only dependencies related info for better caching +COPY package.json yarn.lock ./ +COPY assets/fontawesome/fontawesome-pro-5.15.4-web assets/fontawesome/fontawesome-pro-5.15.4-web + +RUN yarn + +COPY . . +RUN yarn run build + +FROM php:7.4-fpm-alpine + +# Timezone +RUN ln -snf /usr/share/zoneinfo/Europe/Warsaw /etc/localtime +RUN echo "date.timezone = Europe/Warsaw" >> /usr/local/etc/php/conf.d/datetime.ini; + +COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ +COPY --from=composer:1 /usr/bin/composer /usr/local/bin/ + +# Box +RUN wget https://github.com/humbug/box/releases/download/3.8.4/box.phar \ + && mv box.phar /usr/local/bin/box \ + && chmod +x /usr/local/bin/box + +RUN install-php-extensions sockets redis zip curl; + +ARG BUILD_MODE=prod +RUN set -eux; \ + if [ "$BUILD_MODE" = "dev" ]; then \ + install-php-extensions xdebug; \ + { \ + echo "xdebug.discover_client_host=1"; \ + echo "xdebug.mode=debug"; \ + } > "$PHP_INI_DIR"/conf.d/90-xdebug.ini; \ + elif [ "$BUILD_MODE" = "prod" ]; then \ + install-php-extensions opcache; \ + { \ + echo "opcache.enable_cli=1"; \ + echo "opcache.max_accelerated_files=40000"; \ + } > "$PHP_INI_DIR"/conf.d/90-opcache.ini; \ + fi + +WORKDIR /var/www + +COPY composer.* ./ + +RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --no-progress --no-interaction && \ + composer check-platform-reqs + +COPY . . + +RUN composer dump-autoload --optimize && \ + composer run-script post-install-cmd + +COPY --link --from=assets /appsource/public/build ./public/build diff --git a/docker-compose.yml b/docker-compose.yml index 7910e68..fc6a674 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - ./docker/nginx/keylighter.localhost:/etc/nginx/conf.d/keylighter.conf php: - build: docker/php + build: . environment: - MESSENGER_TRANSPORT_DSN=redis://redis:6379/messages env_file: diff --git a/docker/php/.env b/docker/php/.env deleted file mode 100644 index b3290ce..0000000 --- a/docker/php/.env +++ /dev/null @@ -1 +0,0 @@ -PHP_IDE_CONFIG=serverName=keylighter diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile deleted file mode 100644 index e24fa5e..0000000 --- a/docker/php/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -FROM php:7.3-fpm - -ARG XDEBUG_REMOTE_HOST="172.17.0.1" - -RUN apt-get update && \ - apt-get install -y --no-install-recommends git zip libzip-dev wget libcurl4-openssl-dev - -RUN docker-php-ext-install zip curl - -# XDebug -RUN pecl install xdebug-2.9.0 && docker-php-ext-enable xdebug -RUN echo "xdebug.remote_enable = 1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ - echo "xdebug.remote_host = ${XDEBUG_REMOTE_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; - -# Redis -RUN pecl install -o -f redis && docker-php-ext-enable redis - -# Cleanup -RUN rm -rf /tmp/pear - -# Composer -RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ - && php composer-setup.php \ - && php -r "unlink('composer-setup.php');" \ - && mv composer.phar /usr/local/bin/composer \ - && chmod +x /usr/local/bin/composer - -# Box -RUN wget https://github.com/humbug/box/releases/download/3.8.4/box.phar \ - && mv box.phar /usr/local/bin/box \ - && chmod +x /usr/local/bin/box - -# Timezone -RUN ln -snf /usr/share/zoneinfo/Europe/Warsaw /etc/localtime -RUN echo "date.timezone = Europe/Warsaw" >> /usr/local/etc/php/conf.d/datetime.ini; - -WORKDIR /var/www - -EXPOSE 9001 diff --git a/docker/php/log.conf b/docker/php/log.conf deleted file mode 100644 index 39029d9..0000000 --- a/docker/php/log.conf +++ /dev/null @@ -1,2 +0,0 @@ -php_admin_flag[log_errors] = on -php_flag[display_errors] = off \ No newline at end of file diff --git a/package.json b/package.json index 8783c46..6d266ae 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "devDependencies": { "@babel/plugin-transform-react-jsx": "^7.9.4", "@babel/preset-react": "^7.0.0", - "@fortawesome/fontawesome-pro": "^5.13.0", + "@fortawesome/fontawesome-pro": "file:assets/fontawesome/fontawesome-pro-5.15.4-web", "@symfony/webpack-encore": "^0.28.2", "@types/bootstrap": "^3.3.32", "@types/jquery": "^2.0.41",