From 6845943e5e82aef2c38cbba9940965beacb7993c Mon Sep 17 00:00:00 2001 From: Ben Purinton Date: Fri, 9 Jun 2023 21:35:38 +0000 Subject: [PATCH 1/4] remove rake stuff, move db connection to dev --- Gemfile | 2 -- Gemfile.lock | 1 - Rakefile | 7 ------- config/environment.rb | 6 +++--- 4 files changed, 3 insertions(+), 13 deletions(-) delete mode 100644 Rakefile diff --git a/Gemfile b/Gemfile index ed72702..300de59 100644 --- a/Gemfile +++ b/Gemfile @@ -11,8 +11,6 @@ gem 'puma', '~> 5.0' # use active record gem 'sinatra-activerecord' -# use rake -gem "rake" group :development do gem 'better_errors' diff --git a/Gemfile.lock b/Gemfile.lock index 54e8de6..8b9a2eb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -165,7 +165,6 @@ DEPENDENCIES i18n pry puma (~> 5.0) - rake rspec rspec-html-matchers sinatra diff --git a/Rakefile b/Rakefile deleted file mode 100644 index df0e18c..0000000 --- a/Rakefile +++ /dev/null @@ -1,7 +0,0 @@ -require "sinatra/activerecord/rake" - -namespace :db do - task :load_config do - require "./config/environment.rb" - end -end diff --git a/config/environment.rb b/config/environment.rb index fd78f1c..a7e40b9 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -8,9 +8,6 @@ # we can set the default layout name to use and sinatra # will look for that file set(:erb, :layout => :application_layout) - - # setup a database connection - set(:database, {adapter: "sqlite3", database: "db/development.sqlite3"}) end configure :development do @@ -34,4 +31,7 @@ config.pryrc = :full; end AppdevSupport.init + + # setup a database connection + set(:database, {adapter: "sqlite3", database: "db/development.sqlite3"}) end From b4c6d11976f5f43e69e6c505acada34a01eedb56 Mon Sep 17 00:00:00 2001 From: Ben Purinton Date: Fri, 9 Jun 2023 21:37:38 +0000 Subject: [PATCH 2/4] create tasks model --- db/development.sqlite3 | Bin 0 -> 12288 bytes db/migrate/create_tasks.rb | 8 ++++++++ 2 files changed, 8 insertions(+) create mode 100644 db/development.sqlite3 create mode 100644 db/migrate/create_tasks.rb diff --git a/db/development.sqlite3 b/db/development.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..7449ca76f33260c2d04b680816a89ea35162f277 GIT binary patch literal 12288 zcmeI#Jx{|h5C&koMKJNPWj%RH)rtkFGXX`YBK@GGL#E0kE<`kGo4AOz{8lD@1(%3Q zPzf=yRPRZ4a?aUNo=kUt7o^tEY*A#|(uFt^Qi@9=A%x`7s!TAMuH zO`F$a-wS;Ty{o{domw~7nd$J(*5*bYIgTUWvieM`%jdG58b9`{dQFk5(nL|3Tk~iN z8jX8>ZyeFBACWf+hrI!B>idI`216c`An1^)UZv Date: Fri, 9 Jun 2023 21:38:58 +0000 Subject: [PATCH 3/4] some local CRUDing --- db/development.sqlite3 | Bin 12288 -> 12288 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 7449ca76f33260c2d04b680816a89ea35162f277..cdfce7e0098e492a3fd39855a607006d84e54bdd 100644 GIT binary patch delta 123 zcmZojXh@hK&B!`Y#+i|IW5N=CHb(w^4E*~x3kq!E_i Date: Fri, 9 Jun 2023 21:41:32 +0000 Subject: [PATCH 4/4] fly launch, dockerignore dev db --- .dockerignore | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 40 ++++++++++++++++++++++++++++++++++++++++ fly.toml | 14 ++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 fly.toml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a51b880 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,49 @@ +# flyctl launch added from .gitignore +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +.bundle + +# Ignore the default SQLite database. +# /db/*.sqlite3 +# /db/*.sqlite3-journal +db/*.sqlite3-* + +# Ignore all logfiles and tempfiles. +log/* +tmp/* +!log/.keep +!tmp/.keep + +# Ignore uploaded files in development. +storage/* +!storage/.keep + +public/assets +**/.byebug_history + +# Ignore master key for decrypting credentials and more. +config/master.key + +# Ignore dotenv files +.env* + +**/.rbenv-gemsets +**/examples.txt +**/whitelist.yml +**/grades.yml +**/cloud9_plugins.sh +**/appdev +**/node_modules +**/package-lock.json +**/core.chrome* +**/.theia/.ltici_apitoken.yml +**/.vscode/.ltici_apitoken.yml +fly.toml + +# ignore your local database +db/development.sqlite3 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..562ef1a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +ARG RUBY_VERSION=3.2.1 +FROM ruby:$RUBY_VERSION-slim as base + +# Rack app lives here +WORKDIR /app + +# Update gems and bundler +RUN gem update --system --no-document && \ + gem install -N bundler + + +# Throw-away build stage to reduce size of final image +FROM base as build + +# Install packages needed to build gems +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y build-essential + +# Install application gems +COPY Gemfile* . +RUN bundle install + + +# Final stage for app image +FROM base + +# Run and own the application files as a non-root user for security +RUN useradd ruby --home /app --shell /bin/bash +USER ruby:ruby + +# Copy built artifacts: gems, application +COPY --from=build /usr/local/bundle /usr/local/bundle +COPY --from=build --chown=ruby:ruby /app /app + +# Copy application code +COPY --chown=ruby:ruby . . + +# Start the server +EXPOSE 8080 +CMD ["bundle", "exec", "rackup", "--host", "0.0.0.0", "--port", "8080"] diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..020e40d --- /dev/null +++ b/fly.toml @@ -0,0 +1,14 @@ +# fly.toml app configuration file generated for sinatra-task-list on 2023-06-09T21:40:50Z +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = "sinatra-task-list" +primary_region = "sea" + +[http_service] + internal_port = 8080 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0