Hi Guys,
I am a little desperate. After few days I am not able to create a simple developer environment on docker.
My website is based on kirby and zero one (theme). This content needs to be update and in this case to PHP 8.1 - this is the main reason why I am doing this.
Anyways, I started with a simple compose file:
version: '3.9'
services:
nginx:
build:
context: ./
dockerfile: ./dockerfiles/nginx.dockerfile
ports:
- 80:80
volumes:
- ./www/:/var/www/html/
depends_on:
- php
networks:
- php-net
php:
build:
context: ./
dockerfile: ./dockerfiles/php.dockerfile
expose:
- 9000
volumes:
- ./www/:/var/www/html/
networks:
- php-net
networks:
php-net:
driver: bridge
NGINX part
FROM nginx:1.24.0-alpine
ADD ./dockerfiles/default.conf /etc/nginx/conf.d/default.conf
default.conf
upstream _php {
server unix:/sock/docker.sock;
}
server {
server_name 0.0.0.0:80;
index index.php index.html;
root /var/www/html;
client_body_in_file_only clean;
client_body_buffer_size 32K;
client_max_body_size 300M;
sendfile on;
send_timeout 300s;
location /assets {
try_files $uri =404;
expires max;
access_log off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location / {
try_files $uri /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri $uri/ /index.php$is_args$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PHP_VALUE "memory_limit = 512M;";
}
}
PHP file
FROM php:8.1-fpm
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions imagick gd ctype curl dom filter hash iconv json libxml mbstring openssl SimpleXML exif fileinfo intl apcu memcached PDO zip zlib xdebug
RUN chown -R www-data:www-data /var/www/html
My container are created and works as expected. I can reach my VM through the web browser, but:
- The website does not build properly. Only the text is visible, but any visuals are missing.
- According to the browser, the page has an invalid address.
I’m not sure where to look for, let alone why containers worked years ago (PHP 7.1).
Based on the message in the broswer, I suspect URL rewriting errors. Does anyone have any ideas on this?
I thank you for every tip and try to help where I can.
Greets!
