php-censor / docker-php-censor

Containers for PHP Censor CI system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use without Alpine?

panosru opened this issue · comments

I tried to build it without Alpine, just with php:7.2.13-fpm but it seems that it fails to work, I assume entrypoint is working with Alpine only, could you provide any info on what to change so I could use php:7.2.13-fpm instead of Alpine package?

My Dockerfile:

FROM registry.gitlab.com/***/docker/php:dev

RUN apt-get install gettext-base unzip && \
    yes '' | apt-get install nginx netcat

ENV PHPCENSOR_VERSION=0.24.0

WORKDIR /var/www/html

RUN git clone -b $PHPCENSOR_VERSION --single-branch --depth 1 https://github.com/corpsee/php-censor.git . && \
    composer install

ADD entrypoint.sh /
ADD config.tmpl.yml /
ADD nginx.conf /etc/nginx/nginx.conf

ENV ADMIN_NAME=admin
ENV ADMIN_EMAIL=admin@php-censor.local
ENV ADMIN_PASSWORD=admin
ENV DB_HOST=localhost
ENV DB_TYPE=mysql
ENV DB_NAME=phpcensor
ENV DB_USER=phpcensor
ENV DB_PASS=changethepass
ENV SITE_URL=http://phpcensor.local
ENV BEANSTALK_HOST=localhost
ENV BEANSTALK_QUEUE_NAME=phpcensor

EXPOSE 80

ENTRYPOINT ["/entrypoint.sh"]
web_1     | /entrypoint.sh: 2: set: Illegal option -o pipefail
docker-php-censor_web_1 exited with code 2

Thanks!

Update:

I replaced in entrypoint.sh this:

#!/bin/sh
set -eo pipefail

with this:

#!/bin/bash
set -e

The building process went fine
image
but now for some reason I'm getting

Creating docker-php-censor_web_1 ... done
Attaching to docker-php-censor_web_1
web_1     | /entrypoint.sh: line 38: ./app/config.yml: No such file or directory

I have modified my Dockerfile to debug the situation and understand what is going on,

FROM registry.gitlab.com/***/docker/php:dev

WORKDIR /var/www/html

RUN apt-get install gettext-base unzip && \
    yes '' | apt-get install nginx netcat

ENV PHPCENSOR_VERSION=0.24.0

RUN pwd && git clone -b $PHPCENSOR_VERSION --single-branch --depth 1 https://github.com/corpsee/php-censor.git . && \
    composer install && pwd && ls

COPY entrypoint.sh /entrypoint.sh
COPY config.tmpl.yml /config.tmpl.yml
COPY nginx.conf /etc/nginx/nginx.conf

# ENTRYPOINT ["/entrypoint.sh"]

Installation process:
image

Then I docker exec -it docker-php-censor_web_1 sh to check inside the container:
image

and /var/www/html seems to be empty... I'm really confused why it is empty since clearly in the installation process it cloned the git repo and installed composer requirements...

This is my Dockerfile from my private registry in gitlab (registry.gitlab.com/***/docker/php:dev):

#++++++++++++++++++++++++++++++++++++++
# PHP application Docker container
#++++++++++++++++++++++++++++++++++++++

FROM php:7.2.13-fpm


RUN apt-get update && apt-get upgrade -y \
    wget \
    git \
    unzip \
    g++ \
    librabbitmq-dev \
    libc-client-dev \
    libfreetype6-dev \
    libicu-dev \
    libjpeg62-turbo-dev \
    libkrb5-dev \
    libpq-dev \
    libmagickwand-dev \
    libyaml-dev \
    libmcrypt-dev \
    libpng-dev \
    libmemcached-dev \
    libssl-dev \
    libssl-doc \
    libsasl2-dev \
    zlib1g-dev \
    && docker-php-ext-install \
    bz2 \
    bcmath \
    calendar \
    exif \
    gettext \
    iconv \
    mbstring \
    pcntl \
    shmop \
    mysqli \
    sockets \
    opcache \
    wddx \
    pgsql \
    pdo_mysql \
    pdo_pgsql \
    soap \
    zip \
    && docker-php-ext-configure gd \
    --with-freetype-dir=/usr/include/ \
    --with-jpeg-dir=/usr/include/ \
    --with-png-dir=/usr/include/ \
    && docker-php-ext-install gd \
    && docker-php-ext-configure intl \
    && docker-php-ext-install intl \
    && yes '' | pecl install imagick && docker-php-ext-enable imagick \
    && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
    && docker-php-ext-install imap \
    && pecl install memcached && docker-php-ext-enable memcached \
    && pecl install mongodb && docker-php-ext-enable mongodb \
    && pecl install redis && docker-php-ext-enable redis \
    && pecl install xdebug && docker-php-ext-enable xdebug \
    && pecl install igbinary && docker-php-ext-enable igbinary \
    && pecl install psr && docker-php-ext-enable psr \
    && pecl install mcrypt-1.0.1 && docker-php-ext-enable mcrypt \
    && pecl install amqp && docker-php-ext-enable amqp \
    && pecl install yaml && docker-php-ext-enable yaml

# Install APCu and APC backward compatibility
RUN pecl install apcu \
    && pecl install apcu_bc \
    && docker-php-ext-enable apcu --ini-name 10-docker-php-ext-apcu.ini \
    && docker-php-ext-enable apc --ini-name 20-docker-php-ext-apc.ini

# Install Phalcon
ENV PHALCON_VERSION=3.4.2

RUN curl -sSL "https://codeload.github.com/phalcon/cphalcon/tar.gz/v${PHALCON_VERSION}" | tar -xz \
    && cd cphalcon-${PHALCON_VERSION}/build \
    && ./install \
    && cp ../tests/_ci/phalcon.ini $(php-config --configure-options | grep -o "with-config-file-scan-dir=\([^ ]*\)" | awk -F'=' '{print $2}') \
    && cd ../../ \
    && rm -r cphalcon-${PHALCON_VERSION} \
    && docker-php-ext-enable phalcon

# Install Swoole
RUN git clone https://github.com/swoole/swoole-src.git && \
    cd swoole-src && \
    phpize && \
    ./configure && \
    make && make install && \
    cd ../ && \
    rm -r swoole-src && \
    docker-php-ext-enable swoole


# Install Blackfire
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
    && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
    && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \
    && mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
    && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini

# Install TA-Lib
RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz && \
  tar -xvzf ta-lib-0.4.0-src.tar.gz && \
  cd ta-lib/ && \
  ./configure --prefix=/usr && \
  make && \
  make install

RUN rm -R ta-lib ta-lib-0.4.0-src.tar.gz

# Install Trader PHP Extension
RUN pecl install trader && docker-php-ext-enable trader

# Install Composer
RUN curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
    && ln -s $(composer config --global home) /root/composer

ENV PATH $PATH:/root/composer/vendor/bin

# Clean up
RUN pecl clear-cache \
    && apt-get autoremove -y --purge \
    && apt-get clean \
    && rm -Rf /tmp/*


ENV PROVISION_CONTEXT "development"

# Add User
ENV APPLICATION_USER=application \
    APPLICATION_GROUP=application \
    APPLICATION_PATH=/app \
    APPLICATION_UID=1000 \
    APPLICATION_GID=1000

# Add group
RUN groupadd -g "$APPLICATION_GID" "$APPLICATION_GROUP"

# Add user
RUN useradd -u "$APPLICATION_UID" --home "/home/application" --create-home --shell /bin/bash --no-user-group "$APPLICATION_USER"

# Assign user to group
RUN usermod -g "$APPLICATION_GROUP" "$APPLICATION_USER"

# Set Volumes
VOLUME ["/var/www", "/usr/local/etc", "/tmp/debug"]

# Configure volume/workdir
WORKDIR /var/www/

Update

After removing that part from my original Dockerfile

# Add User
ENV APPLICATION_USER=application \
    APPLICATION_GROUP=application \
    APPLICATION_PATH=/app \
    APPLICATION_UID=1000 \
    APPLICATION_GID=1000

# Add group
RUN groupadd -g "$APPLICATION_GID" "$APPLICATION_GROUP"

# Add user
RUN useradd -u "$APPLICATION_UID" --home "/home/application" --create-home --shell /bin/bash --no-user-group "$APPLICATION_USER"

# Assign user to group
RUN usermod -g "$APPLICATION_GROUP" "$APPLICATION_USER"

# Set Volumes
VOLUME ["/var/www", "/usr/local/etc", "/tmp/debug"]

# Configure volume/workdir
WORKDIR /var/www/

It seemed to work
image

although because of installing nginx I had to add RUN rm -f index.nginx-debian.html in Dockerfile because of:
image

Now I'm wondering, why to have nginx inside the container where PHP-fpm is, I'll have some tests by modifying the docker-compose.yml file and I might separate them.

I will post later my results.

@panosru Thank you for the detailed report. I will try to analyze your problem when I will have free time.

@corpsee thanks mate!

I actually made a fork here: https://github.com/panosru/docker-php-censor

As you can see I made quite a lot of changes to fit more on my approach of working with docker, I did not make a PR here as my approach may not be suitable for others, feel free to take whatever you believe you like in my fork once I manage to fix it 🤣

my current issue that after docker-compose up I'm receiving the following output:
image

I'm sure I'm missing something simple but unfortunately, I'm unable to see where exactly is the issue, I'll take a break and re-visit it with clearer mind later.

PS: Если у тебя будет время проверить мой форк и помочь уточнить где я ошибся и php censor не работает, хотя бы указать причину и я сам сделаю debug буду очень благодарен! Спасибо!

Update

I found the issue, I messed up with config.tmpl.yml file... I updated my fork but I have 404 issues with nginx container...

Update 2

fixed :)