Skip to content

Commit

Permalink
fix(metadata): support metadata download durng npm install
Browse files Browse the repository at this point in the history
It turns out the fix for downloading metadata in the Docker images from
#398 did _not_ work.

We need to allow NPM scripts during `npm install` so that, among other
things, better-sqlite3 can install its Node.js bindings.

In the long run, I wonder if we should rethink the entire metadata
approach. Surely it makes sense to treat it as part of the regular
download process like we do the `inventory.json` file for the WOF
download.

But for the short term I wanted to fix the issue without making any
changes to peoples workflows or any significant code changes.

So this PR adds _just_ enough files to the Docker image before `npm
install` is run so that the metadata download will work. We don't want
to copy _all_ the code files first: that would make repeated docker
builds slower during local development. This should be a decent middle
ground that gets things working again.
  • Loading branch information
orangejulius committed Sep 28, 2021
1 parent 7f2362f commit 7effacd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ RUN apt-get update && apt-get install -y bzip2 unzip && rm -rf /var/lib/apt/list
ENV WORKDIR=/code/pelias/geonames
WORKDIR $WORKDIR

# copy files needed to update metadata, as it's called with NPM install
COPY ./bin/updateMetadata.js $WORKDIR/bin/updateMetadata.js
COPY ./lib/tasks/meta.js ./lib/tasks/metafiles.json $WORKDIR/lib/tasks/

# copy package.json first to prevent npm install being rerun when only code changes
COPY ./package.json ${WORKDIR}
RUN npm install --ignore-scripts
RUN npm install

# Copy code into image
ADD . $WORKDIR

# Explicitly download metadata (it will not be downloaded automatically in noninteractive sessions)
RUN npm run download_metadata

# run tests
RUN npm test

Expand Down

0 comments on commit 7effacd

Please sign in to comment.