Skip to content
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
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ruby:2.3-jessie

ENV APP_HOME=/app
ENV BUNDLER_GEMFILE=/app/Gemfile
ENV BUNDLE_PATH=/gems
ENV LANG=C.UTF-8
ENV LANGUAGE="$LANG"
ENV LC_ALL="$LANG"
ENV TZ=Europe/Moscow

RUN mkdir $APP_HOME \
&& echo "en_US ISO-8859-1" > /etc/locale.gen \
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
&& echo "ru_RU ISO-8859-5" >> /etc/locale.gen \
&& echo "ru_RU.CP1251 CP1251" >> /etc/locale.gen \
&& echo "ru_RU.KOI8-R KOI8-R" >> /etc/locale.gen \
&& echo "ru_RU.UTF-8 UTF-8" >> /etc/locale.gen \
&& echo "ru_RU.UTF-8 UTF-8" >> /etc/locale.gen \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& apt-get update \
&& apt-get install -y \
libmysqlclient-dev \
libpq-dev \
libssl-dev \
locales \
mysql-client \

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

nodejs \
postgresql-client \

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

sqlite3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR $APP_HOME
ADD Gemfile* $APP_HOME/
ADD . $APP_HOME

RUN gem install bundler -v 1.17.3 \
&& bundle install --deployment --without development test --with plugins --jobs=3

EXPOSE 3000
CMD [ "bundle", "exec", "rails", "server", "-b", "0.0.0.0", "-p", "3000" ]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

И, конечно, не забыть указать актуальные данные в `config/database.yml`.

Если вы не используете Docker, то удалите **host: postgres** из настроек development окружения.

Далее считаем, что имя БД: `open_cook_dev`

### Создать пустую Базу Данных
Expand Down
66 changes: 66 additions & 0 deletions Readme.Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
## Установка с помощью docker и docker-compose

**1. Необходимое ПО**

- [Docker](https://docs.docker.com/get-started/)
- [Docker Compose](https://docs.docker.com/compose/)

*Проверить наличие*

```bash
$ docker -v
> Docker version 19.03.1

$ docker-compose -v
> docker-compose version 1.24.1
```

**2. Скопируйте конфигурационные файлы**

- `cp -R config/config.examples/ENV/ config/ENV`
- `cp config/config.examples/database.yml config/database.yml`

**3. Запустить команду для поднятия окружения**

- `docker-compose --verbose build`

**4. Архив данных для разработки**

- Получите архив данных для разработки `obfuscated_data.tar.gz` (Смотри: [data_obfuscation.rake](lib/tasks/README.md))
- Поместите архив к каталог `./tmp`
- Распакуйте архив
```
mkdir -p ./tmp/untar

tar xvzf ./tmp/obfuscated_data.tar.gz -C ./tmp/untar
```

**5. Скопируйте фалйы в каталог ./public**

`Не проверено`

**6. Загрузите Базу Данных**

`Не проверено`

- `docker cp Developer/open-cook.ru.rails_app_db.dump ok-2018_postgres_1:/`
- `docker exec ok-2018_postgres_1 pg_restore -U postgres -d open_cook_dev backups/open-cook.ru.rails_app_db.dump`

**7. Проиндексируйте данные для Поиска**

`Не проверено`

- `docker exec ok-2018_web_1 rake ts:configure ts:restart`
- `docker exec ok-2018_web_1 rake ts:index`

**8. Запустите проект**

- `docker-compose up`

**9. Доступ в Rails console**

`Не проверено`

**10. Выполение rake tasks и других команд в контейнере**

`Не проверено`
1 change: 1 addition & 0 deletions config/config.examples/database.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
development:
host: postgres
adapter: postgresql
encoding: unicode
database: open_cook_dev
Expand Down
44 changes: 44 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: '3'
services:
# postgres:
# image: postgres:11
# restart: always
# environment:
# - POSTGRES_DATABSE=open_cook_dev
# - POSTGRES_DB=open_cook_dev
# - POSTGRES_USER=postgres
# - POSTGRES_PASSWORD=postgres
# volumes:
# - ./data:/var/lib/postgresql/data

redis:
image: 'redis:4.0-alpine'
command: redis-server
volumes:
- './data:/var/lib/redis/data'

mysql:
image: mysql:5.7
restart: always
command: --explicit_defaults_for_timestamp
environment:
MYSQL_DATABASE: 'db'
MYSQL_USER: 'user'
MYSQL_PASSWORD: 'password'
MYSQL_ROOT_PASSWORD: 'password'
ports:
- '3306:3306'
expose:
- '3306'
volumes:
- ./data:/var/lib/mysql/data

web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/myapp
ports:
- "3000:3000"
links:
- postgres
11 changes: 9 additions & 2 deletions lib/tasks/data_obfuscation.rake
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ namespace :data_obfuscation do
system('rake data_obfuscation:cleanup_tmp_files')
end


task unzip: :environment do
script_message('Unzipping the archive')
system("mkdir #{UNTAR_DIR}")
system("tar xvzf #{OBFUSCATED_ARCHIVE} -C #{UNTAR_DIR}")
end

task setup: :environment do
db = Rails.configuration.database_configuration['development']
db_name = db['database']
Expand All @@ -55,8 +62,8 @@ namespace :data_obfuscation do
system('RAILS_ENV=development rake db:create')

script_message('Preparing to restore')
system("mkdir #{UNTAR_DIR}")
system("tar xvzf #{OBFUSCATED_ARCHIVE} -C #{UNTAR_DIR}")

system('RAILS_ENV=development rake data_obfuscation:unzip')

script_message('Restore Obfuscated DB')
system("pg_restore --verbose --clean --no-owner --no-acl --dbname #{db_name} #{DB_TO_RESTORE}")
Expand Down