I'm trying to create a php-apache container with npm and composer installed and run composer install, npm install in every build, but I'm getting errors.
# Dockerfile
FROM php:7.4-apache
RUN apt-get -y update && apt-get upgrade -y
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
npm \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
# Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Enable apache modules
RUN a2enmod rewrite headers
EXPOSE 80
#RUN composer install
#RUN npm install
ENTRYPOINT ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
# docker-compose.yml
version: "3"
services:
painel-admin:
build:
context: ./bin/painel-admin
container_name: 'painel-admin'
command: >
sh -c "php /usr/local/bin/composer install"
restart: 'always'
ports:
- "81:80"
- "82:443"
volumes:
- ${DOCUMENT_ROOT-..}:/var/www/html
- ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini
- ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled
- ${LOG_DIR-./logs/apache2}:/var/log/apache2
log error:
Action '-D FOREGROUND sh -c php /usr/local/bin/composer install' failed.
Same error if I try with npm install.
I can run the commands inside the docker, but I want to automate that