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
Docker dev environment #103
Changes from all commits
78630b4
13f46f2
26c3dd8
93a3740
1564085
24ef71b
ea73f3f
7f9e4bb
71af3e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.git* | ||
log/* | ||
tmp/* | ||
Dockerfile | ||
README.md |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM ruby:2.3.3 | ||
|
||
RUN apt-get update -qq && apt-get install -y \ | ||
build-essential \ | ||
libpq-dev \ | ||
nodejs | ||
|
||
ENV app /app | ||
ENV BUNDLE_PATH /gems | ||
|
||
RUN mkdir -p $app | ||
WORKDIR $app | ||
|
||
# Copy the main application. | ||
ADD . $app | ||
|
||
EXPOSE 3000 | ||
|
||
CMD rails s -b 0.0.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
bundle check || bundle install | ||
rm tmp/pids/* | ||
bundle exec rails s -b 0.0.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
development: &default | ||
adapter: postgresql | ||
database: it61_development | ||
url: <%= ENV.fetch("DATABASE_URL") %>_development | ||
encoding: utf8 | ||
min_messages: warning | ||
pool: <%= Integer(ENV.fetch("DB_POOL", 5)) %> | ||
|
@@ -9,11 +8,11 @@ development: &default | |
|
||
test: | ||
<<: *default | ||
database: it61_test | ||
database: <%= ENV.fetch("DATABASE_URL") %>_test | ||
|
||
production: | ||
encoding: utf8 | ||
min_messages: warning | ||
pool: <%= [Integer(ENV.fetch("MAX_THREADS", 5)), Integer(ENV.fetch("DB_POOL", 5))].max %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Может достаточно одной переменной? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тут ничего не менял, подумал раз так есть, может так и надо... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vitallium, это нужно?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно. прод работает в контейнерах, и это нужно для горизонтального масштабирования. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это понятно, но почему мы не можем использовать всегда какую-то одну из этих env переменных? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А по поводу потоков, еще сам schneems писал, что:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Флудеры! 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Да, давайте (если есть желание) это обсудим в #rndrug :-) а то никогда не смержим There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. И тут я такой заметил, что в There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ну т.е. это MAX_THREADS – это что-то неведомое. Я бы это выкосил |
||
timeout: 5000 | ||
url: <%= ENV.fetch("DATABASE_URL", "") %> | ||
url: <%= ENV.fetch("DATABASE_URL", "") %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Для чего указывать пустую строку по умолчанию, путь лучше райзится исключение, если с конфигурацией что-то не так. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. См. комент выше, я просто лишний пробел убрал :) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version: '2' | ||
services: | ||
# Main application container | ||
app: | ||
build: . | ||
command: bin/docker_up | ||
volumes: | ||
- .:/app | ||
volumes_from: | ||
- gems | ||
ports: | ||
- "3000:3000" | ||
environment: | ||
- DATABASE_URL=postgres://postgres@db:5432/it61 | ||
- REDIS_URL=redis://redis:6379/1 | ||
depends_on: | ||
- db | ||
- redis | ||
|
||
# Mounted folder for Gemfile gems container | ||
gems: | ||
image: busybox | ||
volumes: | ||
- /gems | ||
|
||
# Container with database | ||
db: | ||
image: postgres | ||
ports: | ||
- "6543:5432" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А зачем пробрасывать порт из контейнера бд на хост? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Мало ли надо будет в базу залезть, посмотреть что там... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Я тоже использую такую настройку, чтобы смотреть, что с базой творится. |
||
|
||
redis: | ||
image: redis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вот эта строчка сломала локальное окружение (╯°□°)╯︵ ┻━┻