System Information
- Strapi Version: 4.7.0
- Operating System: Alpine, docker
- Database: Postgres 13
- Node Version: 18.14.2
- NPM Version: 9.5.0
- Yarn Version: n/a
This is related to the problem in the topic Deployed strapi admin panel trying to hit localhost:1337
However I have applied the accepted solution for that topic and the problem still occurs - I have specified NODE_ENV=production
during both build and deployment. There appears to be something else going on.
I have had this problem intermittently which upgrading to the last few Strapi versions. I generally loose several hours each time trying all sorts of changes until it suddenly starts working, and continues working even when I revert the changes.
Please see my Dockerfile
below
# syntax=docker/dockerfile:1
FROM node:18-alpine
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV
ARG STRAPI_ADMIN_BACKEND_URL='https://my-site.com'
ENV STRAPI_ADMIN_BACKEND_URL $STRAPI_ADMIN_BACKEND_URL
ENV PORT=8080
EXPOSE $PORT
ENV PATH /home/node/node_modules/.bin:$PATH
CMD ["strapi", "start"]
WORKDIR /home/node
RUN mkdir -p src/plugins/my-project/node_modules src/plugins/my-project/dist
RUN chown node.node src/plugins/my-project/node_modules src/plugins/my-project/dist
USER node
COPY package-lock.json package.json ./
RUN npm ci --omit=optional && npm cache clean --force
COPY . .
RUN cd src/plugins/my-project && npm ci --omit=dev --omit=optional && npm cache clean --force
RUN strapi build
USER root
RUN chown -R node.node src/plugins/my-project/dist
USER node
RUN cd src/plugins/my-project && npm run build