Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][DX] Add Docker Configuration for Development #109

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ruby:3.3

# Set the working directory in the container
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Copy the sample config to the actual config (performed at build time)
RUN cp spec/support/sample.docker.config.yml spec/support/config.yml

# Install any needed packages specified in Gemfile
RUN bundle install

# Command to run the application
CMD ["bash"]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ test:
min_messages: WARNING
</pre>

## Development

If you want to test this library locally, you can do so like this:

```
docker compose run --build --rm ruby /bin/bash
bundle
bundle exec rake
```

You will need Docker installed. The configuration is set up for the latest Ruby, Rails, Postgres, and MySQL versions.

## COPYRIGHT

See [LICENSE](LICENSE) for details.
36 changes: 36 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
services:
ruby:
image: ruby:3.3 # Manually change this based on the desired Ruby version
working_dir: /app
build: .
environment:
BUNDLE_GEMFILE: gemfiles/rails_7.2.gemfile # Manually change this based on the desired Rails version
depends_on:
- mysql
- postgres

mysql:
image: mysql:8.4
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
ports:
- "3306:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping"]
interval: 10s
timeout: 5s
retries: 3

postgres:
image: postgres:16
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
PGUSER: postgres
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
33 changes: 33 additions & 0 deletions spec/support/sample.docker.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
mysql2:
adapter: mysql2
database: database_cleaner_test
username: root
password:
host: mysql
port: 3306
encoding: utf8

trilogy:
adapter: trilogy
database: database_cleaner_test
username: root
password:
host: mysql
port: 3306
encoding: utf8

postgres:
adapter: postgresql
database: database_cleaner_test
username: postgres
password: postgres
host: postgres
encoding: unicode
template: template0

sqlite3:
adapter: sqlite3
database: tmp/database_cleaner_test.sqlite3
pool: 5
timeout: 5000
encoding: utf8