diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e6bb9c7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,28 @@ +# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. + +# Ignore bundler config. +/.bundle + +# Ignore all default key files +config/master.key +config/credentials/*.key + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/ +!/tmp/pids/.keep + +# Ignore storage (uploaded files in development and any SQLite databases). +/storage/* +!/storage/.keep +/tmp/storage/* +!/tmp/storage/ +!/tmp/storage/.keep + +/public/assets diff --git a/.drone.yml b/.drone.yml index e214580..34389c8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -44,3 +44,43 @@ steps: volumes: - name: bundle temp: {} + +trigger: + branch: + exclude: master + event: push + +--- +name: deploy +kind: pipeline + +steps: + - name: docker-build + image: plugins/docker + environment: + SECRET_KEY_BASE: + from_secret: secret_key_base + RAILS_MASTER_KEY: + from_secret: rails_master_key + settings: + pull_image: true + registry: docker.atomaka.com + repo: docker.atomaka.com/budget + tags: + - latest + - ${DRONE_TAG} + - name: deploy + image: appleboy/drone-ssh + settings: + host: + from_secret: unraid_host + username: + from_secret: unraid_username + key: + from_secret: unraid_ssh_key + script: + - docker pull docker.atomaka.com/budget:latest + - docker restart budget + +trigger: + event: tag diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e1c6885 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Make sure it matches the Ruby version in .ruby-version and Gemfile +ARG RUBY_VERSION=3.2.0 +FROM ruby:$RUBY_VERSION + +# Set production environment +ENV RAILS_LOG_TO_STDOUT="1" \ + RAILS_SERVE_STATIC_FILES="true" \ + RAILS_ENV="production" \ + BUNDLE_WITHOUT="development:test" + +# Install application gems +COPY Gemfile Gemfile.lock ./ +RUN bundle install + +# Copy application code +COPY . . + +# Precompile bootsnap code for faster boot times +RUN bundle exec bootsnap precompile --gemfile app/ lib/ + +# Precompiling assets for production without requiring secret RAILS_MASTER_KEY +RUN SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile + +# Entrypoint prepares database and starts app on 0.0.0.0:3000 by default, +# but can also take a rails command, like "console" or "runner" to start instead. +ENTRYPOINT ["/rails/bin/docker-entrypoint"] +EXPOSE 3000 diff --git a/Gemfile b/Gemfile index f9b353a..62b643a 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.2.0" -gem "rails", "7.0.4.2" +# unti 7.1 is out +gem "rails", git: "https://github.com/rails/rails" gem "sprockets-rails" gem "sqlite3" gem "puma" diff --git a/Gemfile.lock b/Gemfile.lock index 1f5bece..2bcf6e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,71 +1,102 @@ -GEM - remote: https://rubygems.org/ +GIT + remote: https://github.com/rails/rails + revision: 3025eaa09154f5f031f5c2e0e5b59553ff5c902b specs: - actioncable (7.0.4.2) - actionpack (= 7.0.4.2) - activesupport (= 7.0.4.2) + actioncable (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.4.2) - actionpack (= 7.0.4.2) - activejob (= 7.0.4.2) - activerecord (= 7.0.4.2) - activestorage (= 7.0.4.2) - activesupport (= 7.0.4.2) + zeitwerk (~> 2.6) + actionmailbox (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + activejob (= 7.1.0.alpha) + activerecord (= 7.1.0.alpha) + activestorage (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.4.2) - actionpack (= 7.0.4.2) - actionview (= 7.0.4.2) - activejob (= 7.0.4.2) - activesupport (= 7.0.4.2) + actionmailer (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + actionview (= 7.1.0.alpha) + activejob (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.4.2) - actionview (= 7.0.4.2) - activesupport (= 7.0.4.2) - rack (~> 2.0, >= 2.2.0) + actionpack (7.1.0.alpha) + actionview (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4.2) - actionpack (= 7.0.4.2) - activerecord (= 7.0.4.2) - activestorage (= 7.0.4.2) - activesupport (= 7.0.4.2) + actiontext (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + activerecord (= 7.1.0.alpha) + activestorage (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.4.2) - activesupport (= 7.0.4.2) + actionview (7.1.0.alpha) + activesupport (= 7.1.0.alpha) builder (~> 3.1) - erubi (~> 1.4) + erubi (~> 1.11) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4.2) - activesupport (= 7.0.4.2) + activejob (7.1.0.alpha) + activesupport (= 7.1.0.alpha) globalid (>= 0.3.6) - activemodel (7.0.4.2) - activesupport (= 7.0.4.2) - activerecord (7.0.4.2) - activemodel (= 7.0.4.2) - activesupport (= 7.0.4.2) - activestorage (7.0.4.2) - actionpack (= 7.0.4.2) - activejob (= 7.0.4.2) - activerecord (= 7.0.4.2) - activesupport (= 7.0.4.2) + activemodel (7.1.0.alpha) + activesupport (= 7.1.0.alpha) + activerecord (7.1.0.alpha) + activemodel (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + activestorage (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + activejob (= 7.1.0.alpha) + activerecord (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.4.2) + activesupport (7.1.0.alpha) concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) + rails (7.1.0.alpha) + actioncable (= 7.1.0.alpha) + actionmailbox (= 7.1.0.alpha) + actionmailer (= 7.1.0.alpha) + actionpack (= 7.1.0.alpha) + actiontext (= 7.1.0.alpha) + actionview (= 7.1.0.alpha) + activejob (= 7.1.0.alpha) + activemodel (= 7.1.0.alpha) + activerecord (= 7.1.0.alpha) + activestorage (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + bundler (>= 1.15.0) + railties (= 7.1.0.alpha) + railties (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.6) + +GEM + remote: https://rubygems.org/ + specs: addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) @@ -83,14 +114,15 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) childprocess (4.1.0) - concurrent-ruby (1.1.10) + concurrent-ruby (1.2.2) + connection_pool (2.3.0) crass (1.0.6) date (3.3.3) debug (1.6.3) irb (>= 1.3.6) reline (>= 0.3.1) - erubi (1.11.0) - globalid (1.0.0) + erubi (1.12.0) + globalid (1.1.0) activesupport (>= 5.0) i18n (1.12.0) concurrent-ruby (~> 1.0) @@ -115,9 +147,8 @@ GEM net-smtp marcel (1.0.2) matrix (0.4.2) - method_source (1.0.0) mini_mime (1.1.2) - minitest (5.16.3) + minitest (5.18.0) msgpack (1.6.0) net-imap (0.3.4) date @@ -137,36 +168,20 @@ GEM public_suffix (5.0.0) puma (6.1.1) nio4r (~> 2.0) - racc (1.6.0) - rack (2.2.4) + racc (1.6.2) + rack (2.2.6.3) + rack-session (1.0.1) + rack (< 3) rack-test (2.0.2) rack (>= 1.3) - rails (7.0.4.2) - actioncable (= 7.0.4.2) - actionmailbox (= 7.0.4.2) - actionmailer (= 7.0.4.2) - actionpack (= 7.0.4.2) - actiontext (= 7.0.4.2) - actionview (= 7.0.4.2) - activejob (= 7.0.4.2) - activemodel (= 7.0.4.2) - activerecord (= 7.0.4.2) - activestorage (= 7.0.4.2) - activesupport (= 7.0.4.2) - bundler (>= 1.15.0) - railties (= 7.0.4.2) + rackup (1.0.0) + rack (< 3) + webrick rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.5.0) loofah (~> 2.19, >= 2.19.1) - railties (7.0.4.2) - actionpack (= 7.0.4.2) - activesupport (= 7.0.4.2) - method_source - rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) regexp_parser (2.6.1) @@ -217,7 +232,7 @@ GEM actionpack (>= 6.0.0) activejob (>= 6.0.0) railties (>= 6.0.0) - tzinfo (2.0.5) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) web-console (4.2.0) @@ -229,13 +244,14 @@ GEM nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (~> 4.0) + webrick (1.8.1) websocket (1.2.9) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.6) + zeitwerk (2.6.7) PLATFORMS x86_64-linux @@ -247,7 +263,7 @@ DEPENDENCIES importmap-rails jbuilder puma - rails (= 7.0.4.2) + rails! selenium-webdriver sprockets-rails sqlite3 diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint new file mode 100755 index 0000000..32e7713 --- /dev/null +++ b/bin/docker-entrypoint @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ $# -eq 0 ]; then + # Create new or migrate existing database + ./bin/rails db:prepare + + # Start the server by default + exec bin/rails server +else + # Allow other commands, like console or runner, to be called + exec bin/rails "$@" +fi diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 5392214..beefd1d 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -31piJThknEWtbmHH3f6HVG/VQD8tI7QQEmyVrMCcu5SXHfM+5RergYrj3gB8SOg3GMczFmN95N0Hg8ux5KxCNkgUirF+myX+4I3RCAxjTU6z9jejqKpFW/m0VeZbxd51Wy/vXRafHtW8aVqS24qih3Cn74fn4wjQhqeLgDp5UXwufrN3qu54Mhcu0D+Xwqou0TpzI1C5GcWqQAA3BS0ffDt50O86aIka73JHNekCkUYN1XgpwzSJyLrJV9U88ABggzv96hHS7nFu+XgZ5h/qfp6vUUjcvNdAD6Cnc4Es7qJCK6cGxKywOkniF311de4kE9OohWJlvgk1gv95iPek/G+kZ6YA5CAGh5EGJmgoHw9VAgXS9qwzmXREv1XnUQqbSBe7f08ZBpyHalBcnlDLLeOYa77banYejaFH--w+t1KcfM0BJzs6cn--WaG989DxzVCeJ4DV37z0TA== \ No newline at end of file +gAAw/qVSk9mVnRdIqpzKdOubWHFa+FUwKzsq9FuPNHQOKBSk5SEwcsC3sI8rNqWsppVYrWHxmdVMA+LipeRmhtR+ovPidi4TrcjfpB65Vaz3MzkNYn9ErT6FbB1WYXep01n1MMJb0amXg+8K5rnPOMSki+XpYLkM5LFhlL83xy8eSwc4bSVuvHEcafEcC3G4ufatDY4DC7QfAwS51ddMe4UJ3P/ehn716A7YBl6RDJBgmGHJ+wztFC84bEQ5g8AF4T5+pr2HYFoJpfxtuKGDUBwqF3lhNwa1CMgTuGqLY8I6jx2g7Ou7qOc4vwBG3+NLGY2XcfmstPrM93thBLexGfZ+qFPCTU/7jEmH/Z30V8nkYimNcmlJdNRhX53yMXv2xvIh1AA9EpVpIyGiF3j9+4vh5AplYRG5JCCQfsetBAS6V4pngz83WEfy/D6zIbuIuMe6ewKKZZrW2ZUyzoFXjS5CQoq7rI+xIBm40gKFSV8Akl6lJc+wwfK231CwagsqDJLsHHdg4KHnVzcnk6ld9VIP7S4rh/BaIkYYmCESs8AnTtEmztSRhyu88ojKv7kMwSmBNlcPi73fsPo+duP7+Y3U0kHdg68fAjgeAjnQx4HUhdzNs80=--L582Wef3fKjdx2rY--aXOMAjCFS2ywLLopeuoV3w== \ No newline at end of file