Any way to use a custom Dockerfile for building static sites on Now v2?February 26, 2020 at 2:23pm
I've been searching, but can't find it anywhere.
We've been using Now to host our CRA for a while, since v1, and use a custom Dockerfile to build it. This is because we fetch packages from our private Bitbucket repository, and need some commands to set up the proper SSH keys before running
The file looks like this:
FROM mhart/alpine-node:12.13.1 as baseWORKDIR /usr/srcRUN apk update && apk add openssh && apk add gitRUN git config --global url."email@example.com:".insteadOf "https://bitbucket.org/"RUN mkdir /root/.sshRUN touch /root/.ssh/known_hostsRUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hostsARG SSH_KEYRUN echo "$SSH_KEY" | base64 -d > /root/.ssh/id_rsaRUN chmod 600 /root/.ssh/id_rsa# You want to move these two files only first and then install,# because that will cache the dependencies for the next build.COPY yarn.lock package.json ./RUN yarn install --network-concurrency 1ARG REACT_APP_API_ENDPOINTARG REACT_APP_VERSIONARG REACT_APP_GOOGLE_MAPS_KEYARG REACT_APP_GOOGLE_OAUTH_CLIENT_IDARG REACT_APP_ENVARG NODE_ENVCOPY . .RUN sh build.shFROM mhart/alpine-node:12.13.1WORKDIR /public# Copy over the files from the build container srcCOPY --from=base /usr/src/build /public
However, lately we've had some users experiencing being shown a Zeit 404 page when hard-refreshing our webapp all of a sudden. We can't find any reason why this should happen, and out of sheer desperation, I'm now investigating moving our deployment and the pipelines to Now v2, and ran into this issue promptly. Searching for a solution, it seems that guides and examples show how to use private NPM packages, not private Git-hosted packages (i.e.
How would I go about achieving this in v2?
February 26, 2020 at 2:31pm
Note: Removed the
Dockerfile mentioned above due to this guide. Also tried committing with it back in, but the build process doesn't seem to use it for anything.
I'd prefer to deploy manually using commands instead of using the Git integration, but I tried the latter as well, hoping that it could solve the issue. However, whenever I press "Connect with Bitbucket" it just connects to my own profile rather than the team profile where all the repositories are hosted, and never gives me the option to choose.
March 4, 2020 at 4:27pm
For anyone finding this, we ended up building the app on our CircleCI and then deploying to Now, allowing us to control the entires build process better and reuse our Dockerfile to a large extent. Another approach could be moving the Dockerfile commands to shell scripts and run those, but we had issues fetching private Bitbucket dependencies using the previously used SSH keys, so we went another way