Skip to content

Commit

Permalink
Feature/docker compose (#10)
Browse files Browse the repository at this point in the history
* Setup for docker-compose, update bundles for security reason

* Update bundles

* Update bundles: rack

---------

Co-authored-by: Yaroslav Yenkala <[email protected]>
  • Loading branch information
yaroslavrick and Yaroslav Yenkala authored Aug 21, 2023
1 parent 5f2d399 commit 459dd3e
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 81 deletions.
5 changes: 5 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=postgres
REDIS_PORT=6379
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ POSTGRES_HOST=localhost
POSTGRES_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=postgres
REDIS_PORT=6379
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ gem 'importmap-rails', '~> 1.1.5'
gem 'interactor', '~> 3.1.2'
gem 'jbuilder', '~> 2.11.5'
gem 'jquery-rails', '~> 4.5.1'
gem 'nokogiri', '~> 1.15.4'
gem 'overcommit', '~> 0.60.0'
gem 'pagy', '~> 6.0'
gem 'pg', '~> 1.4.5'
gem 'puma', '~> 5.0'
gem 'rack', '>= 2.2.6.4'
gem 'rails', '>= 7.0.4.3'
gem 'puma', '~> 5.6.7'
gem 'rack', '~> 2.2.6'
gem 'rails', '~> 7.0.4', '>= 7.0.5.1'
gem 'rails-i18n', '~> 7.0.0'
gem 'sassc-rails', '~> 2.1.2'
gem 'sprockets-rails', '~> 3.4.2'
Expand Down
135 changes: 68 additions & 67 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.4.3)
actionpack (= 7.0.4.3)
activesupport (= 7.0.4.3)
actioncable (7.0.7)
actionpack (= 7.0.7)
activesupport (= 7.0.7)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.4.3)
actionpack (= 7.0.4.3)
activejob (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
actionmailbox (7.0.7)
actionpack (= 7.0.7)
activejob (= 7.0.7)
activerecord (= 7.0.7)
activestorage (= 7.0.7)
activesupport (= 7.0.7)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.4.3)
actionpack (= 7.0.4.3)
actionview (= 7.0.4.3)
activejob (= 7.0.4.3)
activesupport (= 7.0.4.3)
actionmailer (7.0.7)
actionpack (= 7.0.7)
actionview (= 7.0.7)
activejob (= 7.0.7)
activesupport (= 7.0.7)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.4.3)
actionview (= 7.0.4.3)
activesupport (= 7.0.4.3)
rack (~> 2.0, >= 2.2.0)
actionpack (7.0.7)
actionview (= 7.0.7)
activesupport (= 7.0.7)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.4.3)
actionpack (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
actiontext (7.0.7)
actionpack (= 7.0.7)
activerecord (= 7.0.7)
activestorage (= 7.0.7)
activesupport (= 7.0.7)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.4.3)
activesupport (= 7.0.4.3)
actionview (7.0.7)
activesupport (= 7.0.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.4.3)
activesupport (= 7.0.4.3)
activejob (7.0.7)
activesupport (= 7.0.7)
globalid (>= 0.3.6)
activemodel (7.0.4.3)
activesupport (= 7.0.4.3)
activerecord (7.0.4.3)
activemodel (= 7.0.4.3)
activesupport (= 7.0.4.3)
activestorage (7.0.4.3)
actionpack (= 7.0.4.3)
activejob (= 7.0.4.3)
activerecord (= 7.0.4.3)
activesupport (= 7.0.4.3)
activemodel (7.0.7)
activesupport (= 7.0.7)
activerecord (7.0.7)
activemodel (= 7.0.7)
activesupport (= 7.0.7)
activestorage (7.0.7)
actionpack (= 7.0.7)
activejob (= 7.0.7)
activerecord (= 7.0.7)
activesupport (= 7.0.7)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.4.3)
activesupport (7.0.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand Down Expand Up @@ -190,11 +190,11 @@ GEM
net-smtp
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.18.0)
msgpack (1.7.0)
mini_mime (1.1.5)
minitest (5.17.0)
msgpack (1.6.0)
nenv (0.3.0)
net-imap (0.3.4)
net-imap (0.3.7)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -204,7 +204,7 @@ GEM
net-smtp (0.3.3)
net-protocol
nio4r (2.5.9)
nokogiri (1.14.3-x86_64-linux)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
notiffany (0.1.3)
nenv (~> 0.1)
Expand All @@ -228,26 +228,26 @@ GEM
pry (>= 0.13, < 0.15)
pry-rails (0.3.9)
pry (>= 0.10.4)
puma (5.6.5)
puma (5.6.7)
nio4r (~> 2.0)
racc (1.6.2)
racc (1.7.1)
rack (2.2.7)
rack-test (2.1.0)
rack-test (2.0.2)
rack (>= 1.3)
rails (7.0.4.3)
actioncable (= 7.0.4.3)
actionmailbox (= 7.0.4.3)
actionmailer (= 7.0.4.3)
actionpack (= 7.0.4.3)
actiontext (= 7.0.4.3)
actionview (= 7.0.4.3)
activejob (= 7.0.4.3)
activemodel (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
rails (7.0.7)
actioncable (= 7.0.7)
actionmailbox (= 7.0.7)
actionmailer (= 7.0.7)
actionpack (= 7.0.7)
actiontext (= 7.0.7)
actionview (= 7.0.7)
activejob (= 7.0.7)
activemodel (= 7.0.7)
activerecord (= 7.0.7)
activestorage (= 7.0.7)
activesupport (= 7.0.7)
bundler (>= 1.15.0)
railties (= 7.0.4.3)
railties (= 7.0.7)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
Expand All @@ -264,9 +264,9 @@ GEM
json
require_all (~> 3.0)
ruby-progressbar
railties (7.0.4.3)
actionpack (= 7.0.4.3)
activesupport (= 7.0.4.3)
railties (7.0.7)
actionpack (= 7.0.7)
activesupport (= 7.0.7)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand Down Expand Up @@ -372,7 +372,7 @@ GEM
temple (0.10.0)
thor (1.2.1)
tilt (2.1.0)
timeout (0.3.2)
timeout (0.4.0)
turbo-rails (1.3.3)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
Expand All @@ -387,7 +387,7 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
websocket-driver (0.7.5)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.8)
Expand Down Expand Up @@ -416,14 +416,15 @@ DEPENDENCIES
interactor (~> 3.1.2)
jbuilder (~> 2.11.5)
jquery-rails (~> 4.5.1)
nokogiri (~> 1.15.4)
overcommit (~> 0.60.0)
pagy (~> 6.0)
pg (~> 1.4.5)
pry-byebug (~> 3.10.1)
pry-rails (~> 0.3.9)
puma (~> 5.0)
rack (>= 2.2.6.4)
rails (>= 7.0.4.3)
puma (~> 5.6.7)
rack (~> 2.2.6)
rails (~> 7.0.4, >= 7.0.5.1)
rails-i18n (~> 7.0.0)
rails_best_practices (~> 1.23.2)
rspec (~> 3.12.0)
Expand Down
56 changes: 45 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,67 @@

```zsh
[email protected]:yaroslavrick/car_advertisements_web.git
cd car_advertisements_web
```

#### 2. Copy the .env.example file.
#### 2. Move into the project directory:

```zsh
cp .env.example .env
```bash
cd car_advertisements_web
```

#### 3. Install dependencies

```zsh
bundle
bundle install
```

#### 4. Create and setup the database
#### 4. Copy the .env.example file.

```zsh
rails db:create && rails db:migrate && rails db:seed
cp .env.example .env.development
```

#### 5. Start the app
#### 5. Setup Docker services (PostgreSQL and Redis):

```zsh
rails s
docker-compose up
```

Ensure that the ports configured in `.env` do not conflict with your running services.


#### 6. Create the database:

```bash
bundle exec rails db:create
```

#### 7. Run database migrations:

```bash
bundle exec rails db:migrate
```

#### 8. (Optional) Run seed data to create some sample data:

```bash
bundle exec rails db:seed
```

## Usage

To start the app, run the following command:

```bash
bundle exec rails server
```

Visit the app at localhost: http://localhost:3000
Once the server is running, open your web browser and go to http://localhost:3000 to access the app.

## Testing

To run the test suite, use the following command:

Visit the app at web: https://caradvertisementsweb-production.up.railway.app/
```bash
bundle exec rspec
```
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3.9'

services:
db:
image: postgres:15-alpine
environment:
- POSTGRES_USER=${DB_USERNAME}
- POSTGRES_PASSWORD=${DB_PASSWORD}
ports:
- "${POSTGRES_PORT}:5432"
volumes:
- "dbdata:/var/lib/postgresql/data"
healthcheck:
test: ["CMD", "pg_isready -U ${DB_USERNAME}"]
interval: 10s
timeout: 5s
retries: 5

redis:
image: redis:7-alpine
ports:
- "${REDIS_PORT}:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5

volumes:
dbdata:
redis_data:

0 comments on commit 459dd3e

Please sign in to comment.