strapi / strapi-docker

Install and run your first Strapi project using Docker
https://strapi.io
MIT License
1.17k stars 445 forks source link

Error: Missing api folder #256

Closed KarthiAru closed 3 years ago

KarthiAru commented 3 years ago

Hi,

I'm getting the missing api folder error. There is an api folder in the project folder.

➜  strapi git:(master) ✗ docker run -it -p 1337:1337 strapi_custom

> my-project@0.1.0 start /srv/app
> strapi start

[2020-10-09T18:45:27.187Z] debug ⛔️ Server wasn't able to start properly.
[2020-10-09T18:45:27.189Z] error Error: Missing api folder. Please create one in your app root directory
    at module.exports (/srv/app/node_modules/strapi/lib/core/load-apis.js:13:11)
    at module.exports (/srv/app/node_modules/strapi/lib/core/load-modules.js:25:5)
    at Strapi.load (/srv/app/node_modules/strapi/lib/Strapi.js:288:27)
    at Strapi.start (/srv/app/node_modules/strapi/lib/Strapi.js:190:20)
    at module.exports (/srv/app/node_modules/strapi/lib/commands/start.js:8:33)
    at /srv/app/node_modules/strapi/bin/strapi.js:56:14
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-project@0.1.0 start: `strapi start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-project@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-10-09T18_45_27_205Z-debug.log

This is my DockerFile

FROM strapi/base
WORKDIR /srv/app
COPY ./my-project/package.json ./
COPY ./my-project/package-lock.json ./
RUN npm install
COPY . .
RUN npm run build
EXPOSE 1337
ENV NODE_ENV production
CMD ["npm", "start"]

This is my-project directory. This was created by running the cli commands npx create-strapi-app my-project and npm run develop

api
build
config
extensions
node_modules
package-lock.json
package.json
public
alexandrebodin commented 3 years ago

Hi, looks like your packge.json COPY is done in a sub folder whereas your COPY . . is done on the parent folder this means you are not mounting your code in the write folder :) have you tried COPY ./-my-project/

KarthiAru commented 3 years ago

@alexandrebodin Thanks. The issue was with mounting the project folder.

This is my working Dockerfile.

FROM strapi/base
WORKDIR /srv/app
COPY ./package.json ./
COPY ./package-lock.json ./
RUN npm install
COPY ./my-project/ /srv/app
RUN npm run build
EXPOSE 1337
ENV NODE_ENV production
CMD ["npm", "start"]