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

Feature: Added Github codespaces configurations #1541 #1557

Merged

Conversation

Shrest4647
Copy link
Contributor

@Shrest4647 Shrest4647 commented Oct 19, 2023

Related issue: Issue #1541

Change Logs:

  • Fixed the volume mount issues in the dev container configurations
  • Updated the postAttachCommand to start the rails server.
  • Updated the docker file permissions for installing packages

@apoorv1316
Copy link
Collaborator

@akhilgkrishnan Please review

Copy link
Member

@akhilgkrishnan akhilgkrishnan left a comment

Choose a reason for hiding this comment

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

@Shrest4647, This is really great 🎉 . Thanks for working on this :)

I have a small suggestion, and in addition, we should modify the development.rb configuration to allow requests from the CodeSpaces URL. To do this, please add the following code block inside the development.rb file:

if ENV["CODESPACES"] == "true"
  codespace_domain = ENV['GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN']
  codespace_host = "#{ENV['CODESPACE_NAME']}-3000.#{codespace_domain}"
  config.hosts << codespace_host
end

If possible could you also work on the adding a documentation.

@@ -0,0 +1,3 @@
bin/rails db:prepare
Copy link
Member

Choose a reason for hiding this comment

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

Seems like we are not using this file. Or we can use this file by moving all the postAttachCommand values here and run this script inside the postAttachCommand.

@akhilgkrishnan akhilgkrishnan linked an issue Oct 19, 2023 that may be closed by this pull request
@Shrest4647 Shrest4647 force-pushed the feature/codespaces-configurations branch from e3b5da5 to 437025a Compare October 19, 2023 12:25
@Shrest4647
Copy link
Contributor Author

Hi @akhilgkrishnan . I have updated the configuration for development.rb. Also, I have decided not to move the postAttachCommand to script.sh as this requires changing file permissions to execute the script and this also makes the running commands opaque to the user.

@akhilgkrishnan
Copy link
Member

Hi @akhilgkrishnan . I have updated the configuration for development.rb. Also, I have decided not to move the postAttachCommand to script.sh as this requires changing file permissions to execute the script and this also makes the running commands opaque to the user.

Can you fix the rubocop issue?

@@ -0,0 +1,61 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
Copy link
Member

@akhilgkrishnan akhilgkrishnan Oct 19, 2023

Choose a reason for hiding this comment

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

I think the indentation is correct for this page. Use 2 spaces?

Copy link
Member

@akhilgkrishnan akhilgkrishnan left a comment

Choose a reason for hiding this comment

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

  
ActionController::InvalidAuthenticityToken (HTTP Origin header (http://localhost:3000) didn't match request.base_url (https://fluffy-space-zebra-v79wj99x7vw3wg6x-3000.app.github.dev)):
  
actionpack (7.0.8) lib/action_controller/metal/request_forgery_protection.rb:253:in `handle_unverified_request'
actionpack (7.0.8) lib/action_controller/metal/request_forgery_protection.rb:286:in `handle_unverified_request'
devise (4.8.1) lib/devise/controllers/helpers.rb:255:in `handle_unverified_request'
actionpack (7.0.8) lib/action_controller/metal/request_forgery_protection.rb:275:in `verify_authenticity_token'
activesupport (7.0.8) lib/active_support/callbacks.rb:400:in `block in make_lambda'
activesupport (7.0.8) lib/active_support/callbacks.rb:199:in `block (2 levels) in halting'
actionpack (7.0.8) lib/abstract_controller/callbacks.rb:34:in `block (2 levels) in <module:Callbacks>'
activesupport (7.0.8) lib/active_support/callbacks.rb:200:in `block in halting'
activesupport (7.0.8) lib/active_support/callbacks.rb:595:in `block in invoke_before'
activesupport (7.0.8) lib/active_support/callbacks.rb:595:in `each'
activesupport (7.0.8) lib/active_support/callbacks.rb:595:in `invoke_before'
activesupport (7.0.8) lib/active_support/callbacks.rb:116:in `block in run_callbacks'
activesupport (7.0.8) lib/active_support/callbacks.rb:138:in `run_callbacks'
actionpack (7.0.8) lib/abstract_controller/callbacks.rb:233:in `process_action'

I can see this error on the logs, so avoiding this we might need to add below code in developement.rb

  config.action_dispatch.default_headers = {
    'X-Frame-Options' => "ALLOW-FROM #{codespace_domain}"
  }

Also we want to set the APP_BASE_URL env with codespace app url

Copy link
Member

@akhilgkrishnan akhilgkrishnan left a comment

Choose a reason for hiding this comment

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

@Shrest4647 I made couple of changes. It working fine now.

Thanks for taking an initiative on working this ❤️

@Animesh-Ghosh
Copy link
Contributor

Good going! I was also kind of trying it out, but what I ended up doing was pointing the dockerComposeFile to the docker-compose.yml file in the project root. Codespace pre-build was successfull but I couldn't get a similar development experience as one would have locally.

Here are the commits for reference.

Anyway, thanks for this! Will make contributions just one click away! 🚀

@Animesh-Ghosh
Copy link
Contributor

@akhilgkrishnan apparently the error shown here still exists when you try to submit a form/to a JSON end-point.
I created a Codespace from the GitHub UI from the develop branch and the server ran and I could open the homepage. However, when I tried to login, I faced the same error, along with a 422 Unprocessable Entity error.

Let me know if a separate issue should be created.

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

Successfully merging this pull request may close these issues.

Setup Github Codespace Vscode devcontainer
4 participants