Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run build creating different artifacts in different environments #11222

Closed
eric-angelo-kim opened this issue Jul 19, 2021 · 0 comments
Closed

Comments

@eric-angelo-kim
Copy link

Hello,

I am loosely following the set up described here: https://www.datagraphi.com/blog/post/2020/8/30/docker-guide-build-a-fully-production-ready-machine-learning-app-with-react-django-and-postgresql-on-docker

I am finding that when I run npm run build in Docker, the filename hashes differ from what is in index.html, so nothing shows on browser. I'm not entirely sure how that is happening, since I don't believe I am doing anything different from local. The command runs fine in local.

The Docker file in questtion:

###########
# BUILDER #
###########

# pull official base image
FROM node:12.18.3-alpine3.9 as builder

# set work directory
WORKDIR /usr/src/app

# install dependencies and avoid `node-gyp rebuild` errors
COPY ./react_app/package.json .
RUN apk add --no-cache --virtual .gyp \
        python \
        make \
        g++ \
    && npm install \
    && apk del .gyp

# copy our react project
COPY ./react_app .

# perform npm build
ARG API_SERVER
ENV REACT_APP_API_SERVER=${API_SERVER}
RUN REACT_APP_API_SERVER=${API_SERVER} \ 
  npm run build

#########
# FINAL #
#########

# pull official base image
FROM node:12.18.3-alpine3.9 

# set work directory
WORKDIR /usr/src/app

# install serve - deployment static server suggested by official create-react-app
RUN npm install -g serve

# copy our build files from our builder stage
COPY --from=builder /usr/src/app/build ./build

Do you know what would be points to check during debugging? I tried running the command ENV_API_SERVER=http://127.0.0.1 npm run build locally, and confirmed that the build dir and the artifact filenames have the right hash. Not sure what could be different in Docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant