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

Feat: Docker setup #208

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open

Feat: Docker setup #208

wants to merge 12 commits into from

Conversation

epicadk
Copy link
Member

@epicadk epicadk commented Mar 8, 2021

Description

Added dockerfile and docker-compose.yml that will make it easier to setup the project.

Fixes #207

Type of Change:

  • Code
  • Quality Assurance
  • Outreach
  • Documentation

Code/Quality Assurance Only

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update (software upgrade on readme file)
  • New feature (non-breaking change which adds functionality pre-approved by mentors)

How Has This Been Tested?

Checklist:

  • My PR follows the style guidelines of this project
  • I have performed a self-review of my own code or materials
  • I have commented my code or provided relevant documentation, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged

Code/Quality Assurance Only

  • My changes generate no new warnings
  • My PR currently breaks something (fix or feature that would cause existing functionality to not work as expected)
  • 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 published in downstream modules

@welcome
Copy link

welcome bot commented Mar 8, 2021

Hello there!👋 Welcome to the project!💖

Thank you and congrats🎉 for opening your first pull request.✨ AnitaB.org is an inclusive community, committed to creating a safe and positive environment.🌸Please adhere to our Code of Conduct and Contribution Guidelines.🙌.We will get back to you as soon as we can.😄

Feel free to join us on AnitaB.org Open Source Zulip Community.💖 We have different streams for each active repository for discussions.✨ Hope you have a great time there!😄

config.py Outdated Show resolved Hide resolved
Copy link
Member

@mtreacy002 mtreacy002 left a comment

Choose a reason for hiding this comment

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

@epicadk. I think having docker image is a good idea for newcomers who prefer to choose not to setup on local machine.
But we should give the alternative to run locally for those who prefer to go with this option. I myself prefer to run locally since it is:

  • easier to debug
  • easier to look into the local postgres db and directly manipulate it through running sql command which can be done through either terminal shell or pgadmin4

Like in MS backend, the docker is used only as alternative and the contributors still able to run the application locally if they want to.
So, please make sure the code for this docker setup won't interupt the existing local setup that is already there.

Also, please consider how this will affect the testing, both on local machine or on github action.

Below are my initial feedback. Please address them with the consideration that the application would be able to run both locally and on docker.

config.py Show resolved Hide resolved
config.py Outdated Show resolved Hide resolved
docker-compose.yml Show resolved Hide resolved
app/api/request_api_utils.py Outdated Show resolved Hide resolved
run.py Outdated Show resolved Hide resolved
@mtreacy002 mtreacy002 added Category: Coding Changes to code base or refactored code that doesn't fix a bug. Status: Changes Requested Changes are required to be done by the PR author. Type: Maintenance Repository maintenance. labels Mar 8, 2021
@mtreacy002 mtreacy002 added Status: Needs Review PR needs an additional review or a maintainer's review. and removed Status: Changes Requested Changes are required to be done by the PR author. labels Mar 9, 2021
@epicadk epicadk marked this pull request as ready for review March 9, 2021 13:38
Copy link
Member

@mtreacy002 mtreacy002 left a comment

Choose a reason for hiding this comment

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

@epicadk , please check the comment below.

SQLALCHEMY_DATABASE_URI = BaseConfig.build_db_uri()

# SQLALCHEMY_DATABASE_URI = "postgresql://postgres:postgres@postgres:5432/bit_schema"
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this hard-coded string still?

@@ -0,0 +1,25 @@

Copy link
Member

@mtreacy002 mtreacy002 Mar 9, 2021

Choose a reason for hiding this comment

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

In the local setup, it is important to run the BIT backend first before running the MS backend. This is to make sure that the postgresql database schemas is built correctly using the db models from BIT backend code.
In this scenario (running the app on docker), how do you make sure that this constraint being followed? Should we add build BIT 1st, wait, then build MS next?

Copy link
Member

Choose a reason for hiding this comment

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

Also, how to make sure the docker runs the correct branch on MS and BIT on:

  • normal situation: BIT == develop branch, MS == bit branch (assuming the PR is approved and merged)
  • working on PR: BIT == pr branch, MS == bit branch

Copy link
Member

@mtreacy002 mtreacy002 Mar 9, 2021

Choose a reason for hiding this comment

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

Also, how to inspect postgres db? can we still use the pgadmin4 to connect to this? or we must use command line to inspect potgres inside docker? whichever options are possible, can you please explain this in the setup instruction for docker.

Copy link
Member

Choose a reason for hiding this comment

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

Also, if we want to debug, can you please add instruction on docker on how to do this (command to be run for docker to run in debug mode)?

Copy link
Member

@mtreacy002 mtreacy002 Mar 10, 2021

Choose a reason for hiding this comment

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

I tried to run docker by running docker-compose up and tried to register, but failed. Possible cause is MS being built and run first before BIT which messed up the schemas inside postgres db.
Here's the terminal log.

Copy link
Member

@mtreacy002 mtreacy002 Mar 10, 2021

Choose a reason for hiding this comment

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

I think it is because you set the postgres host to localhost. It should be set to postgers while running the app and to test_postgres while testing it ( If you are using docker).

So I need to add these extra variables inside my local .env? I thought that isn't necessary as docker has it's own env when it sets up postgres within docker? I'm confused 🤔. I looked up POSTGRES_HOST and only found it being setup inside Dockerfile.
Screen Shot 2021-03-10 at 6 15 30 pm

It should be set to postgers while running the app and to test_postgres while testing it ( If you are using docker)
Can you please be specific on how and where exactly we need to do this (set to postgres and test_postgres while running the app using docker). Sorry, I'm a noob here 😉

Copy link
Member Author

@epicadk epicadk Mar 10, 2021

Choose a reason for hiding this comment

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

The bit backend is working fine but the issue is with the MS backend (as can be seen in the error log). I have sent a pr to your initial-bit-integration branch here you'll have to use this branch. Also remember to clean up the containers now that the code has changed remember to rebuild the containers. (You can use make docker-dev and it will handle all of this for you : ) )

Copy link
Member

Choose a reason for hiding this comment

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

Also, how to inspect postgres db? can we still use the pgadmin4 to connect to this? or we must use command line to inspect potgres inside docker? whichever options are possible, can you please explain this in the setup instruction for docker.

You can connect to postgers using the docker command line. There are add-ons that let you use pgadmin4 for the database inside docker. Would you like me to set that up?

Yes please

Copy link
Member

Choose a reason for hiding this comment

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

The bit backend is working fine but the issue is with the MS backend (as can be seen in the error log). I have sent a pr to your initial-bit-integration branch here you'll have to use this branch. Also remember to clean up the containers now that the code has changed remember to rebuild the containers. (You can use make docker-dev and it will handle all of this for you : ) )

you mean the command make docker_host_dev as in the Dockerfile, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh oops yes I meant that.

@mtreacy002 mtreacy002 added Status: Changes Requested Changes are required to be done by the PR author. and removed Status: Needs Review PR needs an additional review or a maintainer's review. labels Mar 10, 2021
@epicadk
Copy link
Member Author

epicadk commented Mar 17, 2021

Marking this as status on hold since docker needs to be setup on the mentorship system backend.

@mtreacy002 mtreacy002 added the Status: On Hold Issue or PR needs more info, a discussion, a review or approval from a Maintainer/Code Owner. label Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. Status: Changes Requested Changes are required to be done by the PR author. Status: On Hold Issue or PR needs more info, a discussion, a review or approval from a Maintainer/Code Owner. Type: Maintenance Repository maintenance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: Alternative way to setup dev environment using docker
2 participants