diff --git a/Dockerfile b/Dockerfile index 2585e1d..5d409eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,9 +27,8 @@ RUN gem install bundler && bundle install VOLUME /app/db/database -RUN bin/rake assets:precompile +RUN bundle exec rake assets:precompile EXPOSE 3000 -ENTRYPOINT ["bundle", "exec"] -CMD ["rails", "server", "-b", "0.0.0.0"] +CMD cd /app && rake 'db:migrate' && bundle exec rails server -b 0.0.0.0 diff --git a/README.md b/README.md index cde74dd..0c43589 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,6 @@ docker run -d --name 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 -docker exec /app/bin/rails db:migrate -``` - -This will create new database instance and Snibox is ready to go. \ No newline at end of file +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. \ No newline at end of file diff --git a/config/database.yml b/config/database.yml index c2b36e7..714ab67 100644 --- a/config/database.yml +++ b/config/database.yml @@ -2,4 +2,4 @@ development: adapter: sqlite3 pool: 5 timeout: 5000 - database: db/database/snibox.sqlite3 + database: <%= ENV['DATABASE'] || "db/database/snibox.sqlite3" %>