I am trying to host a Strapi instance in a Docker container using a distroless image. As I am using a distroless image, I cannot use the npm command to run Strapi. Is there an equivalent of the strapi start
command that can be run purely using Node?
Here is my summarised Dockerfile:
FROM node:16-alpine as build
# Build steps
# ...
FROM gcr.io/distroless/nodejs:16 as host
WORKDIR /opt/app
COPY --from=build /opt/app ./
EXPOSE 1337
CMD ["yarn", "start"]
As I mentioned, this Dockerfile cannot be used with a distroless image since it uses npm command in the CMD line. What changes should I make to my Dockerfile to use Strapi with a distroless image without using the npm command?
So the right path is ./node_modules/@strapi/strapi/bin/strapi.js
Here's the updated Dockerfile
FROM gcr.io/distroless/nodejs:16 as host
WORKDIR /opt/app
COPY --from=build /opt/app ./
EXPOSE 1337
CMD ["./node_modules/@strapi/strapi/bin/strapi.js", "start"]
Take note that you should not use alpine to build the application when you are using distroless. Use the node base image.
FROM node:16.20 as build