[RAILS] [Heroku-Bereitstellungsverfahren ③] Von der Ruby-Versionsspezifikation zur Bereitstellung und zum Zugriff auf die Anwendung (abgeschlossen)

Einführung

Dieses Mal möchte ich die Heroku-Bereitstellung in der Fortsetzung der vorherigen Zeit ausführen, auf die Anwendung zugreifen und die Ausgabe des Prozesses in der Heroku-Bereitstellung abschließen.

Wenn Sie die vorherige ** [Heroku-Bereitstellungsprozedur (2)] von der Erstellung einer neuen App bis zur Anzeige der Indexaktion ** nicht gelesen haben, überprüfen Sie dies bitte zuerst. (Von der URL unten) https://qiita.com/nkekisasa222/items/52c872957b30f4e8de1e

Umgebung

Schienen 5er Serie macOS catalina 10.15

Geben Sie die Ruby-Version an

Für Rails 5 ist Ruby 2.2.0 oder höher erforderlich. Überprüfen Sie dies mit dem folgenden Befehl.

Terminal.


$ ruby -v

Beschreiben Sie als Nächstes die bestätigte Version in der Gem-Datei wie unten gezeigt.

Gemfile.


ruby 'Bestätigte Version'

Speichern Sie die App auf Git

Überprüfen Sie zunächst, ob Git installiert ist.

Terminal.


$ git --help
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

Wenn es so angezeigt wird, gibt es kein Problem. Wenn nichts angezeigt wird oder "Befehl nicht gefunden" angezeigt wird, installieren Sie git unter der folgenden URL.

https://git-scm.com/book/ja/v2/%E4%BD%BF%E3%81%84%E5%A7%8B%E3%82%81%E3%82%8B-Git%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB

Überprüfen Sie als Nächstes das Rails-App-Verzeichnis mit dem folgenden Befehl.

Terminal.


$ ls
Gemfile
Gemfile-e
Gemfile.lock
README.md
Rakefile
app
bin
config
config.ru
db
lib
log
package.json
public
storage
test
tmp
vendor

Führen Sie den folgenden Befehl im Rails-App-Verzeichnis aus, um den Code zu initialisieren und an Git zu übergeben.

Terminal.


$ git init
$ git add .
$ git commit -m "init"

Sie können überprüfen, ob alles erfolgreich festgeschrieben wurde, indem Sie den folgenden Befehl ausführen:

Terminal.


$ git status
On branch master
nothing to commit, working tree clean

Nachdem die Anwendung für Git festgeschrieben wurde, können Sie sie für Heroku bereitstellen.

Stellen Sie die App auf Heroku bereit

Stellen Sie sicher, dass Sie sich in dem Verzeichnis befinden, das Ihre Rails-App enthält, und erstellen Sie die App in Heroku.

Terminal.


$ heroku create
Creating app... done, secret-tor-42278
https://secret-tor-42278.herokuapp.com/ | https://git.heroku.com/secret-tor-42278.git

Sie können überprüfen, ob die Fernbedienung zu Ihrem Projekt hinzugefügt wurde, indem Sie den folgenden Befehl ausführen:

Terminal.


$ git config --list | grep heroku
remote.heroku.url=https://git.heroku.com/secret-tor-42278.git
remote.heroku.fetch=+refs/heads/*:refs/remotes/heroku/*

Wenn Sie # fatal: not in a git directory sehen, befinden Sie sich wahrscheinlich nicht im richtigen Verzeichnis. Versuchen Sie es erneut mit dem Befehl ls.

Stellen Sie dann den Code bereit.

Terminal.


$ git push heroku master
remote: Compressing source files... done.
remote: Building source:
remote:
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:             Detected buildpacks: Ruby,Node.js
remote:             See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.6.0
remote: -----> Installing dependencies using bundler 1.15.2
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
remote:        Fetching gem metadata from https://rubygems.org/.........
remote:        Fetching rake 12.3.2
remote:        Installing rake 12.3.2
remote:        Fetching concurrent-ruby 1.1.4
remote:        Fetching thread_safe 0.3.6
remote:        Fetching minitest 5.11.3
remote:        Installing thread_safe 0.3.6
remote:        Installing minitest 5.11.3
remote:        Installing concurrent-ruby 1.1.4
remote:        Fetching builder 3.2.3
remote:        Installing builder 3.2.3
remote:        Fetching erubi 1.8.0
remote:        Installing erubi 1.8.0
remote:        Fetching mini_portile2 2.4.0
remote:        Fetching crass 1.0.4
remote:        Installing mini_portile2 2.4.0
remote:        Fetching rack 2.0.6
remote:        Installing crass 1.0.4
remote:        Installing rack 2.0.6
remote:        Fetching nio4r 2.3.1
remote:        Installing nio4r 2.3.1 with native extensions
remote:        Fetching websocket-extensions 0.1.3
remote:        Installing websocket-extensions 0.1.3
remote:        Fetching mini_mime 1.0.1
remote:        Installing mini_mime 1.0.1
remote:        Fetching arel 9.0.0
remote:        Installing arel 9.0.0
remote:        Fetching mimemagic 0.3.3
remote:        Fetching msgpack 1.2.4
remote:        Installing msgpack 1.2.4 with native extensions
remote:        Installing mimemagic 0.3.3
remote:        Using bundler 1.17.2
remote:        Fetching coffee-script-source 1.12.2
remote:        Installing coffee-script-source 1.12.2
remote:        Fetching execjs 2.7.0
remote:        Installing execjs 2.7.0
remote:        Fetching method_source 0.9.2
remote:        Installing method_source 0.9.2
remote:        Fetching thor 0.20.3
remote:        Installing thor 0.20.3
remote:        Fetching ffi 1.9.25
remote:        Installing ffi 1.9.25 with native extensions
remote:        Fetching multi_json 1.13.1
remote:        Installing multi_json 1.13.1
remote:        Fetching pg 1.1.3
remote:        Installing pg 1.1.3 with native extensions
remote:        Fetching puma 3.12.0
remote:        Installing puma 3.12.0 with native extensions
remote:        Fetching rb-fsevent 0.10.3
remote:        Installing rb-fsevent 0.10.3
remote:        Fetching tilt 2.0.9
remote:        Installing tilt 2.0.9
remote:        Fetching turbolinks-source 5.2.0
remote:        Installing turbolinks-source 5.2.0
remote:        Fetching tzinfo 1.2.5
remote:        Installing tzinfo 1.2.5
remote:        Fetching nokogiri 1.9.1
remote:        Installing nokogiri 1.9.1 with native extensions
remote:        Fetching i18n 1.4.0
remote:        Installing i18n 1.4.0
remote:        Fetching websocket-driver 0.7.0
remote:        Installing websocket-driver 0.7.0 with native extensions
remote:        Fetching mail 2.7.1
remote:        Installing mail 2.7.1
remote:        Fetching rack-test 1.1.0
remote:        Installing rack-test 1.1.0
remote:        Fetching sprockets 3.7.2
remote:        Installing sprockets 3.7.2
remote:        Fetching marcel 0.3.3
remote:        Installing marcel 0.3.3
remote:        Fetching coffee-script 2.4.1
remote:        Installing coffee-script 2.4.1
remote:        Fetching uglifier 4.1.20
remote:        Installing uglifier 4.1.20
remote:        Fetching bootsnap 1.3.2
remote:        Installing bootsnap 1.3.2 with native extensions
remote:        Fetching rb-inotify 0.10.0
remote:        Installing rb-inotify 0.10.0
remote:        Fetching turbolinks 5.2.0
remote:        Installing turbolinks 5.2.0
remote:        Fetching activesupport 5.2.2
remote:        Installing activesupport 5.2.2
remote:        Fetching loofah 2.2.3
remote:        Fetching sass-listen 4.0.0
remote:        Installing loofah 2.2.3
remote:        Installing sass-listen 4.0.0
remote:        Fetching rails-dom-testing 2.0.3
remote:        Installing rails-dom-testing 2.0.3
remote:        Fetching globalid 0.4.1
remote:        Installing globalid 0.4.1
remote:        Fetching activemodel 5.2.2
remote:        Installing activemodel 5.2.2
remote:        Fetching jbuilder 2.8.0
remote:        Installing jbuilder 2.8.0
remote:        Fetching sass 3.7.2
remote:        Installing sass 3.7.2
remote:        Fetching rails-html-sanitizer 1.0.4
remote:        Installing rails-html-sanitizer 1.0.4
remote:        Fetching activejob 5.2.2
remote:        Installing activejob 5.2.2
remote:        Fetching activerecord 5.2.2
remote:        Fetching actionview 5.2.2
remote:        Installing activerecord 5.2.2
remote:        Installing actionview 5.2.2
remote:        Fetching actionpack 5.2.2
remote:        Installing actionpack 5.2.2
remote:        Fetching actioncable 5.2.2
remote:        Fetching activestorage 5.2.2
remote:        Fetching actionmailer 5.2.2
remote:        Installing actioncable 5.2.2
remote:        Installing actionmailer 5.2.2
remote:        Installing activestorage 5.2.2
remote:        Fetching railties 5.2.2
remote:        Installing railties 5.2.2
remote:        Fetching sprockets-rails 3.2.1
remote:        Installing sprockets-rails 3.2.1
remote:        Fetching coffee-rails 4.2.2
remote:        Fetching sass-rails 5.0.7
remote:        Fetching rails 5.2.2
remote:        Installing rails 5.2.2
remote:        Installing coffee-rails 4.2.2
remote:        Installing sass-rails 5.0.7
remote:        Bundle complete! 18 Gemfile dependencies, 61 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into `./vendor/bundle`
remote:        Post-install message from i18n:
remote:
remote:        HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
remote:        But that may break your application.
remote:
remote:        Please check your Rails app for 'config.i18n.fallbacks = true'.
remote:        If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
remote:        'config.i18n.fallbacks = [I18n.default_locale]'.
remote:        If not, fallbacks will be broken in your app by I18n 1.1.x.
remote:
remote:        For more info see:
remote:        https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
remote:
remote:        Post-install message from sass:
remote:
remote:        Ruby Sass is deprecated and will be unmaintained as of 26 March 2019.
remote:
remote:        * If you use Sass as a command-line tool, we recommend using Dart Sass, the new
remote:          primary implementation: https://sass-lang.com/install
remote:
remote:        * If you use Sass as a plug-in for a Ruby web framework, we recommend using the
remote:          sassc gem: https://github.com/sass/sassc-ruby#readme
remote:
remote:        * For more details, please refer to the Sass blog:
remote:          http://sass.logdown.com/posts/7081811
remote:
remote:        Removing bundler (1.15.2)
remote:        Bundle completed (42.62s)
remote:        Cleaning up the bundler cache.
remote:        The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
remote: -----> Installing node-v8.10.0-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Yarn executable was not detected in the system.
remote:        Download Yarn at https://yarnpkg.com/en/docs/install
remote:        I, [2019-01-03T17:16:39.683335 #1309]  INFO -- : Writing /tmp/build_020cb65e00979312f798ba48446f2064/public/assets/application-9622f0fe63bfad91bdeaa3a771e86262263840678fd66849b311b6cfb3f7cc85.js
remote:        I, [2019-01-03T17:16:39.683750 #1309]  INFO -- : Writing /tmp/build_020cb65e00979312f798ba48446f2064/public/assets/application-9622f0fe63bfad91bdeaa3a771e86262263840678fd66849b311b6cfb3f7cc85.js.gz
remote:        I, [2019-01-03T17:16:39.693392 #1309]  INFO -- : Writing /tmp/build_020cb65e00979312f798ba48446f2064/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css
remote:        I, [2019-01-03T17:16:39.693515 #1309]  INFO -- : Writing /tmp/build_020cb65e00979312f798ba48446f2064/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css.gz
remote:        Asset precompilation completed (3.72s)
remote:        Cleaning assets
remote:        Running: rake assets:clean
remote: -----> Detecting rails configuration
remote:
remote: ###### WARNING:
remote:
remote:        You set your `config.active_storage.service` to :local in production.
remote:        If you are uploading files to this app, they will not persist after the app
remote:        is restarted, on one-off dynos, or if the app has multiple dynos.
remote:        Heroku applications have an ephemeral file system. To
remote:        persist uploaded files, please use a service such as S3 and update your Rails
remote:        configuration.
remote:
remote:        For more information can be found in this article:
remote:          https://devcenter.heroku.com/articles/active-storage-on-heroku
remote:
remote:
remote: ###### WARNING:
remote:
remote:        We detected that some binary dependencies required to
remote:        use all the preview features of Active Storage are not
remote:        present on this system.
remote:
remote:        For more information please see:
remote:          https://devcenter.heroku.com/articles/active-storage-on-heroku
remote:
remote:
remote: ###### WARNING:
remote:
remote:        No Procfile detected, using the default web server.
remote:        We recommend explicitly declaring how to boot your server process via a Procfile.
remote:        https://devcenter.heroku.com/articles/ruby-default-web-server
remote:
remote:
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> console, rake, web
remote:
remote: -----> Compressing...
remote:        Done: 41.3M
remote: -----> Launching...
remote:        Released v6
remote:        https://secret-tor-42278.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/secret-tor-42278.git
 * [new branch]      master -> master

Es ist immer ratsam, die Ausführungsergebnisse auf Warnungen oder Fehler zu überprüfen. Wenn alles in Ordnung ist, können Sie die Datenbank migrieren.

Datenbankmigration

Migrieren Sie die Datenbank manuell mit dem folgenden Befehl:

Terminal.


$ heroku run rake db:migrate

Greifen Sie auf die App zu

Stellen Sie sicher, dass Sie einen Prüfstand haben, auf dem der Webprozesstyp ausgeführt wird.

Terminal.


$ heroku ps:scale web=1

Überprüfen Sie den Status des Prüfstands.

Terminal.


$ heroku ps
Free dyno hours quota remaining this month: 967h 44m (96%)
Free dyno usage for this app: 0h 0m (0%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping

=== web (Free): bin/rails server -p $PORT -e $RAILS_ENV (1)
web.1: starting 2019/01/03 11:16:50 -0600 (~ 6s ago)

Wenn es so ausgegeben wird, läuft ein Prüfstand und Sie können mit Ihrem Browser auf die App zugreifen.

Terminal.


$ heroku open

Sie sollten die ** Indexaktion ** sehen, die Sie zuletzt erstellt haben.

heroku bietet eine Standard-Web-URL zur Vereinfachung während der Entwicklung. Wenn Sie bereit sind, Heroku zu skalieren und in der Produktion zu verwenden, können Sie über die unten stehende URL Ihre eigene benutzerdefinierte Domain hinzufügen.

https://devcenter.heroku.com/articles/custom-domains

Schließlich

Damit ist der Heroku-Bereitstellungsvorgang abgeschlossen. Wenn Sie mehr erfahren möchten, greifen Sie bitte über die unten stehende URL auf die offizielle Referenz zu!

https://devcenter.heroku.com/articles/getting-started-with-rails5#create-a-new-rails-app-or-upgrade-an-existing-one

Recommended Posts

[Heroku-Bereitstellungsverfahren ③] Von der Ruby-Versionsspezifikation zur Bereitstellung und zum Zugriff auf die Anwendung (abgeschlossen)
[Ruby] Von den Grundlagen bis zur Injektionsmethode
[Rails] Ich habe versucht, die Version von Rails von 5.0 auf 5.2 zu erhöhen
Bibliothek nicht geladen, wenn versucht wird, die Ruby-Version und die Schienen zu aktualisieren
3. Erstellen Sie eine Datenbank für den Zugriff über das Webmodul
Rails Heroku-Bereitstellungsverfahren
Von Java zu Ruby !!
[JDBC] Ich habe versucht, von Java aus auf die SQLite3-Datenbank zuzugreifen.
Ich möchte Tomcat auf den Server bringen und die Anwendung starten
Android App, die Bilder aus der Galerie auswählt und anzeigt
Stellen Sie die von Spring Boot erstellte Anwendung für Heroku (öffentlich) bereit ②
Stellen Sie die von Spring Boot erstellte Anwendung für Heroku (öffentlich) bereit ①
[Docker] Zugriff auf den Host aus dem Container heraus. http: //host.docker.internal: