chore: 🔧 docker entrypoint for init db
docker-compose.test removed, create testing and dev databases on init db
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
RAILS_ENV=development
|
|
||||||
HOSTNAME=0.0.0.0
|
|
||||||
RAILS_PORT=3000
|
|
||||||
DATABASE_URL=postgres://user:user_12345@db:5432/url_shortener
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
FROM postgres:12.5-alpine
|
||||||
|
|
||||||
|
COPY docker-entrypoint-initdb.sql /docker-entrypoint-initdb.d/
|
||||||
@@ -59,13 +59,6 @@ GEM
|
|||||||
regexp_parser (>= 1.5, < 3.0)
|
regexp_parser (>= 1.5, < 3.0)
|
||||||
xpath (~> 3.2)
|
xpath (~> 3.2)
|
||||||
childprocess (3.0.0)
|
childprocess (3.0.0)
|
||||||
coffee-rails (4.2.2)
|
|
||||||
coffee-script (>= 2.2.0)
|
|
||||||
railties (>= 4.0.0)
|
|
||||||
coffee-script (2.4.1)
|
|
||||||
coffee-script-source
|
|
||||||
execjs
|
|
||||||
coffee-script-source (1.12.2)
|
|
||||||
concurrent-ruby (1.1.9)
|
concurrent-ruby (1.1.9)
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
docile (1.4.0)
|
docile (1.4.0)
|
||||||
@@ -154,17 +147,6 @@ GEM
|
|||||||
regexp_parser (2.1.1)
|
regexp_parser (2.1.1)
|
||||||
ruby_dep (1.5.0)
|
ruby_dep (1.5.0)
|
||||||
rubyzip (2.3.0)
|
rubyzip (2.3.0)
|
||||||
sass (3.7.4)
|
|
||||||
sass-listen (~> 4.0.0)
|
|
||||||
sass-listen (4.0.0)
|
|
||||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
||||||
rb-inotify (~> 0.9, >= 0.9.7)
|
|
||||||
sass-rails (5.1.0)
|
|
||||||
railties (>= 5.2.0)
|
|
||||||
sass (~> 3.1)
|
|
||||||
sprockets (>= 2.8, < 4.0)
|
|
||||||
sprockets-rails (>= 2.0, < 4.0)
|
|
||||||
tilt (>= 1.1, < 3)
|
|
||||||
selenium-webdriver (3.142.7)
|
selenium-webdriver (3.142.7)
|
||||||
childprocess (>= 0.5, < 4.0)
|
childprocess (>= 0.5, < 4.0)
|
||||||
rubyzip (>= 1.2.2)
|
rubyzip (>= 1.2.2)
|
||||||
@@ -189,7 +171,6 @@ GEM
|
|||||||
thor (1.1.0)
|
thor (1.1.0)
|
||||||
thread_safe (0.3.6)
|
thread_safe (0.3.6)
|
||||||
thread_safe (0.3.6-java)
|
thread_safe (0.3.6-java)
|
||||||
tilt (2.0.10)
|
|
||||||
turbolinks (5.2.1)
|
turbolinks (5.2.1)
|
||||||
turbolinks-source (~> 5.2)
|
turbolinks-source (~> 5.2)
|
||||||
turbolinks-source (5.2.0)
|
turbolinks-source (5.2.0)
|
||||||
@@ -230,13 +211,11 @@ DEPENDENCIES
|
|||||||
bootsnap (>= 1.1.0)
|
bootsnap (>= 1.1.0)
|
||||||
byebug
|
byebug
|
||||||
capybara (>= 2.15)
|
capybara (>= 2.15)
|
||||||
coffee-rails (~> 4.2)
|
|
||||||
jbuilder (~> 2.5)
|
jbuilder (~> 2.5)
|
||||||
listen (>= 3.0.5, < 3.2)
|
listen (>= 3.0.5, < 3.2)
|
||||||
pg (>= 0.18, < 2.0)
|
pg (>= 0.18, < 2.0)
|
||||||
puma (~> 4.3.8)
|
puma (~> 4.3.8)
|
||||||
rails (~> 5.2.6)
|
rails (~> 5.2.6)
|
||||||
sass-rails (~> 5.0)
|
|
||||||
selenium-webdriver
|
selenium-webdriver
|
||||||
simplecov
|
simplecov
|
||||||
spring
|
spring
|
||||||
|
|||||||
@@ -15,13 +15,9 @@ docker-compose up
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
- Run database in background
|
|
||||||
```bash
|
|
||||||
docker-compose -f docker-compose.test.yml up -d db
|
|
||||||
```
|
|
||||||
- Run tests
|
- Run tests
|
||||||
```bash
|
```bash
|
||||||
docker-compose -f docker-compose.test.yml run --rm app bundle exec rails test
|
docker-compose run --rm app bundle exec rails test
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rubocop
|
### Rubocop
|
||||||
@@ -34,7 +30,7 @@ docker-compose run --rm app rubocop
|
|||||||
- [x] Generate unique slug
|
- [x] Generate unique slug
|
||||||
- [x] Link unit tests
|
- [x] Link unit tests
|
||||||
- [x] Stimulus setup
|
- [x] Stimulus setup
|
||||||
- [ ] Link controller (handle redirection)
|
- [x] Link controller (handle redirection)
|
||||||
- [ ] Main page with input box
|
- [ ] Main page with input box
|
||||||
- [ ] Create user model
|
- [ ] Create user model
|
||||||
- [ ] User unit tests
|
- [ ] User unit tests
|
||||||
|
|||||||
+8
-5
@@ -23,7 +23,10 @@ default: &default
|
|||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: app_development
|
host: db
|
||||||
|
database: url_shortener
|
||||||
|
username: app_user
|
||||||
|
password: secure_12345
|
||||||
|
|
||||||
# The specified database role being used to connect to postgres.
|
# The specified database role being used to connect to postgres.
|
||||||
# To create additional roles in postgres see `$ createuser --help`.
|
# To create additional roles in postgres see `$ createuser --help`.
|
||||||
@@ -57,7 +60,10 @@ development:
|
|||||||
# Do not set this db to the same as development or production.
|
# Do not set this db to the same as development or production.
|
||||||
test:
|
test:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: app_test
|
host: db
|
||||||
|
database: test_url_shortener
|
||||||
|
username: app_user
|
||||||
|
password: secure_12345
|
||||||
|
|
||||||
# As with config/secrets.yml, you never want to store sensitive information,
|
# As with config/secrets.yml, you never want to store sensitive information,
|
||||||
# like your database password, in your source code. If your source code is
|
# like your database password, in your source code. If your source code is
|
||||||
@@ -80,6 +86,3 @@ test:
|
|||||||
#
|
#
|
||||||
production:
|
production:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: app_production
|
|
||||||
username: app
|
|
||||||
password: <%= ENV['APP_DATABASE_PASSWORD'] %>
|
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
version: '3'
|
|
||||||
|
|
||||||
services:
|
|
||||||
db:
|
|
||||||
image: postgres:12.5-alpine
|
|
||||||
volumes:
|
|
||||||
- test_db_data:/var/lib/postgresql/data
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: user
|
|
||||||
POSTGRES_PASSWORD: user_12345
|
|
||||||
POSTGRES_DB: test_url_shortener
|
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
app:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile.dev
|
|
||||||
volumes:
|
|
||||||
- .:/usr/src/app
|
|
||||||
- gem_cache:/usr/local/bundle/gems
|
|
||||||
command: bundle exec rails test
|
|
||||||
environment:
|
|
||||||
RAILS_ENV: test
|
|
||||||
HOSTNAME: 0.0.0.0
|
|
||||||
PORT: 3000
|
|
||||||
DATABASE_URL: postgres://user:user_12345@db:5432/test_url_shortener
|
|
||||||
depends_on:
|
|
||||||
- db
|
|
||||||
volumes:
|
|
||||||
gem_cache:
|
|
||||||
test_db_data:
|
|
||||||
+8
-5
@@ -2,13 +2,14 @@ version: '3'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:12.5-alpine
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.db
|
||||||
volumes:
|
volumes:
|
||||||
- db_data:/var/lib/postgresql/data
|
- db_data:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: user
|
POSTGRES_USER: app_user
|
||||||
POSTGRES_PASSWORD: user_12345
|
POSTGRES_PASSWORD: secure_12345
|
||||||
POSTGRES_DB: url_shortener
|
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
app:
|
app:
|
||||||
@@ -20,7 +21,9 @@ services:
|
|||||||
- gem_cache:/usr/local/bundle/gems
|
- gem_cache:/usr/local/bundle/gems
|
||||||
command: bundle exec rails s -b '0.0.0.0'
|
command: bundle exec rails s -b '0.0.0.0'
|
||||||
tty: true
|
tty: true
|
||||||
env_file: .env.dev
|
environment:
|
||||||
|
RAILS_ENV: development
|
||||||
|
HOSTNAME: 0.0.0.0
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
CREATE DATABASE url_shortener;
|
||||||
|
CREATE DATABASE test_url_shortener;
|
||||||
|
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE url_shortener TO app_user;
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE test_url_shortener TO app_user;
|
||||||
Reference in New Issue
Block a user