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

Add Dev Containers Docker Development Environment #203

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

viktorianer
Copy link

Summary

This pull request introduces a comprehensive Docker-based development environment for the Rideshare application, enhancing developer productivity and ensuring a consistent setup across various environments. Key features include DevContainers configuration, PostgreSQL setup, and automatic database initialization.

Changes

  1. DevContainer Configuration:

    • Added .devcontainer/devcontainer.json to define the development container environment.
    • Configured the development container to use Docker Compose for service orchestration.
  2. Docker Compose Integration:

    • Created compose.yml to define services for the application and PostgreSQL.
    • Ensured the PostgreSQL service uses version 16 for compatibility with new features.
  3. Environment Setup:

    • Configured environment variables in devcontainer.json for database connections.
  4. Database Configuration:

    • Used Docker Compose to pass PostgreSQL configuration parameters directly, avoiding the need for a custom scripts.

Benefits

  • Consistency: Ensures a consistent development environment across different machines and setups.
  • Productivity: Reduces the time required for environment setup.
  • Flexibility: Supports customization of PostgreSQL configurations directly via Docker Compose.

How to Test

  1. Clone the repository and checkout the branch.
  2. Ensure Docker and Docker Compose are installed on your system.
  3. Run the commands described in the README, to build and start the services.
  4. Verify the PostgreSQL container is running with the correct configurations.
  5. Confirm that the application container initializes correctly and that the database setup script runs without issues.

References

Remarks

I recently started reading the book "High Performance PostgreSQL for Rails" (thanks a lot for the great book! 🥇) and was disappointed to find that I had to spend hours setting up the environment before I could start working on the exercises.

This pull request aims to streamline the setup process, allowing you to get started more quickly. However, please note that I have not tested all features yet, as I have only reached the section where I need to create millions of rows in the database.

This PR is just the first step, from which we could start to improve the setup.

@andyatkinson
Copy link
Owner

andyatkinson commented Jun 29, 2024

Hi there. Since the book has gone to print, I want to keep the installation instructions the same as they are. In other words, I don't want to introduce any changes to the main README.md beyond changes that are spelling or grammar related.

However, if you'd like to submit a guide, I'm open to that. I would call it an alternative method for running Rideshare for development purposes, using Dev Containers, and make it clear that it's submitted by the community and not the officially supported method described in the book.

I'm open to additional alternatives like that including Windows and Linux installation instructions, but I do feel we missed the window of time before the book went to print, to support multiple installation methods and for them to be rigorously tested. Hopefully that makes sense.

With that said, I hope to try out your instructions myself in the future and can report back on my experience.

Thanks.

@viktorianer
Copy link
Author

Hi @andyatkinson,

I've reverted the main README.md file to match the version on the repository's main branch. Additionally, I have submitted a separate guide, which provides an alternative setup method using Dev Containers. This guide is clearly labeled as a community-submitted method and not the officially supported approach described in the book.

As I do not have time to test this setup on Windows, and also do not have a Linux environment up and running, I would suggest that someone from the community could contribute by adding and testing instructions for these platforms. Additionally, using Dev Containers simplifies the process of running the setup on any operating system, making it more accessible and consistent across different development environments.

Thank you for the feedback, and I hope this guide will be helpful for others who prefer using Dev Containers for their development environment.

@andyatkinson
Copy link
Owner

@viktorianer

Additionally, I have submitted a separate guide, which provides an alternative setup method using Dev Containers. This guide is clearly labeled as a community-submitted method and not the officially supported approach described in the book.

Thank you for that. I don't know when, but I'll try and review it. If any other people review the instructions and validate them, that would help as well. Another direction that I'd consider is that I've kept a bunch of additional installation instructions in a companion repo called "development_guides" that's mentioned in the book as well. https://github.com/andyatkinson/development_guides Finally, if you'd prefer, you're also welcome to write a blog post on your own site and describe your process of setting it up. That allows you to release something on your own timeline and to your own preferences without waiting for me to review it.

I'm also tracking the arrival of generated Dev Containers config in Rails 7.2 and I'm curious to see whether that increases adoption of Dev Containers. I did try them a bit myself on a test Rails project which I'll be writing more about soon.

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.

2 participants