Commit f5246e56 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

using npm inside of image

parent 67f36c61
.composer
.npm
.gitlab
.vscode
.node_modules
vendor
.editorconfig
.git
.gitattributes
.gitignore
.gitlab-ci.yaml
APP_ENV=development
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
LOG_CHANNEL=stderr
APP_URL=https://localhost:8080
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=redis
SESSION_DRIVER=array
QUEUE_DRIVER=sync
CENTRAL_REDIS_HOST=redis
CENTRAL_REDIS_PASSWORD=null
CENTRAL_REDIS_PORT=6379
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PROXY_PASSWORD_OLD=secure_password
PROXY_PASSWORD=very_secure_password
PROXY_TIMEOUT=3600
PROXY_URL=https://localhost:8080
PROXY_LOG_LOCATION=/var/log/proxy/proxy.log
PROXY_MEMORY_CACHE=5242880
PROXY_FREE_DOWNLOAD_LIMIT=104857600
CACHE_ENABLED=true
\ No newline at end of file
......@@ -4,6 +4,7 @@
/storage/*.key
/vendor
.npm
.composer
.env
.env.backup
.phpunit.result.cache
......
FROM debian:10
FROM debian:10 AS dependencies
WORKDIR /html
EXPOSE 80
# Install System Components
RUN apt update \
......@@ -8,8 +11,8 @@ RUN apt update \
cron \
lsb-release \
apt-transport-https \
zip \
curl
curl \
zip
RUN curl -o /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
......@@ -30,9 +33,23 @@ RUN apt update \
php7.4-dom \
php7.4-fileinfo \
php7.4-redis \
php7.4-xdebug \
php7.4-zip
WORKDIR /html
# Install Composer
COPY ./helpers/installComposer.sh /usr/bin/installComposer
RUN chmod +x /usr/bin/installComposer && \
/usr/bin/installComposer && \
rm /usr/bin/installComposer
# Install Nodejs
COPY ./helpers/installNodejs.sh /usr/bin/installNodejs
RUN chmod +x /usr/bin/installNodejs && \
/usr/bin/installNodejs && \
rm /usr/bin/installNodejs
ENV PATH /usr/local/lib/nodejs/bin:$PATH
FROM dependencies AS development
RUN sed -i 's/error_log = \/var\/log\/php7.4-fpm.log/error_log = \/dev\/stderr/g' /etc/php/7.4/fpm/php-fpm.conf && \
sed -i 's/;daemonize = yes/daemonize = no/g' /etc/php/7.4/fpm/php-fpm.conf && \
......@@ -46,33 +63,40 @@ RUN sed -i 's/error_log = \/var\/log\/php7.4-fpm.log/error_log = \/dev\/stderr/g
sed -i 's/pm.min_spare_servers = 1/pm.min_spare_servers = 5/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/pm.max_spare_servers = 3/pm.max_spare_servers = 50/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;zend_extension=xdebug.so/zend_extension=xdebug.so/g' /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
echo "xdebug.mode = debug" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
echo "xdebug.start_with_request = yes" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
echo "xdebug.discover_client_host = true" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
echo "xdebug.idekey=VSCODE" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime && \
echo "Europe/Berlin" > /etc/timezone && \
(crontab -l ; echo "* * * * * php /html/artisan schedule:run >> /dev/null 2>&1") | crontab -
CMD chmod +x /entrypoint.sh && \
/entrypoint.sh
# Just the changes we need for production use (i.e. enable opcache, disable xdebug, etc.)
FROM development AS production
# Opcache configuration
RUN phpdismod xdebug && \
sed -i 's/expose_php = On/expose_php = Off/g' /etc/php/7.4/fpm/php.ini && \
# Opcache configuration
sed -i 's/;opcache.enable=1/opcache.enable=1/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.memory_consumption=128/opcache.memory_consumption=128/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.interned_strings_buffer=8/opcache.interned_strings_buffer=8/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.max_accelerated_files=10000/opcache.max_accelerated_files=10000/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.max_wasted_percentage=5/opcache.max_wasted_percentage=5/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.validate_timestamps=1/opcache.validate_timestamps=1/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.revalidate_freq=2/opcache.revalidate_freq=300/g' /etc/php/7.4/fpm/php.ini && \
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime && \
echo "Europe/Berlin" > /etc/timezone && \
(crontab -l ; echo "* * * * * php /html/artisan schedule:run >> /dev/null 2>&1") | crontab -
sed -i 's/;opcache.revalidate_freq=2/opcache.revalidate_freq=300/g' /etc/php/7.4/fpm/php.ini
COPY config/nginx.conf /etc/nginx/nginx.conf
COPY config/nginx-default.conf /etc/nginx/sites-available/default
RUN sed -i 's/fastcgi_pass phpfpm:9000;/fastcgi_pass localhost:9000;/g' /etc/nginx/sites-available/default
COPY --chown=root:www-data . /html
COPY ./helpers/installComposer.sh /usr/bin/installComposer
RUN chmod +x /usr/bin/installComposer && \
/usr/bin/installComposer && \
rm /usr/bin/installComposer && \
composer install --no-dev
# Install Entrypoint
COPY ./helpers/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
COPY --chown=root:www-data . /html
WORKDIR /html
EXPOSE 80
CMD cron -L /dev/stdout && \
php-fpm7.4 -F -R
FROM debian:10
# Install System Components
RUN apt update \
&& apt install -y \
nginx \
tzdata \
cron \
lsb-release \
apt-transport-https \
curl \
zip
RUN curl -o /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
# Install PHP Components
RUN apt update \
&& apt install -y \
php7.4 \
php7.4-fpm \
php7.4-json \
php7.4-bcmath \
php7.4-ctype \
php7.4-mbstring \
php7.4-pdo \
php7.4-tokenizer \
php7.4-xml \
php7.4-curl \
php7.4-dom \
php7.4-fileinfo \
php7.4-redis \
php7.4-xdebug \
php7.4-zip
WORKDIR /html
RUN sed -i 's/error_log = \/var\/log\/php7.4-fpm.log/error_log = \/dev\/stderr/g' /etc/php/7.4/fpm/php-fpm.conf && \
sed -i 's/;daemonize = yes/daemonize = no/g' /etc/php/7.4/fpm/php-fpm.conf && \
mkdir -p /run/php && \
sed -i 's/listen = \/run\/php\/php7.4-fpm.sock/listen = 9000/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/decorate_workers_output = no/decorate_workers_output = no/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/user = nobody/user = www-data/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/group = nobody/group = www-data/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/pm.max_children = 5/pm.max_children = 100/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/pm.start_servers = 2/pm.start_servers = 5/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/pm.min_spare_servers = 1/pm.min_spare_servers = 5/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/pm.max_spare_servers = 3/pm.max_spare_servers = 25/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/expose_php = On/expose_php = Off/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;zend_extension=xdebug.so/zend_extension=xdebug.so/g' /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
echo "xdebug.mode = debug" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
echo "xdebug.start_with_request = yes" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
echo "xdebug.discover_client_host = true" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
echo "xdebug.idekey=VSCODE" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime && \
echo "Europe/Berlin" > /etc/timezone && \
(crontab -l ; echo "* * * * * php /html/artisan schedule:run >> /dev/null 2>&1") | crontab -
COPY ./helpers/installComposer.sh /usr/bin/installComposer
RUN chmod +x /usr/bin/installComposer && \
/usr/bin/installComposer && \
rm /usr/bin/installComposer
WORKDIR /html
EXPOSE 80
CMD cron -L /dev/stdout && \
composer install && \
php-fpm7.4 -F -R
......@@ -67,7 +67,8 @@ class RequestFetcher extends Command
} catch (\Exception $e) {
if ($count >= 9) {
// If its not available after 10 seconds we will exit
return;
echo "Redis Connection was not possible within 10 seconds." . PHP_EOL;
return 1;
}
sleep(1);
}
......
version: '3.7'
services:
assets:
image: node:16
user: "1000:1000"
nodejs:
image: proxy/development:latest
restart: always
build:
context: .
dockerfile: Dockerfile
target: development
volumes:
- .:/html
command: bash -c "npm i --cache .npm --prefer-offline && npm run watch"
composer:
image: proxy/development:latest
environment:
- COMPOSER_HOME=/html/.composer
volumes:
- .:/usr/src/app
- .npm:/home/node/.npm
working_dir: /usr/src/app
command: bash -c "npm i --prefer-offline && npm run watch"
- .:/html
command: composer install
phpfpm:
depends_on:
- "assets"
- "redis"
- "nodejs"
restart: on-failure
build:
context: .
dockerfile: DockerfileDev
image: proxy:latest
working_dir: /html
image: proxy/development:latest
volumes:
- .:/html
- ./helpers/entrypoint.sh:/entrypoint.sh
web:
depends_on:
- "phpfpm"
image: proxy:latest
working_dir: /html
- "nodejs"
image: proxy/development:latest
command: nginx
restart: always
volumes:
- .:/html
- ./config/nginx.conf:/etc/nginx/nginx.conf
......@@ -37,10 +42,9 @@ services:
container_name: redis
worker:
depends_on:
- "phpfpm"
restart: on-failure
image: proxy:latest
working_dir: /html
- "nodejs"
restart: always
image: proxy/development:latest
volumes:
- .:/html
command: "su -s /bin/sh -c 'php artisan requests:fetcher' www-data"
......
#!/bin/sh
set -e
if [ ! -f .env ];
then
cp .env.example .env
fi
chmod -R ugo+w storage
cron -L /dev/stdout
php-fpm7.4 -F -R
\ No newline at end of file
#!/bin/sh
set -e
NODE_VERSION=v14.17.5
NODE_DISTRO=linux-x64
NODE_URL="https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-$NODE_DISTRO.tar.xz"
# Download Nodejs archive
curl -o /tmp/node-$NODE_VERSION-$NODE_DISTRO.tar.xz "$NODE_URL"
tar -xJvf /tmp/node-$NODE_VERSION-$NODE_DISTRO.tar.xz -C /usr/local/lib
mv /usr/local/lib/node-$NODE_VERSION-$NODE_DISTRO /usr/local/lib/nodejs
echo "export PATH=/usr/local/lib/nodejs/bin:$PATH" >> ~/.profile
. ~/.profile
\ No newline at end of file
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment