Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Containerize backend app and MySQL database. #230

Merged
merged 12 commits into from
May 24, 2024
Merged

Conversation

Justin-Fernbaugh
Copy link
Member

Pull Request Template

Screenshots

Description

Firstly, I created a container for the NodeJS backend in the Dockerfile. Secondly, utilized docker-compose to deploy the backend container and MySQL container. Important to note, that the dev and test databases are created using db/init.sql. Seeding and migration are done only on the first run using entrypoint.sh which creates CONTAINER_FIRST_STARTUP inside the container to track whether initialization needs to occur.

Fixes # (issue)

Additional Information

Checklist:

Before you submit your Pull Request, please make sure you have completed the following tasks:

  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.
  • I have tagged my PR with the appropriate label(s).

@Justin-Fernbaugh Justin-Fernbaugh self-assigned this May 23, 2024
@Justin-Fernbaugh Justin-Fernbaugh requested review from a team and nilsstreedain and removed request for a team May 23, 2024 19:18
@Justin-Fernbaugh Justin-Fernbaugh requested a review from a team May 23, 2024 19:36
@nilsstreedain
Copy link
Member

nilsstreedain commented May 23, 2024

I followed the commands added in the server/README.md but I'm having some issues getting it running. I'm getting the following output from myclassroom_backend, could I be doing something wrong here?

2024-05-23 14:26:11 Container first start intializing database...
2024-05-23 14:26:12 
2024-05-23 14:26:12 Sequelize CLI [Node: 22.2.0, CLI: 6.5.2, ORM: 6.37.3]
2024-05-23 14:26:12 
2024-05-23 14:26:12 Loaded configuration file "config/db.config.js".
2024-05-23 14:26:12 Using environment "test".
2024-05-23 14:26:12 
2024-05-23 14:26:12 
2024-05-23 14:26:12 Completed migrating and seeding databases.
2024-05-23 14:26:12 
2024-05-23 14:26:12 > myclassroom@1.0.0 start:dev
2024-05-23 14:26:12 > nodemon app/server.js --NODE_ENV=development
2024-05-23 14:26:12 
2024-05-23 14:26:12 [nodemon] 3.1.0
2024-05-23 14:26:12 [nodemon] to restart at any time, enter `rs`
2024-05-23 14:26:12 [nodemon] watching path(s): *.*
2024-05-23 14:26:12 [nodemon] watching extensions: js,mjs,cjs,json
2024-05-23 14:26:12 [nodemon] starting `node app/server.js --NODE_ENV=development`
2024-05-23 14:26:12 [2024-05-23 09:26:12.581 PM] ERROR:         Unable to connect to sequelize database
2024-05-23 14:26:12 [2024-05-23 09:26:12.582 PM] ERROR:         Plugin 'mysql_native_password' is not loaded
2024-05-23 14:26:12 SequelizeConnectionError: Plugin 'mysql_native_password' is not loaded
2024-05-23 14:26:12     at ConnectionManager.connect (/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:102:17)
2024-05-23 14:26:12     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-05-23 14:26:12     at async ConnectionManager._connect (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:222:24)
2024-05-23 14:26:12     at async /app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:174:32
2024-05-23 14:26:12     at async ConnectionManager.getConnection (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:197:7)
2024-05-23 14:26:12     at async /app/node_modules/sequelize/lib/sequelize.js:305:26
2024-05-23 14:26:12     at async Sequelize.authenticate (/app/node_modules/sequelize/lib/sequelize.js:457:5)
2024-05-23 14:26:12 [nodemon] clean exit - waiting for changes before restart
2024-05-23 14:26:12 ERROR: Plugin 'mysql_native_password' is not loaded

@Justin-Fernbaugh
Copy link
Member Author

I followed the commands added in the server/README.md but I'm having some issues getting it running. I'm getting the following output from myclassroom_backend, could I be doing something wrong here?

2024-05-23 14:26:11 Container first start intializing database...
2024-05-23 14:26:12 
2024-05-23 14:26:12 Sequelize CLI [Node: 22.2.0, CLI: 6.5.2, ORM: 6.37.3]
2024-05-23 14:26:12 
2024-05-23 14:26:12 Loaded configuration file "config/db.config.js".
2024-05-23 14:26:12 Using environment "test".
2024-05-23 14:26:12 
2024-05-23 14:26:12 
2024-05-23 14:26:12 Completed migrating and seeding databases.
2024-05-23 14:26:12 
2024-05-23 14:26:12 > myclassroom@1.0.0 start:dev
2024-05-23 14:26:12 > nodemon app/server.js --NODE_ENV=development
2024-05-23 14:26:12 
2024-05-23 14:26:12 [nodemon] 3.1.0
2024-05-23 14:26:12 [nodemon] to restart at any time, enter `rs`
2024-05-23 14:26:12 [nodemon] watching path(s): *.*
2024-05-23 14:26:12 [nodemon] watching extensions: js,mjs,cjs,json
2024-05-23 14:26:12 [nodemon] starting `node app/server.js --NODE_ENV=development`
2024-05-23 14:26:12 [2024-05-23 09:26:12.581 PM] ERROR:         Unable to connect to sequelize database
2024-05-23 14:26:12 [2024-05-23 09:26:12.582 PM] ERROR:         Plugin 'mysql_native_password' is not loaded
2024-05-23 14:26:12 SequelizeConnectionError: Plugin 'mysql_native_password' is not loaded
2024-05-23 14:26:12     at ConnectionManager.connect (/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:102:17)
2024-05-23 14:26:12     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-05-23 14:26:12     at async ConnectionManager._connect (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:222:24)
2024-05-23 14:26:12     at async /app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:174:32
2024-05-23 14:26:12     at async ConnectionManager.getConnection (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:197:7)
2024-05-23 14:26:12     at async /app/node_modules/sequelize/lib/sequelize.js:305:26
2024-05-23 14:26:12     at async Sequelize.authenticate (/app/node_modules/sequelize/lib/sequelize.js:457:5)
2024-05-23 14:26:12 [nodemon] clean exit - waiting for changes before restart
2024-05-23 14:26:12 ERROR: Plugin 'mysql_native_password' is not loaded

I don't think it's related to anything you did; Might just be a machine difference. Just pushed an update to use legacy authentication and we'll see if that fixes it

Copy link
Member

@nilsstreedain nilsstreedain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, tested and fully working!

@Justin-Fernbaugh Justin-Fernbaugh added this pull request to the merge queue May 24, 2024
Merged via the queue into dev with commit 07e1c60 May 24, 2024
2 checks passed
@Justin-Fernbaugh Justin-Fernbaugh deleted the fernbauj/docker branch May 24, 2024 00:16
@nilsstreedain nilsstreedain mentioned this pull request May 24, 2024
8 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants