Faisal Shani
Faisal Shani

Reputation: 810

Docker build of strapi image not completing, stuck at localhost address

I am trying to create the docker image of my strapi project with cloud hosted mongodb atlas database. Below is my dockerfile code

FROM strapi/base

COPY ./ ./

RUN npm install

RUN npm run build

RUN npm run start:develop

CMD ["npm","start"]

I am running the below code to build the docker file

docker build .

I am not receiving any error but the problem is building of image is not completing, it sticks at http://localhost:1337. How can I resolve this? I have attached the screenshot . TIA :)

Docker build result

Upvotes: 0

Views: 462

Answers (1)

Eranga Heshan
Eranga Heshan

Reputation: 5814

Your RUN npm run start:develop step is never ending since it is running the server.

You can either write that step in your CMD and remove your existing CMD ["npm","start"], or you can simply remove that step. It depends on your case.

Try the following Dockerfile:

FROM strapi/base

COPY ./ ./

RUN npm install

RUN npm run build

CMD ["npm","start"]

or

FROM strapi/base

COPY ./ ./

RUN npm install

RUN npm run build

CMD ["npm"," run", "start:develop]

Upvotes: 2

Related Questions