Skip to content

Container crashes when using sqlite as DB dialect #97

@simplylu

Description

@simplylu

Describe the bug
Docker container crashes on startup when current Dockerfile is used for the build or the official image, and one selects sqlite as DB backend.

To Reproduce
Steps to reproduce the behavior:
Via Dockerfile

  1. Clone repository
  2. Build docker container using docker build
  3. Change DB backend to sqlite
  4. Use official traefik installation way to start the container
  5. Container won't start, the docs will produce the below stacktrace

Via official container

  1. Use official traefik installation way to start the container
  2. Change DB backend to sqlite
  3. Container won't start, the docs will produce the below stacktrace

Expected behavior
Container should start without any problems.

Desktop (please complete the following information):

  • OS: Docker version 20.10.21, build baeda1f
  • node version: node-14.21.2
  • npm version: 6.14.17
  • database dialect: sqlite
  • commit ref: ae77ac3

Additional context
Traceback

info: loaded config file "/etc/vocascan/vocascan.config.js"
error: unhandledRejection: Please install sqlite3 package manually
Error: Please install sqlite3 package manually
    at ConnectionManager._loadDialectModule (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:81:15)
    at new ConnectionManager (/app/node_modules/sequelize/lib/dialects/sqlite/connection-manager.js:24:21)
    at new SqliteDialect (/app/node_modules/sequelize/lib/dialects/sqlite/index.js:15:30)
    at new Sequelize (/app/node_modules/sequelize/lib/sequelize.js:340:20)
    at Object.db.init (/app/database/index.js:34:20)
    at createServer (/app/server.js:22:12)
    at Command.<anonymous> (/app/cmd/web.js:18:26)
    at Command.listener [as _actionHandler] (/app/node_modules/commander/lib/command.js:488:17)
    at /app/node_modules/commander/lib/command.js:1227:65

Possible solution:
I changed the Dockerfile to the following, and at least the error disappeared. Need to test further whether the container works as expected or not.

FROM node:14-alpine as builder

RUN apk add --no-cache build-base python3

WORKDIR /build

COPY ./package*.json ./

RUN npm i --only=production

FROM node:14-alpine

WORKDIR /app

COPY --from=builder /build/node_modules /app/node_modules

COPY . .

RUN npm link

# Added this line explicitly. Adding it in the builder context didn't work somehow.
RUN npm install sqlite3

CMD ["vocascan-server", "web"]

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't workingkind/dependenciesPull request that updates a dependency filekind/dockerEverything that has to do with docker

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions