diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..96b3f42 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,52 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby/.devcontainer/base.Dockerfile + +# [Choice] Ruby version: 3, 3.3, 3.2, 3.1, 3.0, 2, 2.7, 2.6 +ARG VARIANT="2" +FROM mcr.microsoft.com/devcontainers/ruby:${VARIANT} + +# Default value to allow debug server to serve content over GitHub Codespace's port forwarding service +# The value is a comma-separated list of allowed domains +ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev,.preview.app.github.dev,.app.github.dev" + +# [Optional] Uncomment this section to install additional OS packages. +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends \ + postgresql-client \ + postgresql-contrib \ + libpq-dev + +# Install MongoDB Shell +ARG MONGOSH_VERSION="2.1.4" +RUN ARCH=$(dpkg --print-architecture) \ + && if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "arm64" ]; then \ + wget -qO /tmp/mongosh.deb "https://downloads.mongodb.com/compass/mongodb-mongosh_${MONGOSH_VERSION}_${ARCH}.deb" \ + && apt-get install -y /tmp/mongosh.deb \ + && rm -rf /tmp/*; \ + fi + +# Install supported Ruby versions +# https://www.ruby-lang.org/en/downloads/releases/ +RUN /bin/bash -c "source /usr/local/rvm/scripts/rvm \ + && rvm install 2.7.8 \ + && rvm install 3.0.6 \ + && rvm install 3.1.4 \ + && rvm install 3.2.3 \ + && rvm install 3.3.0" + +# Set the default bundle path +ENV BUNDLE_PATH=/usr/local/bundle + +# Install gem dependencies +RUN mkdir -p /tmp/gem/lib/devise/auth0 +COPY gemfiles /tmp/gem/gemfiles +COPY lib/devise/auth0/version.rb /tmp/gem/lib/devise/auth0 +COPY Appraisals devise_auth0.gemspec Gemfile Gemfile.lock /tmp/gem/ +RUN mkdir -p ${BUNDLE_PATH} \ + && gem install bundler:2.4.21 \ + && cd /tmp/gem \ + && bundle install --jobs=3 --retry=3 \ + && bundle exec appraisal install \ + && rm -rf /tmp/gem +VOLUME ["/usr/local/bundle"] + +RUN chown -R vscode:vscode /usr/local/rvm ${BUNDLE_PATH} diff --git a/.devcontainer/boot.sh b/.devcontainer/boot.sh new file mode 100755 index 0000000..a3c2e99 --- /dev/null +++ b/.devcontainer/boot.sh @@ -0,0 +1,9 @@ +sudo chown -R vscode:vscode ${BUNDLE_PATH} && \ + bundle install --jobs=3 --retry=3 && \ + bundle exec appraisal install + +# Rebuild PostgreSQL +dropdb --if-exists devise_auth0_test +dropdb --if-exists devise_auth0_development +createdb -E UTF8 -T template0 devise_auth0_test --lc-collate en_US.UTF-8 +createdb -E UTF8 -T template0 devise_auth0_development --lc-collate en_US.UTF-8 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cbb2c44..bdb0b24 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,29 +1,28 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/typescript-node +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/ruby-rails-postgres { "name": "Devise Auth0", - "image": "mcr.microsoft.com/devcontainers/ruby:3-bullseye", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "features": { - "ghcr.io/devcontainers/features/java:latest": {}, "ghcr.io/devcontainers/features/github-cli:latest": {}, - "ghcr.io/devcontainers/features/git-lfs:latest": {}, - "ghcr.io/devcontainers/features/ruby:latest": { - "version": "3.2" - }, - "ghcr.io/itsmechlark/features/trivy": {} + "ghcr.io/devcontainers/features/java:latest": {}, + "ghcr.io/itsmechlark/features/trivy:latest": {} + }, + + "containerEnv": { + "PGHOST": "postgres", + "PGUSER": "postgres", + "PGPASSWORD": "postgres", + "DATABASE_URL": "postgres://postgres:postgres@postgres:5432/devise_auth0_test", + "MONGODB_URI": "mongodb://mongodb:mongodb@mongodb:27017" }, - "mounts": [ - "type=volume,target=${containerWorkspaceFolder}/coverage", - "type=volume,target=${containerWorkspaceFolder}/vendor/bundle" - ], - "runArgs": [ - "--env-file", - ".env" - ], + + "postCreateCommand": ".devcontainer/boot.sh", // Configure tool-specific properties. "customizations": { - // Configure properties specific to VS Code. "vscode": { // Add the IDs of extensions you want installed when the container is created. "extensions": [ @@ -37,19 +36,13 @@ "rebornix.Ruby", "shopify.ruby-lsp", "visualstudioexptteam.vscodeintellicode", - "ms-vsliveshare.vsliveshare" + "ms-vsliveshare.vsliveshare", + "ms-azuretools.vscode-docker" ] } }, - "remoteEnv": { - "BUNDLE_PATH": "${containerWorkspaceFolder}/vendor/bundle" - }, - - "onCreateCommand": "sudo chown -R vscode:vscode ${containerWorkspaceFolder}/coverage ${containerWorkspaceFolder}/vendor/bundle", - "postStartCommand": "gem install bundler:2.3.6 && bundle install --jobs=3 --retry=3", - // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. "remoteUser": "vscode", "updateRemoteUserUID": true -} \ No newline at end of file +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..810dfe0 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,53 @@ +version: '3' + +services: + app: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + + volumes: + - ../..:/workspaces:cached + - bundle-data:/usr/local/bundle + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. + networks: + - default + + depends_on: + - mongodb + - postgres + + mongodb: + image: mongodb/mongodb-community-server + restart: unless-stopped + networks: + - default + volumes: + - mongodb-data:/data/db + environment: + MONGODB_INITDB_ROOT_USERNAME: mongodb + MONGODB_INITDB_ROOT_PASSWORD: mongodb + + postgres: + image: postgres:latest + restart: unless-stopped + networks: + - default + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + +networks: + default: + +volumes: + bundle-data: + mongodb-data: + postgres-data: diff --git a/Gemfile b/Gemfile index c3e8d7b..de151a2 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,6 @@ source "https://rubygems.org" gem "rails", github: "rails/rails", branch: "6-1-stable" -gem "ruby-lsp", require: false platforms :ruby do gem "sqlite3" end diff --git a/Gemfile.lock b/Gemfile.lock index a6dd768..03651fe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -146,21 +146,19 @@ GEM dotenv (2.8.1) drb (2.2.0) ruby2_keywords - dry-configurable (1.1.0) + dry-configurable (1.0.1) dry-core (~> 1.0, < 2) zeitwerk (~> 2.6) - dry-core (1.0.1) + dry-core (1.0.0) concurrent-ruby (~> 1.0) zeitwerk (~> 2.6) erubi (1.12.0) faker (3.2.2) i18n (>= 1.8.11, < 2) - faraday (2.9.0) - faraday-net_http (>= 2.0, < 3.2) + faraday (2.0.0) + ruby2_keywords (>= 0.0.4) faraday-http-cache (2.5.1) faraday (>= 0.8) - faraday-net_http (3.1.0) - net-http faraday-retry (2.2.0) faraday (~> 2.0) globalid (1.2.1) @@ -195,8 +193,6 @@ GEM multi_xml (0.6.0) multipart-parser (0.1.1) mutex_m (0.2.0) - net-http (0.4.1) - uri net-imap (0.4.9.1) date net-protocol @@ -208,16 +204,16 @@ GEM net-protocol netrc (0.11.0) nio4r (2.7.0) - nokogiri (1.16.2) + nokogiri (1.15.5) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.16.2-aarch64-linux) + nokogiri (1.15.5-aarch64-linux) racc (~> 1.4) - nokogiri (1.16.2-arm64-darwin) + nokogiri (1.15.5-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.2-x86_64-darwin) + nokogiri (1.15.5-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.2-x86_64-linux) + nokogiri (1.15.5-x86_64-linux) racc (~> 1.4) oauth2 (2.0.9) faraday (>= 0.17.3, < 3.0) @@ -244,7 +240,6 @@ GEM parser (3.2.2.3) ast (~> 2.4.1) racc - prism (0.19.0) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -332,10 +327,6 @@ GEM rubocop-factory_bot (~> 2.22) rubocop-shopify (2.14.0) rubocop (~> 1.51) - ruby-lsp (0.13.4) - language_server-protocol (~> 3.17.0) - prism (>= 0.19.0, < 0.20) - sorbet-runtime (>= 0.5.10782) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) simplecov (0.22.0) @@ -348,7 +339,6 @@ GEM snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) - sorbet-runtime (0.5.11219) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -356,19 +346,14 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.7.1) + sqlite3 (1.7.2) mini_portile2 (~> 2.8.0) - sqlite3 (1.7.1-aarch64-linux) - sqlite3 (1.7.1-arm64-darwin) - sqlite3 (1.7.1-x86_64-darwin) - sqlite3 (1.7.1-x86_64-linux) thor (1.3.0) timecop (0.9.8) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) - uri (0.13.0) vcr (6.2.0) version_gem (1.1.3) warden (1.2.9) @@ -410,7 +395,6 @@ DEPENDENCIES rubocop-rake rubocop-rspec rubocop-shopify (~> 2.14) - ruby-lsp simplecov (>= 0.21.2) simplecov-lcov sqlite3 @@ -419,4 +403,4 @@ DEPENDENCIES webmock (~> 3.4) BUNDLED WITH - 2.3.6 + 2.4.21 diff --git a/gemfiles/rails_5.2_stable.gemfile b/gemfiles/rails_5.2_stable.gemfile index e238996..305dfe5 100644 --- a/gemfiles/rails_5.2_stable.gemfile +++ b/gemfiles/rails_5.2_stable.gemfile @@ -3,7 +3,6 @@ source "https://rubygems.org" gem "rails", github: "rails/rails", branch: "5-2-stable" -gem "ruby-lsp", require: false platforms :ruby do gem "sqlite3", "~> 1.3.6" diff --git a/gemfiles/rails_6.0_stable.gemfile b/gemfiles/rails_6.0_stable.gemfile index 3b359df..f165f81 100644 --- a/gemfiles/rails_6.0_stable.gemfile +++ b/gemfiles/rails_6.0_stable.gemfile @@ -3,7 +3,6 @@ source "https://rubygems.org" gem "rails", github: "rails/rails", branch: "6-0-stable" -gem "ruby-lsp", require: false platforms :ruby do gem "sqlite3", "~> 1.4" diff --git a/gemfiles/rails_6.1_stable.gemfile b/gemfiles/rails_6.1_stable.gemfile index 68a2d75..d0e4379 100644 --- a/gemfiles/rails_6.1_stable.gemfile +++ b/gemfiles/rails_6.1_stable.gemfile @@ -3,7 +3,6 @@ source "https://rubygems.org" gem "rails", github: "rails/rails", branch: "6-1-stable" -gem "ruby-lsp", require: false gem "rspec-rails", "~> 6.0" platforms :ruby do diff --git a/gemfiles/rails_7.0_stable.gemfile b/gemfiles/rails_7.0_stable.gemfile index cc54e64..3438c65 100644 --- a/gemfiles/rails_7.0_stable.gemfile +++ b/gemfiles/rails_7.0_stable.gemfile @@ -3,7 +3,6 @@ source "https://rubygems.org" gem "rails", github: "rails/rails", branch: "7-0-stable" -gem "ruby-lsp", require: false gem "responders", "~> 3.0" gem "rspec-rails", "~> 6.0" diff --git a/gemfiles/rails_7.1_stable.gemfile b/gemfiles/rails_7.1_stable.gemfile index ac3dd24..d984101 100644 --- a/gemfiles/rails_7.1_stable.gemfile +++ b/gemfiles/rails_7.1_stable.gemfile @@ -3,7 +3,6 @@ source "https://rubygems.org" gem "rails", github: "rails/rails", branch: "7-1-stable" -gem "ruby-lsp", require: false gem "responders", "~> 3.0" gem "rspec-rails", "~> 6.0" diff --git a/gemfiles/rails_edge.gemfile b/gemfiles/rails_edge.gemfile index ba258c7..69696bc 100644 --- a/gemfiles/rails_edge.gemfile +++ b/gemfiles/rails_edge.gemfile @@ -3,7 +3,6 @@ source "https://rubygems.org" gem "rails", github: "rails/rails", branch: :main -gem "ruby-lsp", require: false gem "responders", "~> 3.0" gem "rspec-rails", "~> 6.0"