'Why the starting command for my Strapi project fails within the Docker environment
I am trying to dockerize my strapi application, but the entrypoint command fails with:
error bootstrap function in plugin "documentation" failed
error TypeError: Cannot read property 'attributes' of undefined
at Object.keys.reduce.required (/usr/srv/app/backend/node_modules/strapi-plugin-documentation/services/Documentation.js:591:42)
at Array.reduce (<anonymous>)
at Object.generateMainComponent (/usr/srv/app/backend/node_modules/strapi-plugin-documentation/services/Documentation.js:540:36)
at Object.generateResponseComponent (/usr/srv/app/backend/node_modules/strapi-plugin-documentation/services/Documentation.js:1001:32)
at /usr/srv/app/backend/node_modules/strapi-plugin-documentation/services/Documentation.js:165:53
at Array.reduce (<anonymous>)
at Object.createDocumentationFile (/usr/srv/app/backend/node_modules/strapi-plugin-documentation/services/Documentation.js:161:42)
at Object.checkIfAPIDocNeedsUpdate (/usr/srv/app/backend/node_modules/strapi-plugin-documentation/services/Documentation.js:45:60)
at /usr/srv/app/backend/node_modules/strapi-plugin-documentation/config/functions/bootstrap.js:64:43
at Array.forEach (<anonymous>)
at module.exports (/usr/srv/app/backend/node_modules/strapi-plugin-documentation/config/functions/bootstrap.js:52:8)
at async Promise.all (index 2)
at async Strapi.runLifecyclesFunctions (/usr/srv/app/backend/node_modules/strapi/lib/Strapi.js:443:5)
at async Strapi.load (/usr/srv/app/backend/node_modules/strapi/lib/Strapi.js:379:5)
at async Strapi.start (/usr/srv/app/backend/node_modules/strapi/lib/Strapi.js:196:9)
The project is starting without any issues on my mac. I've tried the solution from here that implies removing the node_modules files and installing again, but without luck. I've also tried to start from different strapi images (with node-14,alphine etc). Do you guys have any idea about how I could solve this error or what's the cause of it? I am pretty new with the docker, maybe it's something wrong with the volumes? The other services from my docker-compose are working just fine.
This is my docker-compose file
version: "3.9"
services:
web:
build:
context: .
dockerfile: ./docker/nginx/Dockerfile
container_name: web
restart: always
environment:
NEXT_API_LOCAL_DOMAIN: strapi
volumes:
- ./app-f:/srv/app
ports:
- "3000:3000"
depends_on:
- strapi
networks:
- strapi
strapi:
container_name: strapi
build:
context: .
dockerfile: ./docker/backend/Dockerfile
volumes:
- ./app:/srv/app
environment:
DATABASE_CLIENT: mysql
DATABASE_HOST: mysql
DATABASE_PORT: 3306
DATABASE_NAME: strapi
DATABASE_USERNAME: strapi
DATABASE_PASSWORD: strapi
DATABASE_SSL: "false"
ports:
- "1337:1337"
depends_on:
- mysql_db
networks:
- strapi
mysql_db:
container_name: mysql
image: mysql:5.7
restart: always
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_DATABASE: strapi
MYSQL_USER: strapi
MYSQL_PASSWORD: strapi
MYSQL_ROOT_PASSWORD: strapi
volumes:
- ./.db:/var/lib/mysql
- ./backend/database_export/database_backup.sql:/docker-entrypoint-initdb.d/database_backup.sql:ro
networks:
- strapi
networks:
strapi:
name: Strapi
driver: bridge
This is my dockerfile
FROM strapi/strapi:3.6.8-node12
# Set Environment to Production Environment (Optional to include in Dockerfile)
ENV NODE_ENV staging
# Set up working directory that will be used to copy files/directories below :
WORKDIR /usr/srv/app/backend/
# Copy package.json to root directory inside Docker container of Strapi app
COPY ./backend/package.json .
RUN npm install
COPY ./backend/favicon.ico .
COPY ./backend/public/robots.txt ./public/
COPY ./backend/extensions/ ./extensions/
COPY ./backend/api/ ./api/
COPY ./backend/config/ ./config/
COPY ./backend/data/ ./data/
COPY ./backend/public/ ./public/
RUN npm run build --clean
ENTRYPOINT ["npm","start"]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
