Created
December 21, 2020 20:37
-
-
Save ramytamer/ede66eb49d1da312884b9721debddb7c to your computer and use it in GitHub Desktop.
Laravel, nginx, node docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:7.4-fpm-alpine | |
WORKDIR /app | |
RUN apk add --no-cache --update \ | |
&& apk add build-base \ | |
git grep curl bash \ | |
zlib-dev libzip-dev \ | |
freetype-dev \ | |
libjpeg-turbo-dev \ | |
libpng-dev \ | |
libxml2-dev \ | |
bzip2-dev \ | |
libmcrypt-dev \ | |
zip unzip \ | |
autoconf pcre-dev | |
RUN docker-php-ext-install mysqli pdo pdo_mysql tokenizer zip exif pcntl xml bcmath | |
RUN docker-php-ext-configure gd --with-freetype --with-jpeg | |
RUN docker-php-ext-install gd | |
RUN pecl channel-update pecl.php.net \ | |
&& pecl install mcrypt-1.0.3 \ | |
&& pecl install redis \ | |
&& docker-php-ext-enable mcrypt bcmath | |
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | |
COPY config/php.ini /usr/local/etc/php/conf.d/php.ini | |
COPY . . | |
ENV COMPOSER_ALLOW_SUPERUSER=1 | |
ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" | |
RUN set -eux; \ | |
mkdir -p storage/logs storage/framework bootstrap/cache; \ | |
composer install --prefer-dist --no-progress --no-suggest --optimize-autoloader; \ | |
composer clear-cache | |
COPY --from=node:10.20.1-alpine /usr/local/bin/node /usr/local/bin/ | |
COPY --from=node:10.20.1-alpine /usr/local/lib/node_modules /usr/local/lib/node_modules | |
COPY --from=node:10.20.1-alpine /opt/ /opt/ | |
RUN ln -sf /usr/local/bin/node /usr/local/bin/nodejs \ | |
&& ln -sf ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ | |
&& ln -sf ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \ | |
&& ln -sf /opt/yarn*/bin/yarn /usr/local/bin/yarn \ | |
&& ln -sf /opt/yarn*/bin/yarnpkg /usr/local/bin/yarnpkg | |
ENV PATH="/usr/local/bin:${PATH}" | |
RUN npm install | |
RUN npm run production | |
RUN apk add nginx supervisor | |
RUN mkdir -p /run/nginx | |
COPY config/nginx/production.conf /etc/nginx/conf.d/default.conf | |
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
ENTRYPOINT ["/app/entrypoint.sh"] | |
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
index index.php index.html; | |
charset utf-8; | |
add_header X-Frame-Options "SAMEORIGIN"; | |
add_header X-XSS-Protection "1; mode=block"; | |
add_header X-Content-Type-Options "nosniff"; | |
client_max_body_size 50M; | |
proxy_read_timeout 300; | |
proxy_connect_timeout 300; | |
proxy_send_timeout 300; | |
root /app/public; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[supervisord] | |
nodaemon=true | |
logfile=/dev/null | |
logfile_maxbytes=0 | |
pidfile=/run/supervisord.pid | |
user=root | |
[program:php-fpm] | |
command=php-fpm -F | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes=0 | |
stderr_logfile=/dev/stderr | |
stderr_logfile_maxbytes=0 | |
autorestart=false | |
startretries=0 | |
user=root | |
[program:nginx] | |
command=nginx -g 'daemon off;' | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes=0 | |
stderr_logfile=/dev/stderr | |
stderr_logfile_maxbytes=0 | |
autorestart=false | |
startretries=0 | |
user=root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment