Skip to content

Commit

Permalink
Merge pull request #5088 from coopdevs/do-not-recreate-when-booting-d…
Browse files Browse the repository at this point in the history
…ocker

Do not reset the dev env when booting docker
  • Loading branch information
luisramos0 authored Apr 7, 2020
2 parents e0e2c32 + 109da43 commit 29bbf2f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
11 changes: 9 additions & 2 deletions DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,20 @@ Download the Docker images and build the containers:
$ docker-compose build
```

Run the app with all the required containers:
Setup the database and seed it with sample data:
```sh
$ docker-compose run web bundle exec rake db:reset
$ docker-compose run web bundle exec rake db:test:prepare
$ docker-compose run web bundle exec rake ofn:sample_data
```

Finally, run the app with all the required containers:

```sh
$ docker-compose up
```

This command will setup the database and seed it with sample data. The default admin user is '[email protected]' with 'ofn123' password.
The default admin user is '[email protected]' with 'ofn123' password.
Check the app in the browser at `http://localhost:3000`.

You will then get the trace of the containers in the terminal. You can stop the containers using Ctrl-C in the terminal.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ENV BUNDLE_PATH /bundles
WORKDIR /usr/src/app
COPY .ruby-version .

# Rbenv & Ruby part
# Install Rbenv & Ruby
RUN git clone https://github.com/rbenv/rbenv.git ${RBENV_ROOT} && \
git clone https://github.com/rbenv/ruby-build.git ${RBENV_ROOT}/plugins/ruby-build && \
${RBENV_ROOT}/plugins/ruby-build/install.sh && \
Expand All @@ -21,7 +21,7 @@ RUN git clone https://github.com/rbenv/rbenv.git ${RBENV_ROOT} && \
rbenv global $(cat .ruby-version) && \
gem install bundler --version=1.17.2

# Postgres
# Install Postgres
RUN sh -c "echo 'deb https://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main' > /etc/apt/sources.list.d/pgdg.list" && \
wget --quiet -O - https://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - && \
apt-get update && \
Expand All @@ -38,4 +38,6 @@ RUN wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.z
unzip chromedriver_linux64.zip -d /usr/bin && \
chmod u+x /usr/bin/chromedriver

# Copy code and install app dependencies
COPY . /usr/src/app/
RUN bundle install
5 changes: 1 addition & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ services:
ADMIN_PASSWORD: ofn123
OFN_DB_HOST: db
command: >
bash -c "(bundle check || bundle install) &&
wait-for-it -t 30 db:5432 &&
bundle exec rake db:reset &&
bundle exec rake db:test:prepare ofn:sample_data || true &&
bash -c "wait-for-it -t 30 db:5432 &&
rm -f tmp/pids/server.pid &&
bundle exec rails s -p 3000 -b '0.0.0.0'"
Expand Down

0 comments on commit 29bbf2f

Please sign in to comment.