Spree Commerce
Enhancing Rails Development in Docker: Integration with VS Code
While working with Rails in a fully dockerized environment, I encountered an intriguing obstacle: the need to inspect the code of an installed gem. Within the container, I found that running a simple command like bundle open <gem> wasn't a viable option. Additionally, integrating my local VS Code development environment with the container presented challenges, as it would be impractical to replicate all of its dependencies within the dockerized environment.
Fortunately, I found an effective solution: integrating code-server directly into the docker-compose.yml file. To accomplish this, I made some key configurations. Firstly, I added code-server as a service dependent on the main container (the web application container). Then, I defined variables like PASSWORD for access password and DEFAULT_WORKSPACE to point to the main repository of the web container. Furthermore, I configured the volume to include the path of the installed gems.
After setting up the docker environment and starting the services, all I needed to do was access localhost:8080. This opened VS Code directly in the browser, with all installed gems available. To access a specific gem, simply add the gem's path to the browser's URL. For example:
When opening localhost:8080, the URL would look like this:
http://localhost:8080/?folder=/bundle/ruby/<version>/gems/
To open the spree_api<version> gem, simply add the complete path to the end of the URL:
http://localhost:8080/?folder=/bundle/ruby/<version>/gems/spree_api-<version>
This integration provided a convenient and efficient way to explore and work with installed gems directly in the dockerized environment, while leveraging the features of VS Code.
Get Kanamy Stewart’s stories in your inbox
Join Medium for free to get updates from this writer.
Apply code-server in your docker-compose.yml
code-server:
image: codercom/code-server
container_name: code-server
environment:
PASSWORD: ‘password’
DEFAULT_WORKSPACE: “/app”
volumes:
- .:/home/coder/project
- ‘bundle_cache:/bundle’
ports:
- “8080:8080”
depends_on:
- ‘web’
restart: unless-stopped
After building your Docker image, access localhost:8080.
access specific gem
code use: https://github.com/KanamyDamiao/docker-compose-spree-starter
I hope I’ve been able to help and contribute a bit of my knowledge.




