Skip to content

Commit

Permalink
Setup redis for sidekiq and db:seed
Browse files Browse the repository at this point in the history
  • Loading branch information
matthijsgroen committed Sep 26, 2024
1 parent db5b4ee commit e2c8286
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ By using a Ruby version manager (such as [asdf](https://asdf-vm.com/), you can e
docker compose up --build
```

To seed the database:

```sh
docker exec -it kudo-o-matic_web sh
# in the shell of the docker container:
bundle exec rake db:seed
```

When everything runs:

```sh
Expand Down Expand Up @@ -74,14 +82,6 @@ Copy environment variables. Following the dependency setup instructions below wi
cp env.example .env
```

#### Database configuration

Copy default database configuration (change if needed)

```bash
cp config/database.yml.example config/database.yml
```

#### Database

Create the databases and initialize it with the seed data.
Expand Down
12 changes: 12 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ services:
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
command: bash -c "bundle install
&& bundle exec rake db:migrate
&& bundle exec puma"
Expand Down Expand Up @@ -43,3 +45,13 @@ services:
- ./dockerfiles/development/db/init.sh:/docker-entrypoint-initdb.d/init.sh
# Data volume for persistent storage
- ./dockerfiles/development/db/data:/var/lib/postgresql/data

redis:
image: redis:7
ports:
- "${REDIS_PORT_LOCAL:-6379}:6379"
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 1s
timeout: 3s
retries: 5
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
users.each do |user|
user = User.create(
name: user,
email: "#{user}@example.com",
email: "#{user.downcase}@example.com",
password: 'password',
password_confirmation: 'password'
)
Expand Down
2 changes: 2 additions & 0 deletions dockerfiles/development/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ENV RACK_ENV development
ENV ROOT_URL 0.0.0.0
ENV DATABASE_NAME kudo-o-matic_development
ENV DATABASE_URL postgres://kudo_user:kudos@db:5432
ENV DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL true
ENV REDIS_URL redis://redis:6379/0

# Install Node.js, npm, Yarn, Python, and build-essential
RUN apt-get update -qq && \
Expand Down

0 comments on commit e2c8286

Please sign in to comment.