2
votes

I am trying to create Docker file for my Laravel rest Api with Vue.js in the backend Docker file when I tried to run php artisan serve I am getting the error below.

Could not open input file: artisan The command 'php artisan serve' returned a non-zero code: 1

FROM php:7.2.19-fpm

RUN mkdir ./my-project/

WORKDIR /my-project
COPY . ./my-project/

RUN apt-get update

RUN cd my-project

FROM composer:1.7 as vendor

COPY database/ database/

COPY composer.json composer.json
COPY composer.lock composer.lock

RUN composer install \
    --ignore-platform-reqs \
    --no-interaction \
    --no-plugins \
    --no-scripts \
    --prefer-dist


RUN ["php", "artisan", "serve"]

EXPOSE 8000
1
Is it possible that the second FROM negates the WORKDIR? Could you try it out? Also the copy probably - online Thomas
Nothing before the FROM composer... line has any effect in this Dockerfile. Specifying a new FROM image starts anew with just the contents of that base image. Usually this is used for a multi-stage build where you COPY --from=... artifacts that got built in an earlier stage. - David Maze

1 Answers

-1
votes

Use full paths for WORKDIR and COPY

Give this a try:

FROM php:7.2-cli
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
CMD [ "php", "./your-script.php" ]

Also, as mentioned above, the second FROM starts a new build stage for VENDOR.