mirror of
https://github.com/jkaninda/nginx-php-fpm.git
synced 2025-12-06 13:39:42 +01:00
Merge develop
This commit is contained in:
50
.github/workflows/build.yml
vendored
50
.github/workflows/build.yml
vendored
@@ -1,33 +1,15 @@
|
||||
name: ci
|
||||
|
||||
name: Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
branches:
|
||||
- '**'
|
||||
- main
|
||||
|
||||
env:
|
||||
#BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||
BUILDKIT_IMAGE: jkaninda/nginx-php-fpm
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Set environment for branch
|
||||
run: |
|
||||
set -x
|
||||
if [[ $GITHUB_REF == 'refs/heads/main' ]]; then
|
||||
echo "TAG_NAME=latest" >> "$GITHUB_ENV"
|
||||
echo "runs-on: main branch"
|
||||
else
|
||||
echo "TAG_NAME=${{ github.head_ref || github.ref_name }}" >> "$GITHUB_ENV"
|
||||
echo "runs-on: ${{ github.head_ref || github.ref_name }} branch"
|
||||
fi
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
@@ -41,8 +23,32 @@ jobs:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
name: Build and push 7.4
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
file: "./docker/7.4/Dockerfile"
|
||||
push: true
|
||||
tags: "${{env.BUILDKIT_IMAGE}}:${{env.TAG_NAME}}"
|
||||
tags: "${{env.BUILDKIT_IMAGE}}:7.4"
|
||||
-
|
||||
name: Build and push 8.0
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
file: "./docker/8.0/Dockerfile"
|
||||
push: true
|
||||
tags: "${{env.BUILDKIT_IMAGE}}:8.0"
|
||||
-
|
||||
name: Build and push 8.1
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
file: "./docker/8.1/Dockerfile"
|
||||
push: true
|
||||
tags: "${{env.BUILDKIT_IMAGE}}:8.1"
|
||||
-
|
||||
name: Build and push 8.2
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
file: "./docker/8.2/Dockerfile"
|
||||
push: true
|
||||
tags: |
|
||||
"${{env.BUILDKIT_IMAGE}}:8.2"
|
||||
"${{env.BUILDKIT_IMAGE}}:latest"
|
||||
24
README.md
24
README.md
@@ -1,5 +1,4 @@
|
||||

|
||||

|
||||
[](https://github.com/jkaninda/nginx-php-fpm/actions/workflows/build.yml)
|
||||

|
||||

|
||||
|
||||
@@ -90,6 +89,27 @@ services:
|
||||
docker-compose up -d
|
||||
|
||||
```
|
||||
## Build from base
|
||||
Dockerfile
|
||||
```Dockerfile
|
||||
FROM jkaninda/nginx-php-fpm:8.1
|
||||
# Copy laravel project files
|
||||
COPY . /var/www/html
|
||||
# Storage Volume
|
||||
VOLUME /var/www/html/storage
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Custom cache invalidation
|
||||
ARG CACHEBUST=1
|
||||
RUN composer install
|
||||
|
||||
RUN chown -R www-data:www-data /var/www/html/storage
|
||||
RUN chown -R www-data:www-data /var/www/html/bootstrap/cache
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Nginx custom config:
|
||||
### Enable custom nginx config files
|
||||
> /var/www/html/conf/nginx/nginx.conf
|
||||
|
||||
11
build.sh
11
build.sh
@@ -1,9 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/bash
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
tag='latest'
|
||||
else
|
||||
tag=$1
|
||||
fi
|
||||
if [ $tag != 'latest' ]
|
||||
then
|
||||
echo 'Build from tag'
|
||||
docker build -f docker/${tag}/Dockerfile -t jkaninda/nginx-php-fpm:$tag .
|
||||
else
|
||||
echo 'Build latest'
|
||||
docker build -f docker/8.2/Dockerfile -t jkaninda/nginx-php-fpm:$tag .
|
||||
|
||||
docker build -t jkaninda/nginx-php-fpm:$tag .
|
||||
fi
|
||||
|
||||
87
docker/7.4/Dockerfile
Normal file
87
docker/7.4/Dockerfile
Normal file
@@ -0,0 +1,87 @@
|
||||
FROM php:7.4-fpm
|
||||
ARG WORKDIR=/var/www/html
|
||||
ENV DOCUMENT_ROOT=${WORKDIR}
|
||||
ENV LARAVEL_PROCS_NUMBER=1
|
||||
ENV DOMAIN=_
|
||||
ENV CLIENT_MAX_BODY_SIZE=15M
|
||||
ENV NODE_VERSION=17.x
|
||||
ARG HOST_UID=1000
|
||||
ENV USER=www-data
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libmemcached-dev \
|
||||
libzip-dev \
|
||||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev \
|
||||
librdkafka-dev \
|
||||
libpq-dev \
|
||||
openssh-server \
|
||||
zip \
|
||||
unzip \
|
||||
supervisor \
|
||||
sqlite3 \
|
||||
nano \
|
||||
cron
|
||||
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash -
|
||||
# Install Node
|
||||
RUN apt-get install -y nodejs
|
||||
# Install nginx
|
||||
RUN apt-get update && apt-get install -y nginx
|
||||
|
||||
# Clear cache
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install PHP extensions zip, mbstring, exif, bcmath, intl
|
||||
RUN docker-php-ext-configure gd
|
||||
RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl
|
||||
|
||||
# Install Redis and enable it
|
||||
RUN pecl install redis && docker-php-ext-enable redis
|
||||
|
||||
|
||||
|
||||
# Install the php memcached extension
|
||||
RUN pecl install memcached && docker-php-ext-enable memcached
|
||||
|
||||
# Install the PHP pdo_mysql extention
|
||||
RUN docker-php-ext-install pdo_mysql
|
||||
|
||||
# Install the PHP pdo_pgsql extention
|
||||
RUN docker-php-ext-install pdo_pgsql
|
||||
|
||||
|
||||
# Install Composer
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
# Set working directory
|
||||
WORKDIR $WORKDIR
|
||||
|
||||
RUN rm -Rf /var/www/* && \
|
||||
mkdir -p /var/www/html
|
||||
|
||||
ADD src/index.php $WORKDIR/index.php
|
||||
ADD src/conf/nginx/default.conf /etc/nginx/sites-available/default
|
||||
ADD src/php.ini $PHP_INI_DIR/conf.d/
|
||||
ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
COPY ./entrypoint.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
RUN ln -s /usr/local/bin/entrypoint.sh /
|
||||
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
||||
|
||||
|
||||
|
||||
RUN usermod -u ${HOST_UID} www-data
|
||||
RUN groupmod -g ${HOST_UID} www-data
|
||||
|
||||
RUN chmod -R 755 $WORKDIR
|
||||
RUN chown -R www-data:www-data $WORKDIR
|
||||
EXPOSE 9000 80
|
||||
CMD [ "entrypoint" ]
|
||||
@@ -1,10 +1,12 @@
|
||||
FROM php:8.1.11-fpm
|
||||
FROM php:8.0-fpm
|
||||
ARG WORKDIR=/var/www/html
|
||||
ENV DOCUMENT_ROOT=${WORKDIR}
|
||||
ENV LARAVEL_PROCS_NUMBER=1
|
||||
ENV DOMAIN=_
|
||||
ENV CLIENT_MAX_BODY_SIZE=15M
|
||||
ENV NODE_VERSION=17.x
|
||||
ARG HOST_UID=1000
|
||||
ENV USER=www-data
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
@@ -88,11 +90,10 @@ ENTRYPOINT ["entrypoint.sh"]
|
||||
|
||||
|
||||
|
||||
RUN usermod -u 1000 www-data
|
||||
RUN groupmod -g 1000 www-data
|
||||
RUN usermod -u ${HOST_UID} www-data
|
||||
RUN groupmod -g ${HOST_UID} www-data
|
||||
|
||||
RUN chmod -R 755 $WORKDIR
|
||||
RUN chown -R www-data:www-data $WORKDIR
|
||||
EXPOSE 9000 80
|
||||
CMD [ "entrypoint" ]
|
||||
|
||||
100
docker/8.1/Dockerfile
Normal file
100
docker/8.1/Dockerfile
Normal file
@@ -0,0 +1,100 @@
|
||||
FROM php:8.1.13-fpm
|
||||
ARG WORKDIR=/var/www/html
|
||||
ENV DOCUMENT_ROOT=${WORKDIR}
|
||||
ENV LARAVEL_PROCS_NUMBER=1
|
||||
ENV DOMAIN=_
|
||||
ENV CLIENT_MAX_BODY_SIZE=15M
|
||||
ENV NODE_VERSION=17.x
|
||||
ARG HOST_UID=1000
|
||||
ENV USER=www-data
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libmemcached-dev \
|
||||
libzip-dev \
|
||||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev \
|
||||
librdkafka-dev \
|
||||
libpq-dev \
|
||||
openssh-server \
|
||||
zip \
|
||||
unzip \
|
||||
supervisor \
|
||||
sqlite3 \
|
||||
nano \
|
||||
cron
|
||||
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash -
|
||||
# Install Node
|
||||
RUN apt-get install -y nodejs
|
||||
# Install nginx
|
||||
RUN apt-get update && apt-get install -y nginx
|
||||
|
||||
# Clear cache
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
# Install Kafka
|
||||
RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\
|
||||
&& cd php-rdkafka \
|
||||
&& phpize \
|
||||
&& ./configure \
|
||||
&& make all -j 5 \
|
||||
&& make install
|
||||
|
||||
# Install Rdkafka and enable it
|
||||
RUN docker-php-ext-enable rdkafka \
|
||||
&& cd .. \
|
||||
&& rm -rf /php-rdkafka
|
||||
|
||||
# Install PHP extensions zip, mbstring, exif, bcmath, intl
|
||||
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
|
||||
RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl
|
||||
|
||||
# Install Redis and enable it
|
||||
RUN pecl install redis && docker-php-ext-enable redis
|
||||
|
||||
|
||||
|
||||
# Install the php memcached extension
|
||||
RUN pecl install memcached && docker-php-ext-enable memcached
|
||||
|
||||
# Install the PHP pdo_mysql extention
|
||||
RUN docker-php-ext-install pdo_mysql
|
||||
|
||||
# Install the PHP pdo_pgsql extention
|
||||
RUN docker-php-ext-install pdo_pgsql
|
||||
|
||||
|
||||
# Install Composer
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
# Set working directory
|
||||
WORKDIR $WORKDIR
|
||||
|
||||
RUN rm -Rf /var/www/* && \
|
||||
mkdir -p /var/www/html
|
||||
|
||||
ADD src/index.php $WORKDIR/index.php
|
||||
ADD src/conf/nginx/default.conf /etc/nginx/sites-available/default
|
||||
ADD src/php.ini $PHP_INI_DIR/conf.d/
|
||||
ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
COPY ./entrypoint.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
RUN ln -s /usr/local/bin/entrypoint.sh /
|
||||
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
||||
|
||||
|
||||
|
||||
RUN usermod -u ${HOST_UID} www-data
|
||||
RUN groupmod -g ${HOST_UID} www-data
|
||||
|
||||
RUN chmod -R 755 $WORKDIR
|
||||
RUN chown -R www-data:www-data $WORKDIR
|
||||
EXPOSE 80
|
||||
CMD [ "entrypoint" ]
|
||||
|
||||
100
docker/8.2/Dockerfile
Normal file
100
docker/8.2/Dockerfile
Normal file
@@ -0,0 +1,100 @@
|
||||
FROM php:8.2.0-fpm
|
||||
ARG WORKDIR=/var/www/html
|
||||
ENV DOCUMENT_ROOT=${WORKDIR}
|
||||
ENV LARAVEL_PROCS_NUMBER=1
|
||||
ENV DOMAIN=_
|
||||
ENV CLIENT_MAX_BODY_SIZE=15M
|
||||
ENV NODE_VERSION=17.x
|
||||
ARG HOST_UID=1000
|
||||
ENV USER=www-data
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libmemcached-dev \
|
||||
libzip-dev \
|
||||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev \
|
||||
librdkafka-dev \
|
||||
libpq-dev \
|
||||
openssh-server \
|
||||
zip \
|
||||
unzip \
|
||||
supervisor \
|
||||
sqlite3 \
|
||||
nano \
|
||||
cron
|
||||
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash -
|
||||
# Install Node
|
||||
RUN apt-get install -y nodejs
|
||||
# Install nginx
|
||||
RUN apt-get update && apt-get install -y nginx
|
||||
|
||||
# Clear cache
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
# Install Kafka
|
||||
RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\
|
||||
&& cd php-rdkafka \
|
||||
&& phpize \
|
||||
&& ./configure \
|
||||
&& make all -j 5 \
|
||||
&& make install
|
||||
|
||||
# Install Rdkafka and enable it
|
||||
RUN docker-php-ext-enable rdkafka \
|
||||
&& cd .. \
|
||||
&& rm -rf /php-rdkafka
|
||||
|
||||
# Install PHP extensions zip, mbstring, exif, bcmath, intl
|
||||
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
|
||||
RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl
|
||||
|
||||
# Install Redis and enable it
|
||||
RUN pecl install redis && docker-php-ext-enable redis
|
||||
|
||||
|
||||
|
||||
# Install the php memcached extension
|
||||
RUN pecl install memcached && docker-php-ext-enable memcached
|
||||
|
||||
# Install the PHP pdo_mysql extention
|
||||
RUN docker-php-ext-install pdo_mysql
|
||||
|
||||
# Install the PHP pdo_pgsql extention
|
||||
RUN docker-php-ext-install pdo_pgsql
|
||||
|
||||
|
||||
# Install Composer
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
# Set working directory
|
||||
WORKDIR $WORKDIR
|
||||
|
||||
RUN rm -Rf /var/www/* && \
|
||||
mkdir -p /var/www/html
|
||||
|
||||
ADD src/index.php $WORKDIR/index.php
|
||||
ADD src/conf/nginx/default.conf /etc/nginx/sites-available/default
|
||||
ADD src/php.ini $PHP_INI_DIR/conf.d/
|
||||
ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
COPY ./entrypoint.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
RUN ln -s /usr/local/bin/entrypoint.sh /
|
||||
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
||||
|
||||
|
||||
|
||||
RUN usermod -u ${HOST_UID} www-data
|
||||
RUN groupmod -g ${HOST_UID} www-data
|
||||
|
||||
RUN chmod -R 755 $WORKDIR
|
||||
RUN chown -R www-data:www-data $WORKDIR
|
||||
EXPOSE 80
|
||||
CMD [ "entrypoint" ]
|
||||
|
||||
@@ -26,7 +26,7 @@ if [ -f /var/www/html/artisan ]; then
|
||||
autostart=true
|
||||
autorestart=true
|
||||
numprocs=1
|
||||
user=root
|
||||
user=www-data
|
||||
stdout_logfile=/var/log/laravel_scheduler.out.log
|
||||
redirect_stderr=true
|
||||
|
||||
@@ -36,7 +36,7 @@ if [ -f /var/www/html/artisan ]; then
|
||||
autostart=true
|
||||
autorestart=true
|
||||
numprocs=$LARAVEL_PROCS_NUMBER
|
||||
user=root
|
||||
user=www-data
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/log/laravel_worker.log
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user