Skip to content

Commit

Permalink
Fix production build
Browse files Browse the repository at this point in the history
## Description

I don't quite understand everything that's going on here, but this
will get main deployable again.

Summary: the production Docker image build does not put a prebuilt
binary for the `sqlite3` package into the image, ever since I added
`sqlite3@^5.1.5` as an explicit dependency in #488.  I don't know why.
The package was already being installed (as a dependency of
`fastify-sqlite`) but adding the explicit dependency somehow changed
how it gets installed.

Upping the dependency to 5.1.7 fixes the problem. It causes 5.1.5 to
be installed within `node_modules/fastify-sqlite/node_modules` in the
prod image, with the prebuilt binary present. (5.1.7 is not installed
in the prod image at all, as I'd expect, since it's under
`devDependencies`.)

I'm also adding `--frozen-lockfile` to the yarn invocations in the
Dockerfile; I don't think they're strictly necessary (and they're
definitely not necessary to fix this), but that should eliminate one
other possible source of confusion/problems, especially while
debugging weird issues like this.

## Test Plan

Run the server with `yarn dev`; make test requests and ensure they succeed.

Run:

- `docker build -t incentives-api:latest .`
- `docker run --rm -it -p 8080:8080 incentives-api:latest`
- Make sure the server starts up and can serve requests
  • Loading branch information
oyamauchi committed Jun 24, 2024
1 parent 2234484 commit 63327cf
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /app
COPY package.json .
COPY tsconfig.json .
COPY yarn.lock .
RUN yarn
RUN yarn --frozen-lockfile

# Compile Typescript
COPY src src
Expand All @@ -27,7 +27,7 @@ WORKDIR /app
# install node dependencies (without dev)
COPY package.json .
COPY yarn.lock .
RUN yarn --production
RUN yarn --frozen-lockfile --production

# Copy build products
COPY --from=builder /app/build build
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"prettier": "^3.0.3",
"prettier-plugin-multiline-arrays": "^3.0.0",
"prettier-plugin-organize-imports": "^3.2.3",
"sqlite3": "^5.1.5",
"sqlite3": "^5.1.7",
"tap": "^18.6.1",
"ts-morph": "^21.0.1",
"ts-node": "^10.9.1",
Expand Down
Loading

0 comments on commit 63327cf

Please sign in to comment.