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

Container crashes when using sqlite as DB dialect #97

Open
simplylu opened this issue Dec 19, 2022 · 2 comments
Open

Container crashes when using sqlite as DB dialect #97

simplylu opened this issue Dec 19, 2022 · 2 comments
Assignees
Labels
kind/bug Something isn't working kind/dependencies Pull request that updates a dependency file kind/docker Everything that has to do with docker

Comments

@simplylu
Copy link

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"]
@simplylu simplylu added the kind/bug Something isn't working label Dec 19, 2022
@luwol03
Copy link
Member

luwol03 commented Dec 19, 2022

Hello @js-on,

this is currently a bug which has not been fixed. It definitely was working sometime before. We have a custom postinstall hook, which normally should install sqlite if the --sqlite flag is used on npm ci --sqlite. Normally this should also work inside of the builder stage, but it could be that some native stuff is not correctly copied.

@luwol03 luwol03 added kind/dependencies Pull request that updates a dependency file kind/docker Everything that has to do with docker labels Dec 19, 2022
@noctera
Copy link
Member

noctera commented Dec 20, 2022

In the meantime, however, there are two ways to fix this problem.

  1. Use a different database than Sqlite3, for example Postgresql. This lets you get your server up and running.
  2. Either your way directly modifying the docker build script file, or write a wrapper around it, as shown below:
    create a "Dockerfile" in your directory with the following content:
FROM vocascan/server:latest

RUN npm install sqlite3

After that update your "docker-compose.yml" file and add the "build" property and remove the "image" property. This could look like this:

version: "3.8"
services:
vocascan:
  restart: always
  build:
    context: .
    dockerfile: Dockerfile
  tty: true
  environment:
    VOCASCAN_CONFIG: "/etc/vocascan/vocascan.config.js"
  ports:
    - "8000:8000"
  volumes:
    - "./vocascan.config.js:/etc/vocascan/vocascan.config.js:ro"

This will pull the vocascan/server image as base image, and will build a local image with the sqlite3 npm package installed. I just tested it locally, with success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working kind/dependencies Pull request that updates a dependency file kind/docker Everything that has to do with docker
Projects
None yet
Development

No branches or pull requests

3 participants