I am using the official php:alpine https://github.com/docker-library/php/blob/master/7.2/alpine3.7/fpm/Dockerfile as my base image. My projects are basically composer based project. So I installed composer on it like below.
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin -- --filename=composer
When I install any packages using composer install
it runs as root as the main php process runs as root. So how can I run main php process as root and composer as another non root user deploy
?
Update-1
My dockerfile is like below. So as you can see I am not installing composer packages inside dockerfile rather I install those packages on container like docker exec -it php composer install
.
FROM php:7.2-fpm-alpine
..........................
..........................
..........................
RUN set ex \
# Install Composer( Requires git )
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin -- --filename=composer \
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]
I was trying to achieve it like https://unix.stackexchange.com/questions/476155/how-to-pass-multiple-parameters-to-su-user-c-command but in vain.