Skip to content

Commit

Permalink
build: adds database migration method.
Browse files Browse the repository at this point in the history
  • Loading branch information
towfiqi committed Feb 4, 2024
1 parent 34d121d commit dd54e53
Show file tree
Hide file tree
Showing 6 changed files with 770 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .sequelizerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require('path');

module.exports = {
'config': path.resolve('database', 'config.js'),
'models-path': path.resolve('database', 'models'),
'seeders-path': path.resolve('database', 'seeders'),
'migrations-path': path.resolve('database', 'migrations')
};
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# setup the cron
COPY --from=builder --chown=nextjs:nodejs /app/cron.js ./
COPY --from=builder --chown=nextjs:nodejs /app/email ./email
COPY --from=builder --chown=nextjs:nodejs /app/database ./database
COPY --from=builder --chown=nextjs:nodejs /app/.sequelizerc ./.sequelizerc
COPY --from=builder --chown=nextjs:nodejs /app/entrypoint.sh ./entrypoint.sh
RUN rm package.json
RUN npm init -y
RUN npm i cryptr dotenv croner @googleapis/searchconsole
RUN npm i cryptr dotenv croner @googleapis/searchconsole sequelize-cli
RUN npm i -g concurrently

USER nextjs

EXPOSE 3000

ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["concurrently","node server.js", "node cron.js"]
14 changes: 14 additions & 0 deletions database/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
production: {
username: process.env.USER_NAME ? process.env.USER_NAME : process.env.USER,
password: process.env.PASSWORD,
database: 'sequelize',
host: 'database',
port: 3306,
dialect: 'sqlite',
storage: './data/database.sqlite',
dialectOptions: {
bigNumberStrings: true,
},
},
};
3 changes: 3 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
npx sequelize-cli db:migrate --env production
exec "$@"
Loading

0 comments on commit dd54e53

Please sign in to comment.