From 8bf83622e4cf25be975ceba2dfec7a1c9c1f9d2d Mon Sep 17 00:00:00 2001 From: Monique Rio Date: Tue, 5 Mar 2024 17:12:17 -0500 Subject: [PATCH 1/4] changed to latest docker compose and environment variables --- .github/workflows/tests.yml | 11 +++++------ .solargraph.yml | 14 ++++++++++++++ Dockerfile | 23 +++++++++++++++-------- docker-compose.yml => compose.yml | 9 ++++----- db/schema.rb | 6 +++--- .env-dev-values => env.development | 0 .env-example => env.example | 0 fake_alma/Dockerfile | 10 ++-------- fake_alma/Gemfile | 2 -- fake_alma/Gemfile.lock | 7 ------- 10 files changed, 43 insertions(+), 39 deletions(-) create mode 100644 .solargraph.yml rename docker-compose.yml => compose.yml (83%) rename .env-dev-values => env.development (100%) rename .env-example => env.example (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fe2980b..8bb4e37 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,15 +22,14 @@ jobs: - uses: actions/checkout@v2 - name: Create .env file run: | - sed 's/DATABASE_HOST=database/DATABASE_HOST=127.0.0.1/' .env-dev-values > .env-actions - cat .env-example .env-actions > .env - + sed 's/DATABASE_HOST=database/DATABASE_HOST=127.0.0.1/' env.development > env.actions + cat env.example env.actions > .env - name: Load .env file - uses: xom9ikk/dotenv@v1.0.2 - - name: Set up Ruby 3.1.1 + uses: xom9ikk/dotenv@v2 + - name: Set up Ruby 3.1 uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1.1 + ruby-version: 3.1 bundler-cache: true - name: Setup up node 16.14.2 uses: actions/setup-node@v2 diff --git a/.solargraph.yml b/.solargraph.yml new file mode 100644 index 0000000..44c7a2e --- /dev/null +++ b/.solargraph.yml @@ -0,0 +1,14 @@ +--- +include: +- "**/*.rb" +exclude: +- spec/**/* +- vendor/**/* +- ".bundle/**/*" +require: [] +domains: [] +reporters: [] +formatter: +require_paths: [] +plugins: [] +max_files: 5000 diff --git a/Dockerfile b/Dockerfile index a565581..1189bf1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,23 @@ -ARG RUBY_VERSION=3.1 -FROM ruby:${RUBY_VERSION} +FROM ruby:3.1 AS development -ARG BUNDLER_VERSION=2.3 ARG UNAME=app ARG UID=1000 ARG GID=1000 - -LABEL maintainer="mrio@umich.edu" +ARG NODE_MAJOR=16 RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ apt-transport-https -RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - +RUN mkdir -p /etc/apt/keyrings +RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list +RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends nodejs RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ nodejs \ vim-tiny -RUN gem install bundler:${BUNDLER_VERSION} - +RUN gem install bundler RUN groupadd -g ${GID} -o ${UNAME} RUN useradd -m -d /app -u ${UID} -g ${GID} -o -s /bin/bash ${UNAME} @@ -33,3 +32,11 @@ WORKDIR /app COPY --chown=${UID}:${GID} . /app CMD ["bin/rails", "s", "-b", "0.0.0.0"] + +FROM development AS production + +ENV BUNDLE_WITHOUT development:test + +COPY --chown=${UID}:${GID} . /app + +RUN bundle install diff --git a/docker-compose.yml b/compose.yml similarity index 83% rename from docker-compose.yml rename to compose.yml index 005b383..2522868 100644 --- a/docker-compose.yml +++ b/compose.yml @@ -1,8 +1,8 @@ -version: '3' - services: web: - build: . + build: + context: . + target: development ports: - "3000:3000" - "9394:9394" @@ -11,7 +11,7 @@ services: - gem_cache:/gems env_file: - .env - - .env-dev-values + - env.development database: build: lib/dev_db/. @@ -28,7 +28,6 @@ services: ports: - 9091:9091 - volumes: gem_cache: db_data: diff --git a/db/schema.rb b/db/schema.rb index 0008dc3..bf30428 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,14 +11,14 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema[7.0].define(version: 2021_05_06_133110) do - create_table "auth_tokens", charset: "utf8mb4", force: :cascade do |t| + create_table "auth_tokens", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| t.string "token" t.string "name" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - create_table "loans", id: :string, charset: "utf8mb4", force: :cascade do |t| + create_table "loans", id: :string, charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| t.string "user_uniqname", null: false t.string "title" t.string "author" @@ -33,7 +33,7 @@ t.index ["user_uniqname"], name: "index_loans_on_user_uniqname" end - create_table "users", primary_key: "uniqname", id: :string, charset: "utf8mb4", force: :cascade do |t| + create_table "users", primary_key: "uniqname", id: :string, charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| t.boolean "retain_history", default: false t.boolean "confirmed", default: false t.datetime "created_at", null: false diff --git a/.env-dev-values b/env.development similarity index 100% rename from .env-dev-values rename to env.development diff --git a/.env-example b/env.example similarity index 100% rename from .env-example rename to env.example diff --git a/fake_alma/Dockerfile b/fake_alma/Dockerfile index ec86079..99db863 100644 --- a/fake_alma/Dockerfile +++ b/fake_alma/Dockerfile @@ -1,17 +1,11 @@ -FROM ruby:2.7.2 +FROM ruby:3.2 LABEL maintainer="mrio@umich.edu" RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ - apt-transport-https - -RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - - -RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ - nodejs \ vim -RUN gem install bundler:2.1.4 +RUN gem install bundler RUN mkdir -p /gems diff --git a/fake_alma/Gemfile b/fake_alma/Gemfile index 0619ef5..b861b9f 100644 --- a/fake_alma/Gemfile +++ b/fake_alma/Gemfile @@ -1,7 +1,5 @@ source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby "2.7.2" - gem "sinatra" gem "sinatra-contrib" diff --git a/fake_alma/Gemfile.lock b/fake_alma/Gemfile.lock index 5a8f7d6..cb4762b 100644 --- a/fake_alma/Gemfile.lock +++ b/fake_alma/Gemfile.lock @@ -1,12 +1,9 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.7.0) - public_suffix (>= 2.0.2, < 5.0) multi_json (1.15.0) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) - public_suffix (4.0.6) rack (2.2.3) rack-protection (2.1.0) rack @@ -28,12 +25,8 @@ PLATFORMS ruby DEPENDENCIES - addressable sinatra sinatra-contrib -RUBY VERSION - ruby 2.7.2p137 - BUNDLED WITH 2.1.4 From 7e45e05836910fae067479ee3f9269920be002c2 Mon Sep 17 00:00:00 2001 From: Monique Rio Date: Tue, 5 Mar 2024 17:13:40 -0500 Subject: [PATCH 2/4] updated Gemfile --- Gemfile.lock | 348 ++++++++++++++++++++++++++------------------------- 1 file changed, 180 insertions(+), 168 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ce4aa9e..d6f6576 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,276 +11,288 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.0.3) - actionpack (= 7.0.3) - activesupport (= 7.0.3) + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.3) - actionpack (= 7.0.3) - activejob (= 7.0.3) - activerecord (= 7.0.3) - activestorage (= 7.0.3) - activesupport (= 7.0.3) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.3) - actionpack (= 7.0.3) - actionview (= 7.0.3) - activejob (= 7.0.3) - activesupport (= 7.0.3) + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.3) - actionview (= 7.0.3) - activesupport (= 7.0.3) - rack (~> 2.0, >= 2.2.0) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.3) - actionpack (= 7.0.3) - activerecord (= 7.0.3) - activestorage (= 7.0.3) - activesupport (= 7.0.3) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.3) - activesupport (= 7.0.3) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.3) - activesupport (= 7.0.3) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.3.6) - activemodel (7.0.3) - activesupport (= 7.0.3) - activerecord (7.0.3) - activemodel (= 7.0.3) - activesupport (= 7.0.3) - activestorage (7.0.3) - actionpack (= 7.0.3) - activejob (= 7.0.3) - activerecord (= 7.0.3) - activesupport (= 7.0.3) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.3) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - amazing_print (1.4.0) - anyway_config (2.3.0) - ruby-next-core (>= 0.14.0) + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) + amazing_print (1.5.0) + anyway_config (2.6.3) + ruby-next-core (~> 1.0) ast (2.4.2) - bootsnap (1.12.0) + bigdecimal (3.1.6) + bootsnap (1.18.3) msgpack (~> 1.2) builder (3.2.4) byebug (11.1.3) - concurrent-ruby (1.1.10) - crack (0.4.5) + concurrent-ruby (1.2.3) + crack (1.0.0) + bigdecimal rexml crass (1.0.6) - database_cleaner (2.0.1) - database_cleaner-active_record (~> 2.0.0) - database_cleaner-active_record (2.0.1) + database_cleaner (2.0.2) + database_cleaner-active_record (>= 2, < 3) + database_cleaner-active_record (2.1.0) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - diff-lcs (1.5.0) - digest (3.1.0) + date (3.3.4) + diff-lcs (1.5.1) docile (1.4.0) dry-initializer (3.1.1) - erubi (1.10.0) - factory_bot (6.2.1) + erubi (1.12.0) + factory_bot (6.4.6) activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) + factory_bot_rails (6.4.3) + factory_bot (~> 6.4) railties (>= 5.0.0) - faker (2.21.0) + faker (3.2.3) i18n (>= 1.8.11, < 2) - ffi (1.15.5) - globalid (1.0.0) - activesupport (>= 5.0) - hashdiff (1.0.1) - httparty (0.20.0) - mime-types (~> 3.0) + ffi (1.16.3) + globalid (1.2.1) + activesupport (>= 6.1) + hashdiff (1.1.0) + httparty (0.21.0) + mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) - i18n (1.10.0) + i18n (1.14.1) concurrent-ruby (~> 1.0) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) - json (2.6.2) - listen (3.7.1) + json (2.7.1) + language_server-protocol (3.17.0.3) + lint_roller (1.1.0) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.18.0) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (1.0.2) + net-imap + net-pop + net-smtp + marcel (1.0.4) method_source (1.0.0) - mime-types (3.4.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) - mini_mime (1.1.2) - minitest (5.15.0) - msgpack (1.5.2) + mini_mime (1.1.5) + minitest (5.22.2) + msgpack (1.7.2) multi_xml (0.6.0) - mysql2 (0.5.4) - net-imap (0.2.3) - digest + mysql2 (0.5.6) + net-imap (0.4.10) + date net-protocol - strscan - net-pop (0.1.1) - digest + net-pop (0.1.2) net-protocol + net-protocol (0.2.2) timeout - net-protocol (0.1.3) - timeout - net-smtp (0.3.1) - digest + net-smtp (0.4.0.1) net-protocol - timeout - nio4r (2.5.8) - nokogiri (1.13.6-x86_64-linux) + nio4r (2.7.0) + nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) - parallel (1.22.1) - parser (3.1.2.0) + parallel (1.24.0) + parser (3.3.0.5) ast (~> 2.4.1) - prometheus-client (2.1.0) - public_suffix (4.0.7) - puma (5.6.4) + racc + prometheus-client (4.2.2) + public_suffix (5.0.4) + puma (5.6.8) nio4r (~> 2.0) - racc (1.6.0) - rack (2.2.3.1) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (7.0.3) - actioncable (= 7.0.3) - actionmailbox (= 7.0.3) - actionmailer (= 7.0.3) - actionpack (= 7.0.3) - actiontext (= 7.0.3) - actionview (= 7.0.3) - activejob (= 7.0.3) - activemodel (= 7.0.3) - activerecord (= 7.0.3) - activestorage (= 7.0.3) - activesupport (= 7.0.3) + racc (1.7.3) + rack (2.2.8.1) + rack-test (2.1.0) + rack (>= 1.3) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) bundler (>= 1.15.0) - railties (= 7.0.3) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + railties (= 7.0.8.1) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.4.2) - loofah (~> 2.3) - rails_semantic_logger (4.10.0) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + rails_semantic_logger (4.14.0) rack railties (>= 5.1) - semantic_logger (~> 4.9) - railties (7.0.3) - actionpack (= 7.0.3) - activesupport (= 7.0.3) + semantic_logger (~> 4.13) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.0.6) - rb-fsevent (0.11.1) + rake (13.1.0) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (2.5.0) - rexml (3.2.5) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + regexp_parser (2.9.0) + rexml (3.2.6) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-mocks (3.11.1) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-rails (5.1.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) - rspec-support (3.11.0) - rubocop (1.29.1) + rspec-support (~> 3.13.0) + rspec-rails (6.1.1) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.12) + rspec-expectations (~> 3.12) + rspec-mocks (~> 3.12) + rspec-support (~> 3.12) + rspec-support (3.13.1) + rubocop (1.61.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.17.0, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.18.0) - parser (>= 3.1.1.0) - rubocop-performance (1.13.3) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - ruby-next-core (0.15.1) - ruby-progressbar (1.11.0) - semantic_logger (4.11.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.1) + parser (>= 3.3.0.4) + rubocop-performance (1.20.2) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) + ruby-next-core (1.0.2) + ruby-progressbar (1.13.0) + semantic_logger (4.15.0) concurrent-ruby (~> 1.0) - simplecov (0.21.2) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - standard (1.12.1) - rubocop (= 1.29.1) - rubocop-performance (= 1.13.3) + standard (1.34.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.60) + standard-custom (~> 1.0.0) + standard-performance (~> 1.3) + standard-custom (1.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50) + standard-performance (1.3.1) + lint_roller (~> 1.1) + rubocop-performance (~> 1.20.2) standardrb (1.0.1) standard - strscan (3.0.3) - thor (1.2.1) - timeout (0.3.0) - tzinfo (2.0.4) + thor (1.3.1) + timeout (0.4.1) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.1.0) - webmock (3.14.0) + unicode-display_width (2.5.0) + webmock (3.23.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket-driver (0.7.5) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - yabeda (0.11.0) + yabeda (0.12.0) anyway_config (>= 1.0, < 3) concurrent-ruby dry-initializer - yabeda-prometheus (0.8.0) - prometheus-client (>= 0.10, < 3.0) + yabeda-prometheus (0.9.1) + prometheus-client (>= 3.0, < 5.0) rack yabeda (~> 0.10) - yabeda-puma-plugin (0.6.0) + yabeda-puma-plugin (0.7.1) json puma yabeda (~> 0.5) - yabeda-rails (0.8.1) + yabeda-rails (0.9.0) activesupport anyway_config (>= 1.3, < 3) railties yabeda (~> 0.8) - zeitwerk (2.5.4) + zeitwerk (2.6.13) PLATFORMS x86_64-linux @@ -309,4 +321,4 @@ DEPENDENCIES yabeda-rails BUNDLED WITH - 2.3.7 + 2.5.6 From 15ec9135159505cdf2ca2500153a644b9a907833 Mon Sep 17 00:00:00 2001 From: Monique Rio Date: Tue, 5 Mar 2024 17:20:08 -0500 Subject: [PATCH 3/4] updates to ruby 3.2 and node 20 --- .github/workflows/tests.yml | 12 ++++++------ Dockerfile | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8bb4e37..f306ce8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,22 +19,22 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Create .env file run: | sed 's/DATABASE_HOST=database/DATABASE_HOST=127.0.0.1/' env.development > env.actions cat env.example env.actions > .env - name: Load .env file uses: xom9ikk/dotenv@v2 - - name: Set up Ruby 3.1 + - name: Set up Ruby 3.2 uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1 + ruby-version: 3.2 bundler-cache: true - - name: Setup up node 16.14.2 - uses: actions/setup-node@v2 + - name: Setup up node 20 + uses: actions/setup-node@v4 with: - node-version: '16.14.2' + node-version: 20 - name: Verify MariaDB connection run: | while ! mysqladmin ping -h"127.0.0.1" -P"3306" --silent; do diff --git a/Dockerfile b/Dockerfile index 1189bf1..51c068a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM ruby:3.1 AS development +FROM ruby:3.2 AS development ARG UNAME=app ARG UID=1000 ARG GID=1000 -ARG NODE_MAJOR=16 +ARG NODE_MAJOR=20 RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ apt-transport-https From 1411185e6bceb88bb0f0d3d6759d7747e500e52a Mon Sep 17 00:00:00 2001 From: Monique Rio Date: Thu, 7 Mar 2024 13:19:36 -0500 Subject: [PATCH 4/4] updates workflows --- .../workflows/build-deploy-on-release.yaml | 25 +++++++ .github/workflows/build-from-main.yml | 69 ----------------- .github/workflows/build-main.yml | 27 +++++++ .github/workflows/deploy-production.yaml | 52 ------------- .github/workflows/manual-build-dev-db.yml | 67 +++-------------- .../workflows/manual-deploy-production.yaml | 27 +++++++ .github/workflows/manual-deploy-staging.yaml | 74 ------------------- .github/workflows/manual-deploy-testing.yaml | 73 ------------------ .github/workflows/manual-deploy-workshop.yaml | 27 +++++++ .github/workflows/tag-release.yaml | 27 ------- 10 files changed, 115 insertions(+), 353 deletions(-) create mode 100644 .github/workflows/build-deploy-on-release.yaml delete mode 100644 .github/workflows/build-from-main.yml create mode 100644 .github/workflows/build-main.yml delete mode 100644 .github/workflows/deploy-production.yaml create mode 100644 .github/workflows/manual-deploy-production.yaml delete mode 100644 .github/workflows/manual-deploy-staging.yaml delete mode 100644 .github/workflows/manual-deploy-testing.yaml create mode 100644 .github/workflows/manual-deploy-workshop.yaml delete mode 100644 .github/workflows/tag-release.yaml diff --git a/.github/workflows/build-deploy-on-release.yaml b/.github/workflows/build-deploy-on-release.yaml new file mode 100644 index 0000000..be90d2b --- /dev/null +++ b/.github/workflows/build-deploy-on-release.yaml @@ -0,0 +1,25 @@ + +name: Build and Deploy to Production on Release + +on: + release: + types: [ released ] + +jobs: + build-production: + name: Build production ${{ github.event.release.tag_name }} + uses: mlibrary/platform-engineering-workflows/.github/workflows/build-production.yml@v1 + with: + image_name: ${{ vars.IMAGE_NAME }} + tag: ${{ github.event.release.tag_name }} + dockerfile: Dockerfile + secrets: inherit + + deploy-production: + needs: build-production + name: Deploy to production + uses: mlibrary/platform-engineering-workflows/.github/workflows/deploy.yml@v1 + with: + image: ghcr.io/mlibrary/${{ vars.IMAGE_NAME }}:${{ github.event.release.tag_name }} + file: environments/account/production/checkout-history-web-image.txt + secrets: inherit diff --git a/.github/workflows/build-from-main.yml b/.github/workflows/build-from-main.yml deleted file mode 100644 index 3a4aa18..0000000 --- a/.github/workflows/build-from-main.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: Build latest from main and Auto Deploy to Testing and Staging - -on: - workflow_run: - workflows: [ 'Run Tests' ] - branches: [ 'main' ] - types: [ completed ] - - -jobs: - build: - if: ${{ github.event.workflow_run.conclusion == 'success' }} - runs-on: ubuntu-latest - environment: testing - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Log into Github Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and Push - uses: docker/build-push-action@v2 - with: - context: . - file: Dockerfile.prod - push: true - tags: | - ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:latest - ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.sha }} - - deploy-testing: - needs: build - runs-on: ubuntu-latest - environment: testing - steps: - - name: Deploy to Testing - uses: mlibrary/deploy-to-kubernetes@v1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.sha }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - deployment: circulation-history-web - container: circulation-history - - deploy-staging: - needs: build - runs-on: ubuntu-latest - environment: staging - steps: - - name: Deploy to Staging - uses: mlibrary/deploy-to-kubernetes@v1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.sha }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - deployment: circulation-history-web - container: circulation-history diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml new file mode 100644 index 0000000..5cc5f77 --- /dev/null +++ b/.github/workflows/build-main.yml @@ -0,0 +1,27 @@ +name: Build latest from main and Auto Deploy to workshop + +on: + workflow_run: + workflows: [ 'Run Tests' ] + branches: [ 'main' ] + types: [ completed ] + + +jobs: + build-unstable: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + uses: mlibrary/platform-engineering-workflows/.github/workflows/build-unstable.yml@v1 + with: + image_name: ${{ vars.IMAGE_NAME }} + tag: ${{ github.sha }} + dockerfile: Dockerfile + secrets: inherit + + deploy-unstable: + needs: build-unstable + name: Deploy to workshop + uses: mlibrary/platform-engineering-workflows/.github/workflows/deploy.yml@v1 + with: + image: ${{ needs.build-unstable.outputs.image }} + file: environments/account/workshop/checkout-history-web-image.txt + secrets: inherit diff --git a/.github/workflows/deploy-production.yaml b/.github/workflows/deploy-production.yaml deleted file mode 100644 index 94cddfa..0000000 --- a/.github/workflows/deploy-production.yaml +++ /dev/null @@ -1,52 +0,0 @@ -name: Deploy to Production - -on: - workflow_dispatch: - inputs: - tag: - description: Release - required: true - -jobs: - deploy: - runs-on: ubuntu-latest - environment: production - steps: - - name: Deploy to Production - uses: mlibrary/deploy-to-kubernetes@v1.1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.event.inputs.tag }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - deployment: circulation-history-web - container: circulation-history - - name: Deploy early cronjob - uses: mlibrary/deploy-to-kubernetes@v1.1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.event.inputs.tag }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - type: cronjob - container: circulation-history - cronjob_name: circulation-history-loader-early - - name: Deploy later cronjob - uses: mlibrary/deploy-to-kubernetes@v1.1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.event.inputs.tag }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - type: cronjob - container: circulation-history - cronjob_name: circulation-history-loader-later diff --git a/.github/workflows/manual-build-dev-db.yml b/.github/workflows/manual-build-dev-db.yml index dcfe86f..00827cd 100644 --- a/.github/workflows/manual-build-dev-db.yml +++ b/.github/workflows/manual-build-dev-db.yml @@ -7,64 +7,15 @@ on: description: tag required: true - env: - IMAGE_NAME: circulation_history_dev_db + IMAGE_NAME: checkout-history-dev-db jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Clone latest repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Check that the tag exists in repo - id: tag_check - run: | - if git rev-parse 'refs/tags/${{ github.event.inputs.tag }}' &> /dev/null; then - echo '::set-output name=tag::${{ github.event.inputs.tag }}' - elif git rev-parse '${{ github.event.inputs.tag }}' &> /dev/null; then - echo "::set-output name=tag::`git rev-parse '${{ github.event.inputs.tag }}'`" - else - echo "Couldn't figure out tag from input: ${{ github.event.inputs.tag }}" - echo "Aborting deployment." - false - fi - - name: Log into Github Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Check that the tag exists in container registry - id: image_check - run: | - if docker manifest inspect ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }} > /dev/null; then - echo '::set-output name=image_exists::true' - echo "image exists!" - else - echo "image doesn't exist; Starting to Build and push image" - fi - - name: Checkout Correct repository - if: ${{ steps.image_check.outputs.image_exists != 'true' }} - uses: actions/checkout@v2 - with: - ref: ${{ github.event.inputs.tag }} - - name: Build and Push - if: ${{ steps.image_check.outputs.image_exists != 'true' }} - uses: docker/build-push-action@v2 - with: - context: lib/dev_db/. - push: true - tags: | - ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:latest - ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}} - - name: Relabel as latest - if: ${{ steps.image_check.outputs.image_exists == 'true' }} - run: | - docker pull ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}} - docker tag ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}} ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:latest - docker push ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:latest - - + build-unstable: + uses: mlibrary/platform-engineering-workflows/.github/workflows/build-unstable.yml@v1 + with: + image_name: ${{ env.IMAGE_NAME }} + tag: ${{ github.event.inputs.tag }} + context: "lib/dev_db/." + dockerfile: Dockerfile + secrets: inherit diff --git a/.github/workflows/manual-deploy-production.yaml b/.github/workflows/manual-deploy-production.yaml new file mode 100644 index 0000000..3b7641e --- /dev/null +++ b/.github/workflows/manual-deploy-production.yaml @@ -0,0 +1,27 @@ +name: Manual Deploy to Production + +on: + workflow_dispatch: + inputs: + tag: + description: Release + required: true + +jobs: + build-production: + name: Build production ${{ github.event.inputs.tag }} + uses: mlibrary/platform-engineering-workflows/.github/workflows/build-production.yml@v1 + with: + image_name: ${{ vars.IMAGE_NAME }} + tag: ${{ github.event.inputs.tag }} + dockerfile: Dockerfile + secrets: inherit + + deploy-production: + needs: build-production + name: Deploy to production + uses: mlibrary/platform-engineering-workflows/.github/workflows/deploy.yml@v1 + with: + image: ghcr.io/mlibrary/${{ vars.IMAGE_NAME }}:${{ github.event.inputs.tag }} + file: environments/account/production/checkout-history-web-image.txt + secrets: inherit diff --git a/.github/workflows/manual-deploy-staging.yaml b/.github/workflows/manual-deploy-staging.yaml deleted file mode 100644 index c9435c0..0000000 --- a/.github/workflows/manual-deploy-staging.yaml +++ /dev/null @@ -1,74 +0,0 @@ -name: Manual Deploy to Staging - -on: - workflow_dispatch: - inputs: - tag: - description: tag - required: true - - -env: - environment: staging - -jobs: - deploy: - runs-on: ubuntu-latest - environment: staging - steps: - - name: Clone latest repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Check that the tag exists in repo - id: tag_check - run: | - if git rev-parse 'refs/tags/${{ github.event.inputs.tag }}' &> /dev/null; then - echo '::set-output name=tag::${{ github.event.inputs.tag }}' - elif git rev-parse '${{ github.event.inputs.tag }}' &> /dev/null; then - echo "::set-output name=tag::`git rev-parse '${{ github.event.inputs.tag }}'`" - else - echo "Couldn't figure out tag from input: ${{ github.event.inputs.tag }}" - echo "Aborting deployment." - false - fi - - name: Log into Github Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Check that the tag exists in container registry - id: image_check - run: | - if docker manifest inspect ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }} > /dev/null; then - echo '::set-output name=image_exists::true' - echo "image exists!" - else - echo "image doesn't exist; Starting to Build and push image" - fi - - name: Checkout Correct repository - if: ${{ steps.image_check.outputs.image_exists != 'true' }} - uses: actions/checkout@v2 - with: - ref: ${{ github.event.inputs.tag }} - - name: Build and Push - if: ${{ steps.image_check.outputs.image_exists != 'true' }} - uses: docker/build-push-action@v2 - with: - context: . - file: Dockerfile.prod - push: true - tags: ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}} - - name: Deploy to ${{ env.environment }} - uses: mlibrary/deploy-to-kubernetes@v1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - deployment: circulation-history-web - container: circulation-history diff --git a/.github/workflows/manual-deploy-testing.yaml b/.github/workflows/manual-deploy-testing.yaml deleted file mode 100644 index 64c9895..0000000 --- a/.github/workflows/manual-deploy-testing.yaml +++ /dev/null @@ -1,73 +0,0 @@ -name: Manual Deploy to Testing - -on: - workflow_dispatch: - inputs: - tag: - description: tag - required: true - -env: - environment: testing - -jobs: - deploy: - runs-on: ubuntu-latest - environment: testing - steps: - - name: Clone latest repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Check that the tag exists in repo - id: tag_check - run: | - if git rev-parse 'refs/tags/${{ github.event.inputs.tag }}' &> /dev/null; then - echo '::set-output name=tag::${{ github.event.inputs.tag }}' - elif git rev-parse '${{ github.event.inputs.tag }}' &> /dev/null; then - echo "::set-output name=tag::`git rev-parse '${{ github.event.inputs.tag }}'`" - else - echo "Couldn't figure out tag from input: ${{ github.event.inputs.tag }}" - echo "Aborting deployment." - false - fi - - name: Log into Github Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Check that the tag exists in container registry - id: image_check - run: | - if docker manifest inspect ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }} > /dev/null; then - echo '::set-output name=image_exists::true' - echo "image exists!" - else - echo "image doesn't exist; Starting to Build and push image" - fi - - name: Checkout Correct repository - if: ${{ steps.image_check.outputs.image_exists != 'true' }} - uses: actions/checkout@v2 - with: - ref: ${{ github.event.inputs.tag }} - - name: Build and Push - if: ${{ steps.image_check.outputs.image_exists != 'true' }} - uses: docker/build-push-action@v2 - with: - context: . - file: Dockerfile.prod - push: true - tags: ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}} - - name: Deploy to ${{ env.environment }} - uses: mlibrary/deploy-to-kubernetes@v1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - deployment: circulation-history-web - container: circulation-history diff --git a/.github/workflows/manual-deploy-workshop.yaml b/.github/workflows/manual-deploy-workshop.yaml new file mode 100644 index 0000000..c729f81 --- /dev/null +++ b/.github/workflows/manual-deploy-workshop.yaml @@ -0,0 +1,27 @@ +name: Manual Deploy to Workshop + +on: + workflow_dispatch: + inputs: + tag: + description: tag + required: true + +jobs: + build-unstable: + uses: mlibrary/platform-engineering-workflows/.github/workflows/build-unstable.yml@v1 + with: + image_name: ${{ vars.IMAGE_NAME }} + tag: ${{ github.event.inputs.tag }} + dockerfile: Dockerfile + secrets: inherit + + deploy-workshop: + needs: build-unstable + name: Deploy to workshop + uses: mlibrary/platform-engineering-workflows/.github/workflows/deploy.yml@v1 + with: + environment: aim + image: ${{ needs.build-unstable.outputs.image }} + file: environments/account/workshop/checkout-history-web-image.txt + secrets: inherit diff --git a/.github/workflows/tag-release.yaml b/.github/workflows/tag-release.yaml deleted file mode 100644 index ac0fdd9..0000000 --- a/.github/workflows/tag-release.yaml +++ /dev/null @@ -1,27 +0,0 @@ - -name: Docker Tag Latest Release - -on: - release: - types: [ released ] - -env: - PROD_IMAGE_ID: ghcr.io/mlibrary/circulation_history - UNSTABLE_IMAGE_ID: ghcr.io/mlibrary/circulation_history_unstable -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Log into registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Clone latest repository - uses: actions/checkout@v2 - - name: Tag latest release in Github Container Registry - run: | - docker pull $UNSTABLE_IMAGE_ID:${{ github.sha }} - docker tag $UNSTABLE_IMAGE_ID:${{ github.sha }} $PROD_IMAGE_ID:${{ github.event.release.tag_name }} - docker tag $UNSTABLE_IMAGE_ID:${{ github.sha }} $PROD_IMAGE_ID:latest - docker push $PROD_IMAGE_ID:${{ github.event.release.tag_name }} - docker push $PROD_IMAGE_ID:latest