Skip to content

Missing composer vendor folder #28

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

Closed
larron opened this issue Apr 16, 2020 · 5 comments
Closed

Missing composer vendor folder #28

larron opened this issue Apr 16, 2020 · 5 comments

Comments

@larron
Copy link

larron commented Apr 16, 2020

When attempting to build from this image and use composer as the documentation suggests, you'll come up short and discover that the vendor folder created by composer will never be written into /var/www/html

This is broken because of the VOLUME /var/www/html in the base image, IE this repository.

Removing the VOLUME declaration from the base image will fix this issue.

@TrafeX
Copy link
Owner

TrafeX commented Apr 18, 2020

Hi @larron,

I'm not sure why the VOLUME declaration conflicts with running composer. Can you give an example?

@james-lukensow
Copy link

@TrafeX I'm seeing the same issue. Sample of what I'm trying to do...

FROM composer:latest AS composer
FROM trafex/alpine-nginx-php7:latest

COPY --from=composer /usr/bin/composer /usr/bin/composer

USER root

#Install php packages for composer
RUN apk add --no-cache php7-simplexml php7-tokenizer php7-xmlwriter

USER nobody

#Set working directory
WORKDIR /var/www/html

COPY --chown=nobody site .
COPY --chown=nobody site/development.env .env
RUN composer install --optimize-autoloader --no-interaction --no-progress

RUN ls -al

COPY ./nginx/nginx.conf /etc/nginx/nginx.conf

EXPOSE 8080

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

After running compose, the vendor folder is never created. Now, if I start up the Dockerfile, and execute into the running container, I can run composer install from the var/www/html directory, then it get's added correctly.

@larron
Copy link
Author

larron commented Apr 20, 2020

@whnunlife that's a perfect example of what is happening. Removing the VOLUME declaration from the base will fix the issue.

@TrafeX
Copy link
Owner

TrafeX commented Apr 20, 2020

Thanks, you both are absolutely right. It's because the RUN instruction is executed in a container with an anonymous volume and that volume is discarded after the command is executed, deleting all contents written to /var/www/html.

I've removed the VOLUME instruction in https://github.com/TrafeX/docker-php-nginx/releases/tag/1.6.0

@TrafeX TrafeX closed this as completed Apr 20, 2020
@james-lukensow
Copy link

@TrafeX Thanks!

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

3 participants