Added db:migrate and DATABASE variable

This commit is contained in:
Pavel Pivovarov
2018-12-07 22:09:26 +11:00
parent 7bf96dd47f
commit 8b53e05b06
3 changed files with 5 additions and 10 deletions

View File

@@ -27,9 +27,8 @@ RUN gem install bundler && bundle install
VOLUME /app/db/database VOLUME /app/db/database
RUN bin/rake assets:precompile RUN bundle exec rake assets:precompile
EXPOSE 3000 EXPOSE 3000
ENTRYPOINT ["bundle", "exec"] CMD cd /app && rake 'db:migrate' && bundle exec rails server -b 0.0.0.0
CMD ["rails", "server", "-b", "0.0.0.0"]

View File

@@ -25,10 +25,6 @@ docker run -d --name snibox \
snibox snibox
``` ```
After first run you probably will see error due to database hasn't been initialized in the attached volume. Pleas run following command to create empty database: Default database file location is `/app/db/database/snibox.sqlite3`, however you can redefine it by using environment variable `DATABASE`.
```bash Container is running `rake db:migrate` on every start, in order to either create database if not exist, or update database scheme if required, so backups are highly recommended.
docker exec <container_id> /app/bin/rails db:migrate
```
This will create new database instance and Snibox is ready to go.

View File

@@ -2,4 +2,4 @@ development:
adapter: sqlite3 adapter: sqlite3
pool: 5 pool: 5
timeout: 5000 timeout: 5000
database: db/database/snibox.sqlite3 database: <%= ENV['DATABASE'] || "db/database/snibox.sqlite3" %>