1

Dockerfile

FROM node:16.14.2-alpine as build

WORKDIR /myapp
COPY package*.json ./
RUN npm ci

COPY . ./
ENV NODE_ENV='dev'
RUN npm run build

FROM build

EXPOSE 3000
CMD ["node"] // list reduced to one item

// .sequelizerc

const path = require('path');

module.exports = {
  'config': path.resolve('/src', 'dbconfig.js'),
  'models-path': path.resolve('src', 'models')
};

Structure

- src
   - dbconfig.js
- .sequelizerc

When running on docker i get the error

ERROR: Cannot find "/app/config/config.json". Have you run "sequelize init"?
myselfmiqdad
  • 2,518
  • 2
  • 18
  • 33

1 Answers1

0

You have to define .sequelizerc file in root folder specifying path to your database config, migration and seeders folder,otherwise sequelize will looks for them in its default location. It will look somewhat like this

//.sequelize.rc file
module.exports = {
    'config': /* Path to db config file */,
    'migrations-path': /* Path to migration folder */,
    'seeders-path': /* Path to seeders folder */,
    'models-path': /* Path to models folder */,
}

Note: After creating this file you have to rebuild the docker image for it to work.