Issue
I have dockerized a react native web. And I created the production folder in the root folder web-build with the command: npx expo export:web
And without docker. If I browse to the folder web-build and do a npx serve the app starts on url: http://localhost:3000
And I can build the image with the command docker compose -f docker-compose-prod.yml build
. So this I have for the dockerfile:
# pull base image
FROM node:lts-alpine
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV
ARG PORT=19006
ENV PORT $PORT
EXPOSE $PORT 19001 19002
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH /home/node/.npm-global/bin:$PATH
RUN npm i --unsafe-perm --allow-root -g npm@latest expo-cli@latest
RUN mkdir /opt/dwl_frontend
WORKDIR /opt/dwl_frontend
ENV PATH /opt/dwl_frontend/.bin:$PATH
COPY package.json yarn.lock ./
RUN yarn
RUN yarn install
WORKDIR /opt/dwl_frontend
COPY ./ ./
ENTRYPOINT [ "npx", "serve" ]
But the problem I am facing is that if I run the image with: docker compose -f docker-compose-prod.yml up
then the app starts with url: INFO Accepting connections at http://localhost:19006
But if I go to that url. I see the directory structure:
Index of dwl_frontend/. And I see the content and folders of the root folder. But the actual app is not loading.
Question: how to run the docker container using the web-build folder?
Solution
By using
npx serve web-build
So your entry point should look like this
ENTRYPOINT [ "npx", "serve", "web-build" ]
Answered By - Brendan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.