Previously we did not support authentication for redis anywhere. Also in the docker compose we were exposing redis port 6379 without any authentication. In the app side for the connections that app server (for storing keys as well as for socket connections made using action cable) and Sidekiq were making to redis server did not support authentication. With this commit, we support authentication for redis connections from app side and Sidekiq. This is supported in docker-compose as well. The changes include : * Added support for new env variable REDIS_PASSWORD * This redis password is now supported by action cable connections, Sidekiq connections and app side redis connections * Since Sidekiq did not have an initializer, added an initializer to pass custom config to Sidekiq (for now it's options for redis) * Changes in docker-compose to pickup a password set in .env file to protect the redis server running in docker * Added necessary documentation changes in `docker.md` and `environment-variables.md`
77 lines
2.2 KiB
Markdown
77 lines
2.2 KiB
Markdown
---
|
|
path: "/docs/installation-guide-docker"
|
|
title: "Docker Setup and Debugging Guide"
|
|
---
|
|
|
|
### Development environment
|
|
|
|
After cloning the repo and installing docker on your machine, run the following command from the root directory of the project.
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
|
|
Make changes to the `.env` file as required [Optional]. If you want to set the password for redis when you run
|
|
docker-compose, set any string value to the environment variable `REDIS_PASSWORD` in the `.env` file. which will secure the redis running inside docker-compose with this password. This will be automatically picked up by app server and sidekiq, to authenticate while making connections to redis server.
|
|
|
|
```bash
|
|
docker-compose build
|
|
```
|
|
|
|
After building the image or after destroying the stack you would have to reset the database using following command
|
|
|
|
```bash
|
|
docker-compose run rails bundle exec rails db:reset
|
|
```
|
|
|
|
### Running the app
|
|
|
|
```bash
|
|
docker-compose run --service-port rails
|
|
```
|
|
|
|
open another terminal and also run below command to run sidekiq in a separate service
|
|
|
|
```
|
|
docker-compose run rails bundle exec sidekiq
|
|
```
|
|
|
|
* Access the rails app frontend by visiting `http://0.0.0.0:3000/`
|
|
* Access Mailhog inbox by visiting `http://0.0.0.0:8025/` (You will receive all emails going out of the application here)
|
|
* Access Sidekiq Web UI by visiting `http://0.0.0.0:3000/sidekiq` (You need to login with administrator account to access sidekiq)
|
|
|
|
you can also use the below command instead to run the app and see the full logs.
|
|
|
|
```bash
|
|
docker-compose up
|
|
```
|
|
|
|
### Destroying the complete composer stack
|
|
|
|
```bash
|
|
docker-compose down
|
|
```
|
|
|
|
### Running rspec tests
|
|
|
|
For running the complete rspec tests
|
|
|
|
```bash
|
|
docker-compose run rails bundle exec rspec
|
|
```
|
|
|
|
For running specific test:
|
|
|
|
```bash
|
|
docker-compose run rails bundle exec rspec spec/<path-to-file>:<line-number>
|
|
```
|
|
|
|
## production environment
|
|
|
|
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:
|
|
|
|
```bash
|
|
docker-compose -f docker-compose.production.yaml build
|
|
docker-compose -f docker-compose.production.yaml up
|
|
```
|