Docker executor failing for Nginx and php build - php

Hi I am trying to setup docker on my new system and trying to make the Laravel projects work using docker. In such a case I am trying to build an image using the following Dockerfile which would install the Nginx and the php. I am using M1 apple silicon MacBook and I am facing some issues when I am trying to build it.
My Dockerfile
FROM ubuntu:16.04
RUN apt-get update \
&& apt-get install -y locales \
&& locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN apt-get update \
&& apt-get install -y nginx curl zip unzip git software-properties-common supervisor \
&& add-apt-repository -y ppa:ondrej/php \
&& apt-get update \
&& apt-get install -y php7.0-fpm php7.0-cli php7.0-mcrypt php7.0-gd php7.0-mysql \
php7.0-pgsql php7.0-imap php-memcached php7.0-mbstring php7.0-xml php7.0-curl \
php7.0-sqlite3 php7.0-xdebug \
&& php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
&& mkdir /run/php \
&& apt-get remove -y --purge software-properties-common \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& echo "daemon off;" >> /etc/nginx/nginx.conf
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
COPY default /etc/nginx/sites-available/default
COPY php-fpm.conf /etc/php/7.0/fpm/php-fpm.conf
EXPOSE 80
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["/usr/bin/supervisord"]
I am getting the following error when I am trying to build it.
executor failed running [/bin/sh -c apt-get update && apt-get install -y nginx curl zip unzip git software-properties-common supervisor && add-apt-repository -y ppa:ondrej/php && apt-get update && apt-get install -y php7.0-fpm php7.0-cli php7.0-mcrypt php7.0-gd php7.0-mysql php7.0-pgsql php7.0-imap php-memcached php7.0-mbstring php7.0-xml php7.0-curl php7.0-sqlite3 php7.0-xdebug && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer && mkdir /run/php && apt-get remove -y --purge software-properties-common && apt-get -y autoremove && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && echo "daemon off;" >> /etc/nginx/nginx.conf]: exit code: 100

So to fix the problem I had to install the extensions of the php which were available. So in such a case I tried to install the extensions of php7.4 and below is the docker-compose file
version: '2'
services:
app:
build:
context: ./docker/app
dockerfile: Dockerfile
image: ebdaa-delivery.test.com/app
volumes:
- .:/var/www/html
ports:
- "81:80"
networks:
- sdnet
node:
build:
context: ./docker/node
dockerfile: Dockerfile
image: ebdaa-delivery.test.com/node
volumes:
- .:/var/www/html
networks:
- sdnet
mysql:
image: mariadb:10.5
ports:
- "3307:3306"
environment:
MYSQL_ROOT_PASSWORD: "root"
MYSQL_DATABASE: "ecom"
MYSQL_USER: "root"
MYSQL_PASSWORD: "root"
volumes:
- mysqldata:/var/lib/mysql
networks:
- sdnet
redis:
image: redis:alpine
volumes:
- redisdata:/data
networks:
- sdnet
networks:
sdnet:
driver: "bridge"
volumes:
mysqldata:
driver: "local"
redisdata:
driver: "local"

Related

docker configuration for macbook pro with m1 pro chip

Have symfony 6.0 project with docker and it's lagging a lot of, as I know it is because of my new macbook pro with m1 chip. Before I used ubuntu, and everything was just fine. Now using arm64v8 images but still got a lot of lagging.
docker configuration is below:
I have Symfony 6.0 project on macbook pro with m1 pro chip
i have docker configuration like this:
docker-compose.yml:
version: '3'
services:
php:
build: ./docker/php
container_name: {PROJECT_NAME}_php
environment:
TZ: Europe/Vilnius
volumes:
- ./docker/php/config/www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
- ./docker/php/config/php.ini:/usr/local/etc/php/php.ini:ro
web:
build: ./docker/web
environment:
APP_PROJECT_DIR: {PATH_TO_PROJECT}
volumes:
- ./docker/web/config:/etc/nginx/config:ro
- ./docker/web/nginx.conf:/etc/nginx/nginx.conf:ro
mysql:
image: arm64v8/mariadb:10.6.4
build: ./docker/mysql
docker-compose.override.yml:
version: '3'
services:
php:
hostname: {USER_NAME}-{PROJECT_NAME}-php
working_dir: {PATH_TO_PROJECT}
volumes:
- {PATH_TO_PROJECT}:{PATH_TO_PROJECT}
- ./docker/php/composer/:/var/www/.composer/
- ./docker/php/composer/auth.json:/var/www/.composer/auth.json
- {PATH_TO_PROJECT}/node_modules
web:
environment:
APP_PROJECT_DIR: {PATH_TO_PROJECT}
APP_HOST: {PROJECT_HOST}
extra_hosts:
- "{PROJECT_HOST}:host-gateway"
volumes:
- {PATH_TO_PROJECT}:{PATH_TO_PROJECT}/public
networks:
default:
ipv4_address: 172.12.16.10
ports:
- 98:80
depends_on:
- php
- mysql
mysql:
image: arm64v8/mariadb:10.6.4
ports:
- 4306:3306
expose:
- 3306
environment:
MYSQL_ROOT_PASSWORD: qwerty
networks:
default:
ipv4_address: 172.12.16.30
networks:
default:
name: {PROJECT_NAME}
driver: bridge
ipam:
driver: default
config:
- subnet: 172.12.16.0/24
php Dockerfile:
FROM arm64v8/php:8.0-fpm
USER root
# change user and groups ids
RUN usermod --uid=1000 www-data && \
groupmod --gid=1000 www-data && \
# fix permissions
chown -R www-data:www-data /var/www/
# enable extensions
RUN echo 'START' && \
docker-php-ext-install mysqli && \
docker-php-ext-install bcmath && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-enable opcache && \
docker-php-source delete
RUN docker-php-ext-configure pcntl --enable-pcntl
RUN docker-php-ext-install pcntl
RUN apt-get update && \
apt-get install -y libzip-dev && \
docker-php-ext-install zip && \
apt-get install -y libxml2-dev && \
docker-php-ext-install soap && \
apt-get install -y libicu-dev && \
docker-php-ext-install intl && \
apt-get install -y libgmp-dev && \
docker-php-ext-install gmp && \
apt-get install -y libcurl4 libcurl4-openssl-dev && \
docker-php-ext-install -j$(nproc) curl && \
apt-get install -y libpq-dev && \
docker-php-ext-install pdo_pgsql && \
apt-get install -y libpng-dev libfreetype6-dev libjpeg62-turbo-dev && \
docker-php-ext-install gd && \
rm -r /var/lib/apt/lists/* && \
docker-php-source delete
RUN apt-get update && \
apt-get install -y git zip gnupg && \
rm -r /var/lib/apt/lists/* && \
docker-php-source delete
RUN apt-get update && \
apt-get install -y wget && \
rm -r /var/lib/apt/lists/* && \
docker-php-source delete
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt update && apt install -y yarn && \
rm -r /var/lib/apt/lists/* && \
docker-php-source delete
RUN apt update && apt install -y libxrender1 && apt install -y libfontconfig1 && apt install -y libfontconfig
RUN apt install -y wget fontconfig fontconfig-config xfonts-75dpi xfonts-base
RUN wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_arm64.deb
RUN dpkg -i wkhtmltox_0.12.6-1.buster_arm64.deb
ADD ./includes/install-composer.sh /usr/bin
RUN /usr/bin/install-composer.sh && \
mv composer.phar /usr/bin/composer
RUN apt-get update && \
## zip
apt-get install -y iputils-ping && \
## cleanup
rm -r /var/lib/apt/lists/* && \
docker-php-source delete
USER www-data
mysql Dockerfile:
FROM arm64v8/mariadb:10.6.4
COPY ./config/my.cnf /etc/mysql/conf.d/my.cnf
ENV TZ=Europe/Vilnius
web Dockerfile:
FROM nginx:1.11.0-alpine
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
Any suggestions to make it less lagging?

"deploy-php-ext-configure" in /bin/sh missing when building docker laravel image

i am trying to build image and container from a project but i am having an issue when trying to build the image. the project is a template and I already have a project using this template in my computer. I would like to know how to solve it and understand a little more. I hope somebody would help me.
here is the error log when I run the command "docker build -t my-payments ." :
#7 200.3 /bin/sh: 1: deploy-php-ext-configure: not found
here is the "docker-compose.yml" :
version: '3.8'
services:
web:
container_name: laravel-template-...
build:
context: ./
dockerfile: ./Dockerfile.dev
volumes:
- .:/var/www-data
environment:
- PORT=80
ports:
- 81:80
links:
- db
db:
image: postgres:13
container_name: db-lrv-postgres-...
restart: always
environment:
POSTGRES_DB: db-lrv-postgres
POSTGRES_USER: ...
POSTGRES_PASSWORD: ...
TZ: ...
PORT: ${PORT:-5432}
ports:
- "5434:5432"
here is "Dockerfile" :
FROM php:7.4-fpm
USER root
WORKDIR /var/www-data
RUN apt-get update \
# gd
&& apt-get install -y --no-install-recommends build-essential openssl nginx libfreetype6-dev libjpeg-dev libpng-dev libwebp-dev zlib1g-dev libzip-dev gcc g++ make nano vim unzip curl git jpegoptim optipng pngquant gifsicle locales libonig-dev nodejs npm libpq-dev \
#custom-dependencies installed: libpq-dev
&& deploy-php-ext-configure gd \
&& deploy-php-ext-install gd \
# gmp
&& apt-get install -y --no-install-recommends libgmp-dev \
&& deploy-php-ext-install gmp \
# pdo
&& deploy-php-ext-install pdo \
# pdo_pgsql
&& deploy-php-ext-install pgsql pdo_pgsql mbstring \
# opcache
&& deploy-php-ext-enable opcache \
# zip
&& deploy-php-ext-install zip \
&& apt-get autoclean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/pear/
COPY . /var/www-data
COPY ./deploy/php.ini /usr/local/etc/php/conf.d/local.ini
COPY ./deploy/nginx.conf /etc/nginx/nginx.conf
RUN mv .env.production .env
RUN chmod +rwx /var/www-data
RUN chmod -R 777 /var/www-data
#RUN npm install -g npm#latest
RUN npm install
RUN npm run prod
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install --working-dir="/var/www-data"
RUN composer dump-autoload --working-dir="/var/www-data"
RUN php artisan optimize
EXPOSE 8080
RUN ["chmod", "+x", "./deploy/post_deploy.sh"]
CMD [ "sh", "./deploy/post_deploy.sh" ]

Laravel Sail container suddenly unreachable

A few days ago my sail environment was working just fine. Now it isn't. Currently I'm using Laravel to refactor a bunch of api's over from our legacy system. So the way it works is our legacy system makes an http request, using Guzzle, to Laravel which does the processing and then returns. I noticed on my local machine I am no longer able to hit my laravel project. I get an error of connection refused. I also noticed I'm not able to hit the application through my chrome browser either and I get ERR_EMPTY_RESPONSE, however, if I log into any of my other containers on the same network and try to ping my laravel container it works just fine. I'd also like to note I have a rabbitmq service in the same docker-compose.yml and I'm able to hit the ui portion of that just fine in my browser.
This is a shared project being used on both Mac and Windows. The one mac machine it's running on is fine. My windows machine is the only one that's experiencing this issue. Below is an image of the output from sail up -d
sail up -d output
See laravel.test Error??? That's never come up before. Also notice how the DockerFile is running on CACHED commands. Not sure if that's an issue, but it never did that before when building from scratch.
Current Configuration:
Windows 10
Docker Desktop 4.8.2
PHP 8.1
WSL2
Things I've tried (stupid or not)
Restart my machine
Add php_flag opcache.enable Off to my .htaccess
Add memory_limit = 1024M to my php.ini
Point to a different DockerFile
Change the port
Wipe all associate images and rebuild from scratch
docker-compose.yml:
version: '3'
services:
laravel.test:
build:
context: ./docker_config/sail/runtimes/8.1
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.1/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
volumes:
- '.:/var/www/html'
networks:
- sail
- default
depends_on:
- rabbitmq3
rabbitmq3:
container_name: "rabbitmq"
image: rabbitmq:3-management
environment:
- RABBITMQ_DEFAULT_USER=guest
- RABBITMQ_DEFAULT_PASS=guest
volumes:
- ./docker_config/rabbitmq_init/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
- ./docker_config/rabbitmq_init/definitions.json:/etc/rabbitmq/definitions.json:ro
ports:
# AMQP protocol port
- '5672:5672'
# HTTP management UI
- '15672:15672'
networks:
default:
external: true
name: localdevstructure_default
sail:
driver: bridge
DockerFile:
FROM ubuntu:21.10
LABEL maintainer="Taylor Otwell"
ARG WWWGROUP
ARG NODE_VERSION=16
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update \
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
&& mkdir -p ~/.gnupg \
&& chmod 600 ~/.gnupg \
&& echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
&& apt-key adv --homedir ~/.gnupg --keyserver hkps://keyserver.ubuntu.com --recv-keys 14AA40EC0831756756D7F66C4F4EA0AAE5267A6C \
&& echo "deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu impish main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
&& apt-get update \
&& apt-get install -y php8.1-cli php8.1-dev \
php8.1-pgsql php8.1-sqlite3 php8.1-gd \
php8.1-curl \
php8.1-imap php8.1-mysql php8.1-mbstring \
php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap \
php8.1-intl php8.1-readline \
php8.1-ldap \
php8.1-msgpack php8.1-igbinary php8.1-redis php8.1-swoole \
php8.1-memcached php8.1-pcov php8.1-xdebug \
&& php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
&& curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -y yarn \
&& apt-get install -y mysql-client \
&& apt-get install -y postgresql-client \
&& apt-get install -y vim \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.1
RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY highPriority-worker.conf /etc/supervisor/conf.d/highPriority-worker.conf
COPY lowPriority-worker.conf /etc/supervisor/conf.d/lowPriority-worker.conf
COPY php.ini /etc/php/8.1/cli/conf.d/99-sail.ini
RUN chmod +x /usr/local/bin/start-container
EXPOSE 8000
ENTRYPOINT ["start-container"]
EDIT:
The only error I keep coming across is this:
"Error response from daemon: Get "https://sail-8.1/v2/": Failed to lookup host: sail-8.1"
I believe this relates to the error shown in the provided image for service laravel.test. What's happening is that service enters the "Pulling" stage and within a second errors out. So this is leading me to believe that something is happening during image creation
So I figured out what was happening and this was really stupid on my part. I thought that inherently supervisor isn't setup to autostart on local dev environments, but when using sail it is. In the supervisord.conf file that gets copied over to the container from local, there's a program in there to run the artisan serve command. Long story short I commented this out thinking it wasn't necessary. Didn't realize sail was using supervisor to keep that command running.

Docker file installing wrong php

I have a laravel/php docker image that I updated to PHP 8.1 - I am now trying to go back to our project version 7.3 and won't work.
here's my YAML
###############################################################################
# Generated on forwardforce.io #
###############################################################################
version: "3.1"
services:
postgres:
image: postgres:11.1-alpine
container_name: mtn-postgres
working_dir: /application
volumes:
- db:/var/lib/postgresql/data
- .:/application
ports:
- 5001:5432
environment:
- POSTGRES_USER=root
- POSTGRES_PASSWORD=root
- POSTGRES_DB=forge
webserver:
image: nginx:alpine
container_name: mtn-webserver
working_dir: /application
volumes:
- .:/application
- ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "8091:80"
tty: true
php-fpm:
build: phpdocker/php-fpm
container_name: mtn-php-fpm
working_dir: /application
environment:
XDEBUG_CONFIG: "remote_host=docker.for.mac.host.internal"
PHP_IDE_CONFIG: "serverName=MTN-Docker"
image: php:7.2-alpine
volumes:
- .:/application
- ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini
volumes:
db:
and here's my Dockerfile
FROM php:7.4-fpm-alpine
WORKDIR "/application"
# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive
# Install git
RUN apt-get update \
&& apt-get -y install libpng-dev \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install php7.2-pgsql php7.2-gd php-xdebug php-ssh2 \
&& 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 php-imagick
RUN apt-get update \
&& apt-get -y install php-imagick \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
# Install Node.js, Yarn and required dependencies
RUN apt-get update \
&& apt-get install -y curl gnupg build-essential \
&& curl --silent --location https://deb.nodesource.com/setup_10.x | bash - \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get remove -y --purge cmdtest \
&& apt-get update \
&& apt-get install -y nodejs yarn \
# remove useless files from the current layer
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/lib/apt/lists.d/* \
&& apt-get autoremove \
&& apt-get clean \
&& apt-get autoclean
RUN npm install -g cordova ionic
RUN npm i -D -E -g #angular/cli
I have deleted docker cache & containers and ran:
docker-compose up -d --force-recreate --build
But I do see "59bf1c3509f3 Already exists " in the build while it's running. And after it's finished I have the latest version of PHP 8.13
So could it be a different cache somewhere else I am not clearing? Or how can I force install of PHP 7.2 o 7.3
apt is the package manager for Debian based distribution. Use apk to manage software packages on Alpine Linux. See How to use this image.

How to install yarn and npm on a PHP docker image (symfony 4 project)

Im working on a symfony 4/posgresql project. Im using docker toolbox.
I need to install webpack encore bundle on symfony, but in order to do this, i need to add yarn and npm to my project. Somebody told me i should add theses 2 installations on my php docker container, but i don't know which command to add (im a linux/docker beginner).
This is my docker-compose.yaml :
services:
database:
image: postgres:11-alpine
ports:
- "5432:5432"
volumes:
- 'boeki_database:/var/lib/postgresql/data'
environment:
POSTGRES_PASSWORD: root
database_pg_admin:
image: dpage/pgadmin4
ports:
- "8001:80"
environment:
PGADMIN_DEFAULT_EMAIL: root#root.com
PGADMIN_DEFAULT_PASSWORD: root
application:
build:
context: .
dockerfile: ./docker/Dockerfile
working_dir: /var/www/project
ports:
- "8000:80"
volumes:
- ./:/var/www/project:rw,cached
- ./docker/http/000-default.conf:/etc/apache2/sites-enabled/000-default.conf:rw,cached
volumes:
boeki_database: {}
And this is my Dockerfile :
RUN apt-get update && \
apt-get install -y libpq-dev g++ zlib1g-dev libicu-dev vim git zip
#GD
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
poppler-utils
RUN rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
docker-php-ext-install -j "$(nproc)" gd pdo_pgsql
RUN docker-php-ext-configure intl
RUN docker-php-ext-install pdo pdo_mysql intl zip opcache
RUN pecl install redis && echo "extension=redis.so" > /usr/local/etc/php/conf.d/docker-php-ext-redis.ini
RUN a2enmod rewrite
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Thanks for the help !
according to https://classic.yarnpkg.com/en/docs/install#debian-stable which provides some commands to follow, adding the following to your dockerfile should work (disclaimer: I'm not extremely familiar with docker)
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && sudo apt-get install -y yarn
(the -y removes the questions)

Categories