Reputation: 1952
I'm trying to create a container that installs one of my apps.
In this application, I have to do a composer install
at the root but also in a sub-folder.
In my dockerfile I do this:
# Switch to non-root 'app' user & install app dependencies
COPY composer.json composer.lock ./
RUN chown -R $NON_ROOT_USER:$NON_ROOT_GROUP $LARAVEL_PATH
USER $NON_ROOT_USER
# Install composer in base directoru
RUN composer install --prefer-dist --no-scripts --no-dev --no-autoloader
# Here I want to go to subfolder
RUN ls -la
RUN cd ./web/app/themes/sage
RUN composer install --prefer-dist --no-scripts --no-dev --no-autoloader
RUN rm -rf /home/$NON_ROOT_USER/.composer
The problem is, I'm getting the following error:
can't cd to ./web/app/themes/sage: No such file or directory
However, when I look at the build, I do RUN ls -la
and see the correct file architecture with my existing "web" folder.
How to do ?
Upvotes: 1
Views: 2058
Reputation: 96
You can use WORKDIR
to change working directory. So replace RUN cd ./web/app/themes/sage
with WORKDIR /web/app/themes/sage
Upvotes: 1