Skip to content

Instantly share code, notes, and snippets.

@elia
Created February 13, 2023 09:36
Show Gist options
  • Save elia/705515d6b3a6480ede548bec48c8fd27 to your computer and use it in GitHub Desktop.
Save elia/705515d6b3a6480ede548bec48c8fd27 to your computer and use it in GitHub Desktop.
diff --git a/Gemfile b/Gemfile
index 09e2601..88f92c8 100644
--- a/Gemfile
+++ b/Gemfile
@@ -70,3 +70,5 @@
gem "selenium-webdriver"
gem "webdrivers"
end
+
+gem "foreman"
diff --git a/Gemfile.lock b/Gemfile.lock
index 874da0f..af1f26a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -88,6 +88,7 @@ GEM
irb (>= 1.5.0)
reline (>= 0.3.1)
erubi (1.12.0)
+ foreman (0.87.2)
globalid (1.1.0)
activesupport (>= 5.0)
i18n (1.12.0)
@@ -127,6 +128,8 @@ GEM
nio4r (2.5.8)
nokogiri (1.14.1-arm64-darwin)
racc (~> 1.4)
+ nokogiri (1.14.1-x86_64-linux)
+ racc (~> 1.4)
public_suffix (5.0.1)
puma (5.6.5)
nio4r (~> 2.0)
@@ -179,6 +182,7 @@ GEM
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.6.0-arm64-darwin)
+ sqlite3 (1.6.0-x86_64-linux)
stimulus-rails (1.2.1)
railties (>= 6.0.0)
thor (1.2.1)
@@ -208,11 +212,13 @@ GEM
PLATFORMS
arm64-darwin-21
+ x86_64-linux
DEPENDENCIES
bootsnap
capybara
debug
+ foreman
importmap-rails
jbuilder
puma (~> 5.0)
diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..e354234
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: foreman start --procfile=Procfile.production
diff --git a/Procfile.production b/Procfile.production
new file mode 100644
index 0000000..92c7a9b
--- /dev/null
+++ b/Procfile.production
@@ -0,0 +1,2 @@
+rails: bin/rails server -p $PORT -e $RAILS_ENV
+sqlite: bin/litestream db/${RAILS_ENV:-development}.sqlite3 ${LITESTREAM_URL}
diff --git a/bin/litestream b/bin/litestream
new file mode 100755
index 0000000..d95dd07
--- /dev/null
+++ b/bin/litestream
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+${LITESTREAM_PATH:-litestream} restore -o $1 $2 && \
+ echo "Litestream restored to $1" && \
+ ${LITESTREAM_PATH:-litestream} replicate $1 $2
diff --git a/bin/litestream-linux b/bin/litestream-linux
new file mode 100755
index 0000000..5aa5b8c
Binary files /dev/null and b/bin/litestream-linux differ
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 9d69393..c520e49 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -90,4 +90,6 @@
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
+
+ config.active_record.sqlite3_production_warning = false
end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000..2fcef30
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,21 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# This file is the source Rails uses to define your schema when running `bin/rails
+# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
+# be faster and is potentially less error prone than running all of your
+# migrations from scratch. Old migrations may fail to apply correctly if those
+# migrations use external dependencies or application code.
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema[7.0].define(version: 2023_02_12_100015) do
+ create_table "posts", force: :cascade do |t|
+ t.string "title"
+ t.text "body"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment