Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php-fpm is not running on docker-compose up #30

Closed
ghost opened this issue Sep 30, 2020 · 4 comments
Closed

php-fpm is not running on docker-compose up #30

ghost opened this issue Sep 30, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Sep 30, 2020

I am running a slightly modified version of the generated files from phpdocker.io and php-fpm won't start on docker-compose up

There are no logs being generated, as it just looks like php-fpm doesn't start.

docker-compose.yml:

version: "3.1"
services:

    postgres:
      image: postgres:11.1-alpine
      container_name: sgn-postgres
      working_dir: /application
      volumes:
        - .:/application
        - ./docker/postgres/:/docker-entrypoint-initdb.d/
      environment:
        - POSTGRES_USER=sgn
        - POSTGRES_PASSWORD=sgn
        - POSTGRES_DB=sgn
      ports:
        - "5432:5432"
      restart: always

    webserver:
      image: nginx:alpine
      container_name: sgn-webserver
      working_dir: /application
      volumes:
          - .:/application
          - ./docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
      ports:
       - "80:80"
      restart: always

    php-fpm:
      build: docker/php-fpm
      container_name: sgn-php-fpm
      working_dir: /application
      volumes:
        - .:/application
        - ./docker/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini
      restart: always

Dockerfile inside /php-fpm/:

FROM phpdockerio/php74-fpm:latest
WORKDIR "/application"

# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive

# Install selected extensions and other stuff
RUN apt-get update \
    && apt-get -y --no-install-recommends install nano php7.4-pgsql php-xdebug apt-utils libfontconfig1 libxrender1 xvfb libjpeg-turbo8 libpng16-16 \
    && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

# Install git
RUN apt-get update \
    && apt-get -y install git \
    && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

# Install cron
RUN apt-get update \
    && apt-get install -y cron
ADD ./crontab /etc/cron.d/cron
RUN chmod 0644 /etc/cron.d/cron \
    && touch /var/log/cron.log \
    && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

# Run the command on container startup
CMD printenv > /etc/environment && echo "cron starting..." && (cron) && : > /var/log/cron.log && tail -f /var/log/cron.log

nginx.conf inside /nginx/:

server {
    listen 80 default;

    client_max_body_size 108M;

    access_log /var/log/nginx/application.access.log;


    root /application/public;
    index index.php;

    if (!-e $request_filename) {
        rewrite ^.*$ /index.php last;
    }

    location ~ \.php$ {
        fastcgi_pass php-fpm:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        include fastcgi_params;
    }

}
@ghost
Copy link
Author

ghost commented Sep 30, 2020

Removing Cron commands made this work again.

@ghost ghost closed this as completed Sep 30, 2020
@luispabon
Copy link
Contributor

If you need cron commands, you can simply run another php container - in fact this would be the preferred method. You can use phpdockerio/php74-cli for that (no FPM on that one)

@ghost
Copy link
Author

ghost commented Oct 1, 2020

Are there any way to include cron in the php-fpm container?
Having a container just for CLI looks like a waste to me.

@luispabon
Copy link
Contributor

Docker best practices are to have one container per function.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant