Jump to content
thirty bees forum

Has anyone used ThirtyBees in a docker environment? (nginx + php-fpm)


MaxStrax

Recommended Posts

Hello, I'm trying to setup the environment for ThirtyBees in docker, but I just can't get it working.

I always, receive the message: file created in the system's temporary directory in /var/www/default/classes/PrestaShopAutoload.php on line 125

I know this error is due to permissions issues, after checking the corresponding line in the PrestaShopAutoload.php file. But, as this is my first time using a PHP application in nginx (+ php-fpm), I'm not really sure how to solve the permissions issue.

I'm using the following Docker Compose file:

services:

  web:
    image: nginx:latest
    container_name: nginx
    ports:
      - "10010:80/tcp"
    volumes:
      - /home/debian/docker-data/nginx/php:/var/www/default
      - /home/debian/docker-data/nginx/nginx.conf:/etc/nginx/nginx.conf
    restart: unless-stopped
    networks:
      - thirtybees-net

  php:
    image: php:8.0-fpm
    container_name: php-fpm
    volumes:
      - /home/debian/docker-data/nginx/php:/var/www/default
    networks:
      - thirtybees-net

  database:
    image: lscr.io/linuxserver/mariadb:10.11.4
    container_name: thirtybees-db
    environment:
      - MYSQL_DATABASE=thirtybees
      - MYSQL_USER=thirtybees
      - MYSQL_PASSWORD=thirtybees
      - MYSQL_ROOT_PASSWORD=thirtybees_root
      - TZ=Europe/Madrid
      - PUID=1000
      - PGID=1000
    volumes:
      - /home/debian/docker-data/thirtybees-db:/config
    restart: unless-stopped
    networks:
      - thirtybees-net

networks:
  thirtybees-net:
    name: thirtybees-net

And, the nginx.conf file:

worker_processes auto;

events {
  worker_connections 1024;
}

http {
  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  sendfile on;
  keepalive_timeout 65;

  server {
    listen 80;
    server_name localhost;

    root /var/www/html;
    index index.php;

    location / {
      try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
      fastcgi_pass php:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
    }
  }
}

I tried with php: 7.4, 8.0, 8.1. Of course, after switching php-fpm docker versions, I was downloading and extracting the corresponding ZIP file for the matching version of ThirtyBees too.

Edited by MaxStrax
Link to comment
Share on other sites

Mmmm, the file does not exist there:

Note: The error from above, appears just after the second click of the setup wizard: Choose your language (OK) > Licence agreement (OK) > System compatibility (FAIL).

56456756757.JPG

Edited by MaxStrax
Link to comment
Share on other sites

1 hour ago, the.rampage.rado said:

Here's a google result for exact same error but in Laravel. https://stackoverflow.com/questions/30182984/sqlstatehy000-2002-php-network-getaddresses-getaddrinfo-failed-name-or-ser

TB is not able to connect to the DB server. Please, check your settings!

I assume that ThirtyBees code checks for the database instance that will be connected to, not in the 4th step, but on System Compatibility step?

My database instance (MariaDB) is ok. It's in the same docker network as the nginx/php webserver is placed.

Also, I didn't mention it here, but when I try to run the setup by without configuring php-fpm on the standalone nginx docker container, I can complete all the setup wizard steps, including connecting to the mariadb container and it starts creating tables and such. But, I can't continue on the final step: I can't open store preview nor admin pane. But, when I try to add fpm support, the errors discussed on this thread starts to be shown. So, the database is not the problem here I think.

Edited by MaxStrax
Link to comment
Share on other sites

1 hour ago, the.rampage.rado said:

Here's a google result for exact same error but in Laravel. https://stackoverflow.com/questions/30182984/sqlstatehy000-2002-php-network-getaddresses-getaddrinfo-failed-name-or-ser

TB is not able to connect to the DB server. Please, check your settings!

What TB files manages the database discovery? A part from the 'settings.inc.php', but the System Compatibility setup, as it doesn't fail to create tables, but on the previous screen.

Maybe, php-fpm implementation prevents somehow TB to see database instances when it checks the system compatibilities.

Edited by MaxStrax
Link to comment
Share on other sites

The only thing that exists is this: https://github.com/thirtybees/thirtybees/blob/e25be2ffb57ff6d98ea28b65ac3aa3bc6e621d0a/classes/ConfigurationTest.php#L180-L195

That should NOT run during installation time, because constant _DB_SERVER_ is not defined yet.

If this test is executed during install time, that means that you defined this constant somewhere - most likely in in settings.inc.php file. Double check that this file does not exists. 

Link to comment
Share on other sites

I finally got it working. Seems I was forgetting to include a php extension while building the image. But, the main reason was a file/folder permission error. Sorry about that. Totally, my fault.

But, now I see this error message:

image.png.345e56c7043cd932c0d1709dfab935dd.png

Edited by MaxStrax
Link to comment
Share on other sites

This is the Dockerfile I use to create the php-fpm image:
 

FROM php:8.1-fpm

# Instalar dependencias y módulos PHP necesarios
RUN apt-get update && apt-get install -y \
    libzip-dev \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    libpq-dev \
    && docker-php-ext-install -j$(nproc) \
    bcmath \
    gd \
    intl \
    pdo_mysql \
    soap \
    zip

RUN docker-php-ext-enable gd
RUN docker-php-ext-configure gd --with-freetype --with-jpeg

# Habilitar OPcache
RUN docker-php-ext-enable opcache

# Configurar el archivo de configuración de PHP
#COPY php.ini /usr/local/etc/php/conf.d/custom.ini

# Establecer permisos adecuados para el servidor web
RUN chown -R www-data:www-data /var/www/html/

 

Edited by MaxStrax
Link to comment
Share on other sites

Ok. SOLVED!

FROM php:8.1-fpm

# Instalar dependencias y módulos PHP necesarios
RUN apt-get update && apt-get install -y \
    libzip-dev \
    libfreetype6-dev \
    libjpeg-dev \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    libpq-dev \
    && docker-php-ext-install -j$(nproc) \
    bcmath \
    intl \
    pdo_mysql \
    soap \
    zip

RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install gd
RUN docker-php-ext-enable gd

# Habilitar OPcache
RUN docker-php-ext-enable opcache

# Configurar el archivo de configuración de PHP
#COPY php.ini /usr/local/etc/php/conf.d/custom.ini

# Establecer permisos adecuados para el servidor web
RUN chown -R www-data:www-data /var/www/html/

 

Edited by MaxStrax
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...