{"id":28321141,"url":"https://github.com/ritankarsaha/demo-dockerization","last_synced_at":"2026-01-26T21:49:57.121Z","repository":{"id":287242949,"uuid":"964071534","full_name":"ritankarsaha/demo-dockerization","owner":"ritankarsaha","description":"This is a sample dockerization project projecting ruby, having properly integrated ci-cd pipelines and also provisions for codespaces (devcontainer) for ease and pace of development. ","archived":false,"fork":false,"pushed_at":"2025-04-10T17:17:00.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-01T20:50:11.652Z","etag":null,"topics":["ci-cd","codespaces","dockerization","workflows"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ritankarsaha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-10T16:38:25.000Z","updated_at":"2025-04-11T21:13:13.000Z","dependencies_parsed_at":"2025-04-10T18:51:06.477Z","dependency_job_id":"dc12dc8f-abcd-43b7-8e30-e421986d0abb","html_url":"https://github.com/ritankarsaha/demo-dockerization","commit_stats":null,"previous_names":["ritankarsaha/demo-dockerization"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ritankarsaha/demo-dockerization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ritankarsaha%2Fdemo-dockerization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ritankarsaha%2Fdemo-dockerization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ritankarsaha%2Fdemo-dockerization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ritankarsaha%2Fdemo-dockerization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ritankarsaha","download_url":"https://codeload.github.com/ritankarsaha/demo-dockerization/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ritankarsaha%2Fdemo-dockerization/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261487008,"owners_count":23166003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci-cd","codespaces","dockerization","workflows"],"created_at":"2025-05-25T12:13:14.125Z","updated_at":"2026-01-26T21:49:57.109Z","avatar_url":"https://github.com/ritankarsaha.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Application with Docker\n\nThis project demonstrates a Sinatra web application running inside a Docker container with PostgreSQL as the database. It uses Docker Compose to manage the multi-container setup.\n\nPrerequisites\nBefore you start, ensure that you have the following tools installed:\n\nDocker: Install Docker\n\nDocker Compose: Install Docker Compose\n\nGit (optional, if you want to clone the repository): Install Git\n\n\n## Getting Started\n\nFollow these steps to get the application up and running on your local machine.\n\n1. Clone the Repository\nIf you haven't already cloned the repository, you can do so with the following command:\n\n```bash\ngit clone https://github.com/ritankarsaha/demo-dockerization.git\ncd demo-dockeriation\n```\n\n2. Build the Docker Images\nThe first step is to build the Docker images using Docker Compose. Run the following command:\n\n```bash\ndocker-compose build --no-cache\n```\nThis will rebuild the Docker images from scratch, ensuring that all dependencies are installed properly\n\n3. Start the Application\nOnce the images are built, you can start the application by running:\n\n```bash\ndocker-compose up\n```\n\nThis will start both the app and database services:\n\nThe Sinatra application will be available at http://localhost:3006.\n\nThe PostgreSQL database will be running on port 5432.\n\n4. Check Logs\nIf you want to monitor the logs of the Sinatra app, you can run:\n\n```bash\ndocker-compose logs -f app\n```\nThis will show the real-time logs for the app container. If the app encounters issues, the logs will help you troubleshoot.\n\n5. Stop the Containers\nTo stop the running containers, use:\n\n```bash\ndocker-compose down\n```\nThis will stop the containers and remove any resources created by Docker Compose.\n\n\n## Dockerfile Overview\nThe Dockerfile is divided into two stages:\n\nBuilder Stage: This stage installs build-time dependencies, copies the application code, installs gems (excluding development and test gems), and precompiles assets.\n\nFinal Stage: This stage installs runtime dependencies and copies the application from the builder stage. It runs the Sinatra application using the rackup command.\n\n## Key Dockerfile Instructions\nMulti-stage Build: The Dockerfile uses a multi-stage build to ensure the final image is as lightweight as possible by excluding unnecessary build dependencies.\n\nCMD: The CMD directive runs bundle exec rackup to start the Sinatra web server when the container is run.\n\n## Database Configuration\nThe project uses PostgreSQL for database management. Docker Compose will automatically start the PostgreSQL container and set the environment variables needed for the app to connect to the database.\n\nDatabase URL: postgres://postgres:password@database:5432/myapp\n\nThe database service is available at port 5432 and configured with the default credentials.\n\n## Troubleshooting\n\nMissing Gem Executables\nIf you see an error like bundler: command not found: rackup, run the following inside the container:\n\n```bash\ndocker-compose run --rm app /bin/bash\nbundle install\n```\n\n## PostgreSQL Connection Issues\n\nIf the app is unable to connect to the PostgreSQL database, ensure that the DATABASE_URL environment variable is correctly set in your .env or Docker Compose configuration.\n\nTo check the logs of the database container, run:\n```bash\ndocker-compose logs -f database\n```\n\n## Permissions Issues\n\nIf you encounter any file permission issues, especially in a development environment, make sure the application files are owned by the correct user in the Docker container. The Dockerfile sets the proper user (consul) to run the application.\n\n## Rebuilding Docker Containers\n\nIf you need to rebuild the Docker containers (for example, after changing dependencies), run:\n\n```bash\ndocker-compose down\ndocker-compose build --no-cache\ndocker-compose up\n```\n\n## Directory Structure\nHere is an overview of the project directory structure:\n\n```bash\n├── .devcontainer/\n│   └── devcontainer.json\n├── app/\n│   ├── public/\n│   ├── app.rb\n│   └── config.ru\n├── config/\n│   └── deploy.yml\n├── spec/\n│   └── app_spec.rb   (example tests)\n├── docker-compose.yml\n├── Dockerfile\n├── Gemfile\n└── Gemfile.lock\n```\n\napp/: Contains the Sinatra app and its configuration.\n\nconfig/: Contains configuration files (like deploy.yml).\n\nspec/: Contains RSpec tests.\n\nDockerfile: Defines the multi-stage build for the Docker image.\n\ndocker-compose.yml: Defines the multi-container setup for the app and database.\n\nGemfile: Defines the Ruby gems required for the project.\n\nGemfile.lock: Locked versions of the gems.\n\n\n## Conclusion\n\nThis setup allows you to easily run a Sinatra application inside a Docker container with PostgreSQL for development or production. With Docker Compose, it's easy to manage the entire stack with a single command.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fritankarsaha%2Fdemo-dockerization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fritankarsaha%2Fdemo-dockerization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fritankarsaha%2Fdemo-dockerization/lists"}