PHP 8.4 environment
This commit is contained in:
13 files changed
+342
No files matched your search
@@ -0,0 +1,4 @@
|
||||
UID=1000
|
||||
GID=1000
|
||||
APP_NAME = app
|
||||
APP_PORT = 8080
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Listen for Xdebug",
|
||||
"type": "php",
|
||||
"request": "launch",
|
||||
"port": 9003,
|
||||
"stopOnEntry": true,
|
||||
"pathMappings": {
|
||||
"/app": "${workspaceRoot}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
pid /tmp/nginx.pid;
|
||||
worker_processes auto;
|
||||
error_log /dev/stderr warn;
|
||||
|
||||
events {
|
||||
worker_connections 2048;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
|
||||
server_tokens off;
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 15;
|
||||
types_hash_max_size 2048;
|
||||
client_max_body_size 20M;
|
||||
|
||||
access_log /dev/stdout;
|
||||
error_log /dev/stderr;
|
||||
gzip on;
|
||||
|
||||
upstream php-upstream {
|
||||
server 127.0.0.1:9000;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
root /app/public;
|
||||
index index.php;
|
||||
|
||||
location / {
|
||||
try_files $uri /index.php$is_args$args;
|
||||
}
|
||||
|
||||
location ~ ^/index\.php(/|$) {
|
||||
include fastcgi_params;
|
||||
|
||||
fastcgi_pass php-upstream;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||
fastcgi_param DOCUMENT_ROOT $realpath_root;
|
||||
|
||||
fastcgi_buffers 16 16k;
|
||||
fastcgi_buffer_size 32k;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
xdebug.mode=debug
|
||||
xdebug.discover_client_host=1
|
||||
xdebug.start_with_request=yes
|
||||
xdebug.idekey=vsc
|
||||
xdebug.client_host=host.docker.internal
|
||||
xdebug.log_level=0
|
||||
xdebug.client_port=9003
|
||||
@@ -0,0 +1,15 @@
|
||||
services:
|
||||
app:
|
||||
container_name: ${APP_NAME}-app
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: docker/dockerfile
|
||||
args:
|
||||
UID: ${UID}
|
||||
GID: ${GID}
|
||||
DEBUG: 'true'
|
||||
BUILD_MODE: 'dev'
|
||||
volumes:
|
||||
- ../:/app
|
||||
ports:
|
||||
- ${APP_PORT}:80
|
||||
@@ -0,0 +1,77 @@
|
||||
FROM php:8.4-fpm-alpine3.21
|
||||
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
ARG DEBUG=false
|
||||
ARG BUILD_MODE=prod
|
||||
|
||||
# Custom prompt
|
||||
ENV PS1="\033[01;32mapp\033[00m:\033[01;34m\w\033[00m\$ \033[37m"
|
||||
|
||||
# Install packages
|
||||
RUN apk add --update --no-cache \
|
||||
linux-headers \
|
||||
curl \
|
||||
curl-dev \
|
||||
git \
|
||||
build-base \
|
||||
libpq-dev \
|
||||
libpng-dev \
|
||||
libzip-dev \
|
||||
zlib-dev \
|
||||
oniguruma-dev \
|
||||
autoconf \
|
||||
nginx \
|
||||
bash \
|
||||
shadow \
|
||||
make
|
||||
|
||||
# Install PHP extensions
|
||||
RUN docker-php-ext-install \
|
||||
pdo_pgsql \
|
||||
bcmath \
|
||||
curl \
|
||||
exif \
|
||||
zip \
|
||||
bz2 \
|
||||
gd
|
||||
|
||||
# Configure non-root user
|
||||
RUN groupmod -o -g ${GID} www-data && \
|
||||
usermod -o -u ${UID} -g www-data www-data
|
||||
|
||||
# Copy application
|
||||
WORKDIR /app
|
||||
RUN chown www-data:www-data /app
|
||||
COPY --chown=www-data:www-data ./ /app
|
||||
|
||||
# Configure Xdebug
|
||||
RUN if [ ${DEBUG} = "true" ]; \
|
||||
then \
|
||||
pecl install xdebug && docker-php-ext-enable xdebug; \
|
||||
fi;
|
||||
COPY ./docker/conf/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
|
||||
|
||||
# Install composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Install php dependencies
|
||||
RUN if [ ${BUILD_MODE} = "prod" ]; \
|
||||
then \
|
||||
composer install --no-dev --no-interaction --no-progress --no-scripts --optimize-autoloader; \
|
||||
chown -R www-data:www-data /app/vendor/; \
|
||||
fi;
|
||||
|
||||
# Configure nginx
|
||||
RUN touch /var/lib/nginx/logs/error.log && chown www-data:www-data /var/lib/nginx/logs/error.log
|
||||
RUN chown -Rf www-data:www-data /var/lib/nginx /run
|
||||
COPY ./docker/conf/nginx.conf /etc/nginx/
|
||||
|
||||
COPY ./docker/entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
USER www-data
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["/entrypoint.sh"]
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "Starting php-fpm..."
|
||||
php-fpm -D
|
||||
|
||||
echo "Starting nginx..."
|
||||
exec nginx -g "daemon off;"
|
||||
Reference in new issue
Block a user