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

Added Docker Support to Talawa Admin, Fixes #1075 #1726

Closed
wants to merge 10 commits into from

Conversation

vasujain275
Copy link

@vasujain275 vasujain275 commented Mar 14, 2024

What kind of change does this PR introduce?

This PR add Docker Support to Talawa Admin.

Issue Number:

Did you add tests for your changes?

N/A

Snapshots/Videos:

If relevant, did you update the documentation?

N/A

Summary

1. Introduction of Docker Support:

  • This PR adds Docker support to Talawa Admin.
  • This enhancement aims to facilitate a smoother developer experience, especially for individuals contributing to Talawa API and Talawa App.

2. Consideration of Docker Methods:

  • Initially, the idea was to implement two Docker methods - dev and production.
  • However, upon scrutinizing the codebase, it was discovered that we are utilizing Create React App and react scripts for the build process.
  • The current build process is evidently not optimized for either production-ready minified binaries or Docker hot reloading.

3. Proposal for Build Process Improvement:

  • To address this limitation, I think we should migrate to a more suitable build process like Vite.
  • This migration is necessary to enable efficient building of both minified production-ready build files and Docker hot reloading.

4. Planned Actions:

  • After this PR is merged, I will raise an issue to migrate from React scripts to the Vite build process, we can have further discussion on build process there.
  • This action will lay the groundwork for future improvements in better and improved Docker support once the Build Process is sorted.

5. Current Status:

  • Currently, separate dev and prod Docker methods have not been implemented due to the inadequacy of the existing build process.
  • The current build process cannot produce minified production-ready build files, and a dev hot reloading Docker setup would be impractical due to the same issue.

Does this PR introduce a breaking change?

No

Other information

You can test the current Docker Installtion process by using -

npm run dx-prod

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • New Features

    • Introduced a Docker setup for the application.
    • Added a new script for Docker operations (dx-prod).
  • Chores

    • Updated .dockerignore and .eslintignore files to optimize builds and linting.
    • Updated package.json with new and updated dependencies (dotenv, inquirer).
  • Configuration

    • Updated docker-compose.yml to configure the application service, set environment variables, and expose port 4321.

Copy link

Our Pull Request Approval Process

We have these basic policies to make the approval process smoother for our volunteer team.

Testing Your Code

Please make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. Merge conflicts

The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congratulations on making your first PR! 🎊 If you haven't already, check out our Contributing Guidelines and PR Reporting Guidelines to ensure that you are following our guidelines for contributing and creating PR.

Copy link

codecov bot commented Mar 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.55%. Comparing base (05aaf09) to head (c27e841).

Current head c27e841 differs from pull request most recent head 2b82c9d

Please upload reports for the commit 2b82c9d to get more accurate results.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1726      +/-   ##
===========================================
- Coverage    98.43%   97.55%   -0.88%     
===========================================
  Files          221      177      -44     
  Lines         5945     4385    -1560     
  Branches      1734     1258     -476     
===========================================
- Hits          5852     4278    -1574     
- Misses          87      103      +16     
+ Partials         6        4       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Cioppolo14
Copy link

@Tajcore @beingnoble03 Can you review this PR?

@palisadoes
Copy link
Contributor

This is an update on the PR merging freeze:

  1. In the next few hours we will be merging the develop-userTypeFix branch into the develop branch.
  2. The develop-userTypeFix branch was created to fix a long standing design flaw where Admins were Admins of all organizations, not specific ones.
  3. The userType field has been removed from the User collection and it has been replaced by an appUserProfileId field.
    1. This field is null if the user isn’t registered to use the apps. This will help people to add users manually during the event checkin process, or if an Admin wants to manually add someone in the Admin dashboard.
    2. When not null the AppUserProfileID will reference a AppUserProfile collection with App related information such as the organizations for which a user may be an Admin.
    3. The updated schema can be found here https://github.com/PalisadoesFoundation/talawa-api/blob/develop-userTypeFix/schema.graphql
    4. This is the parent issue that we have been using to track progress:
      1. PARENT ISSUE: Fix the usage of userType talawa-api#1965
  4. This merge will cause some conflicts in your PR.

We decided to do this at the beginning of the weekend to give us all time to adjust PR code and create bug fixes that may arise.

Update your code at or after midnight GMT on the morning of March 23, 2024. (5:30am IST).

If your PRs have already been approved, request a re-review after fixing the conflicts and refactoring to the new AppUserProfileID methodology.

@palisadoes
Copy link
Contributor

The PR merging freeze is lifted.

  1. We are working on bug fixes that may arise. These should be few and are being tracked here:
    1. https://github.com/orgs/PalisadoesFoundation/projects/24
  2. Please update your PRs and local repos. Fix any new merge conflicts that may have occurred.

Background:

  1. The develop-userTypeFix branch was created to fix a long standing design flaw where Admins were Admins of all organizations, not specific ones.
  2. The userType field has been removed from the User collection and it has been replaced by an appUserProfileId field.
    1. This field is null if the user isn’t registered to use the apps. This will help people to add users manually during the event checkin process, or if an Admin wants to manually add someone in the Admin dashboard.
    2. When not null the AppUserProfileID will reference a AppUserProfile collection with App related information such as the organizations for which a user may be an Admin.
    3. The updated schema can be found here https://github.com/PalisadoesFoundation/talawa-api/blob/develop-userTypeFix/schema.graphql
    4. This is the parent issue that we have been using to track progress:
      1. PARENT ISSUE: Fix the usage of userType talawa-api#1965
  3. If your PRs have already been approved, request a re-review after fixing the conflicts and refactoring to the new AppUserProfileID methodology.

1 similar comment
@palisadoes
Copy link
Contributor

The PR merging freeze is lifted.

  1. We are working on bug fixes that may arise. These should be few and are being tracked here:
    1. https://github.com/orgs/PalisadoesFoundation/projects/24
  2. Please update your PRs and local repos. Fix any new merge conflicts that may have occurred.

Background:

  1. The develop-userTypeFix branch was created to fix a long standing design flaw where Admins were Admins of all organizations, not specific ones.
  2. The userType field has been removed from the User collection and it has been replaced by an appUserProfileId field.
    1. This field is null if the user isn’t registered to use the apps. This will help people to add users manually during the event checkin process, or if an Admin wants to manually add someone in the Admin dashboard.
    2. When not null the AppUserProfileID will reference a AppUserProfile collection with App related information such as the organizations for which a user may be an Admin.
    3. The updated schema can be found here https://github.com/PalisadoesFoundation/talawa-api/blob/develop-userTypeFix/schema.graphql
    4. This is the parent issue that we have been using to track progress:
      1. PARENT ISSUE: Fix the usage of userType talawa-api#1965
  3. If your PRs have already been approved, request a re-review after fixing the conflicts and refactoring to the new AppUserProfileID methodology.

@Cioppolo14
Copy link

@vasujain275 Can you fix the linting test issue?

@vasujain275
Copy link
Author

@Cioppolo14 Sorry for the late response, I was not well. Can you link me to the issue you are referring to?

@palisadoes
Copy link
Contributor

  1. There is a linting test that is failing. You need to submit your PR using a different source branch. This requirement was implemented 2-3 weeks ago
  2. Either close this PR or update it with a source branch with a different name.

@Cioppolo14
Copy link

@vasujain275 Please fix the linting issue.

@Cioppolo14 Cioppolo14 requested review from Cioppolo14 and removed request for Tajcore and beingnoble03 April 10, 2024 00:23
@vasujain275 vasujain275 changed the base branch from develop to develop-userTypeFix April 11, 2024 15:45
@vasujain275 vasujain275 changed the base branch from develop-userTypeFix to develop April 11, 2024 15:48
@vasujain275
Copy link
Author

  1. There is a linting test that is failing. You need to submit your PR using a different source branch. This requirement was implemented 2-3 weeks ago
  2. Either close this PR or update it with a source branch with a different name.

I tried solving the liniting issue but not able to understand how to solve it, any guidance on how to do it would be really helpful. Otherwise I can close this PR and create a new one if solving the linting issue in this pr is too complex.

Copy link

This pull request did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please verify it has no conflicts with the develop branch and rebase if needed. Mention it now if you need help or give permission to other people to finish your work.

@github-actions github-actions bot added no-pr-activity No pull request activity and removed no-pr-activity No pull request activity labels Apr 27, 2024
@palisadoes
Copy link
Contributor

Is anything else required for a review of this?

@vasujain275
Copy link
Author

Is anything else required for a review of this?

No, I don't think so

Copy link
Member

@varshith257 varshith257 left a comment

Choose a reason for hiding this comment

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

@vasujain275 Add dockerignore file

cc: @Cioppolo14

@vasujain275
Copy link
Author

@vasujain275 Add dockerignore file

cc: @Cioppolo14

Okay

@vasujain275
Copy link
Author

@varshith257 Added .dockerignore file, thanks for the suggestion

@palisadoes
Copy link
Contributor

@vasujain275 The tests aren't running. PTAL

@vasujain275
Copy link
Author

Okay, let me take a look

Copy link

coderabbitai bot commented Jun 2, 2024

Walkthrough

The changes in this update focus on adding Docker support for the Talawa-Admin project. This includes creating a Dockerfile and a docker-compose.yml configuration to streamline deployment and ensure consistency across environments. Additionally, updates were made to .dockerignore and .eslintignore to optimize Docker build contexts and ESLint checks, respectively. The package.json file was also updated to include necessary dependencies and a new script for Docker operations.

Changes

Files Change Summary
.dockerignore Updated to exclude YARN, dependencies, testing, production, miscellaneous files, and editor-related files.
.eslintignore Added Dockerfile* and docker-compose*.yml to the list of files excluded from linting.
Dockerfile Created to set up a Node.js environment, install TypeScript, build the project, expose port 4321, and run the application using npm.
docker-compose.yml Added configuration for a service named app, setting an environment variable, exposing port 4321, and building with Dockerfile.
package.json Added dotenv dependency, updated inquirer, and added a dx-prod script for Docker operations.

Assessment Against Linked Issues

Objective Addressed Explanation
Add Docker support for Talawa-Admin (#1075)
Create a Dockerfile for Talawa-Admin (#1075)
Update docker-compose.yml to include necessary configurations (#1075)
Update documentation to reflect Docker setup (not covered in code) (##1075) Implementation present, docs update missing

Poem

In the land of code so bright,
Docker sails, a joyous sight.
Ports exposed, deploy with glee,
Talawa-Admin, now container free.
With scripts to run and nodes to dance,
Scalability has its chance.
Kudos to the lines we write,
In the Docker's gentle light.


Tip

Early access features
  • OpenAI gpt-4o model for reviews and chat.

Note:

  • You can disable early access features from the CodeRabbit UI or by setting early_access: false in the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are always opted into early access features.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vasujain275
Copy link
Author

Fixed the conflicting files

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Outside diff range and nitpick comments (1)
Dockerfile (1)

1-1: Consider pinning the Node.js image to a specific minor version to ensure consistent builds.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cf57c47 and cbbb8f9.

Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing (5)
  • .dockerignore (1 hunks)
  • .eslintignore (1 hunks)
  • Dockerfile (1 hunks)
  • docker-compose.yml (1 hunks)
  • package.json (3 hunks)
Files skipped from review due to trivial changes (3)
  • .dockerignore
  • .eslintignore
  • docker-compose.yml
Additional context used
Hadolint
Dockerfile

[warning] 7-7: Pin versions in npm. Instead of npm install <package> use npm install <package>@<version>


[info] 9-9: Multiple consecutive RUN instructions. Consider consolidation.


[info] 11-11: Multiple consecutive RUN instructions. Consider consolidation.

Additional comments not posted (5)
Dockerfile (3)

3-3: This is a good practice to set a working directory.


13-15: Proper use of EXPOSE and CMD to set up the container's exposed port and default command.


5-5: Ensure that the .dockerignore file is properly configured to avoid unnecessary files being copied into the Docker image.

Verification successful

The .dockerignore file is properly configured to exclude unnecessary files from being copied into the Docker image.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check if .dockerignore is properly set up.
cat .dockerignore

Length of output: 388

package.json (2)

Line range hint 25-35: Ensure that all new dependencies are necessary and correctly versioned to avoid potential conflicts and ensure reproducibility.


74-75: The addition of Docker-related scripts enhances the developer experience by simplifying Docker operations.

Dockerfile Show resolved Hide resolved
Dockerfile Show resolved Hide resolved
Dockerfile Show resolved Hide resolved
@palisadoes
Copy link
Contributor

@varshith257 PTAL here too. We need to get this functionality working so that we have a live demo instance of the API and Admin in the next few weeks. This will help with us getting grants for internships as well as new contributors

@palisadoes palisadoes requested a review from noman2002 June 2, 2024 20:32
Copy link
Member

@varshith257 varshith257 left a comment

Choose a reason for hiding this comment

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

What's the current image size of it?

package.json Show resolved Hide resolved

COPY . .

RUN npm install -g typescript
Copy link
Member

Choose a reason for hiding this comment

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

Is this step required?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cbbb8f9 and 2b82c9d.

Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing (1)
  • package.json (3 hunks)
Additional comments not posted (3)
package.json (3)

25-25: Verify the usage of dotenv.

Ensure that the dotenv dependency is used appropriately to manage environment variables, especially in the Docker configuration.

Verification successful

The usage of dotenv has been verified.

The dotenv dependency is used in the following files to manage environment variables:

  • scripts/config-overrides/custom_build.js
  • scripts/config-overrides/custom_start.js
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `dotenv` in the codebase.

# Test: Search for the usage of `dotenv`. Expect: Usage in Docker configuration or environment setup scripts.
rg --type python $'dotenv'

Length of output: 56



Script:

#!/bin/bash
# Description: Verify the usage of `dotenv` in the codebase.

# Test: Search for the usage of `dotenv`. Expect: Usage in Docker configuration or environment setup scripts.
rg --type js 'dotenv'

Length of output: 159


75-75: Verify the correctness and necessity of the dx-prod script.

Ensure that the dx-prod script correctly runs Docker compose operations and aligns with the objectives of the PR.

Verification successful

The dx-prod script is correctly set up to build and run the Docker compose configuration defined in docker-compose.yml.

  • The script correctly references the docker-compose.yml file.
  • The docker-compose.yml file includes appropriate build instructions and environment variables for the app service.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correctness and necessity of the `dx-prod` script.

# Test: Check if the `dx-prod` script correctly runs Docker compose operations.
docker compose -f docker-compose.yml up -d --build

Length of output: 126



Script:

#!/bin/bash
# Find the docker-compose.yml file and display its contents
fd -H -I -t f -i 'docker-compose.yml' --exec cat {}

# Search for references to the `dx-prod` script in the codebase
rg 'dx-prod'

Length of output: 358


35-35: Verify the necessity of updating inquirer.

Ensure that the update of inquirer from ^8.0.0 to ^8.2.6 is necessary and does not introduce compatibility issues.

@palisadoes
Copy link
Contributor

Please fix the failing workflow

@palisadoes
Copy link
Contributor

Should this PR be closed? It's been open a long time.

@vasujain275
Copy link
Author

Should this PR be closed? It's been open a long time.

Forgot about this PR entirely, my bad. I glanced through it and it is a much needed change to our docker files of projects.

Let me fix the conflicts and finalize this for review by this or at max next weekend.

@noman2002
Copy link
Member

Closing due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants