Finish up moving to docker

This commit is contained in:
Kacper Donat 2024-01-10 22:23:55 +01:00
parent d90286f741
commit 77c7ce56ed
8 changed files with 79 additions and 44 deletions

16
.dockerignore Normal file
View File

@ -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 ###

2
.gitignore vendored
View File

@ -15,3 +15,5 @@
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
/assets/fontawesome

59
Dockerfile Normal file
View File

@ -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

View File

@ -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:

View File

@ -1 +0,0 @@
PHP_IDE_CONFIG=serverName=keylighter

View File

@ -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

View File

@ -1,2 +0,0 @@
php_admin_flag[log_errors] = on
php_flag[display_errors] = off

View File

@ -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",