2019-12-22 17:23:18 +00:00
---
path: "/docs/installation-guide-docker"
title: "Docker Setup and Debugging Guide"
---
2019-12-23 07:30:22 +00:00
### Development environment
2019-12-22 17:23:18 +00:00
2019-12-23 06:26:25 +00:00
After cloning the repo and installing docker on your machine, run the following command from the root directory of the project.
2019-12-23 07:30:22 +00:00
```bash
2019-12-22 17:23:18 +00:00
docker-compose build
```
2019-12-23 06:26:25 +00:00
After building the image or after destroying the stack you would have to reset the database using following command
2019-12-22 17:23:18 +00:00
2019-12-23 07:30:22 +00:00
```bash
2019-12-23 06:26:25 +00:00
docker-compose run rails bundle exec rails db:reset
2019-12-22 17:23:18 +00:00
```
2019-12-23 06:26:25 +00:00
### Running the app
2019-12-22 17:23:18 +00:00
2019-12-23 07:30:22 +00:00
```bash
2019-12-22 17:23:18 +00:00
docker-compose run --service-port rails
```
2019-12-23 06:26:25 +00:00
* Access the rails app frontend by visiting `http://0.0.0.0:3000/`
2019-12-22 17:23:18 +00:00
* Access Mailhog inbox by visiting `http://0.0.0.0:8025/` (You will receive all emails going out of the application here)
2019-12-23 06:26:25 +00:00
you can also use the below command instead to run the app and see the full logs.
2019-12-22 17:23:18 +00:00
2019-12-23 07:30:22 +00:00
```bash
2019-12-22 17:23:18 +00:00
docker-compose up
```
### Destroying the complete composer stack
2019-12-23 07:30:22 +00:00
```bash
2019-12-22 17:23:18 +00:00
docker-compose down
```
### Running rspec tests
For running the complete rspec tests
2019-12-23 07:30:22 +00:00
```bash
2019-12-22 17:23:18 +00:00
docker-compose run rails bundle exec rspec
```
For running specific test:
2019-12-23 07:30:22 +00:00
```bash
2019-12-22 17:23:18 +00:00
docker-compose run rails bundle exec rspec spec/< path-to-file > :< line-number >
```
## production environment
2019-12-23 06:26:25 +00:00
Sometimes you might want to debug the production build locally. You would first need to set `SECRET_KEY_BASE` environment variable in your .env.example file and then run the below commands:
2019-12-22 17:23:18 +00:00
2019-12-23 07:30:22 +00:00
```bash
2019-12-23 06:26:25 +00:00
docker-compose -f docker-compose.production.yaml build
2019-12-22 17:23:18 +00:00
docker-compose -f docker-compose.production.yaml up
2019-12-23 07:30:22 +00:00
```