diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2cc67040..fc6bab01 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,15 +1,3 @@ -FROM mcr.microsoft.com/devcontainers/ruby:1-3.1-bullseye - -# 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 - -# [Optional] Uncomment this line to install additional gems. -# RUN gem install - -# [Optional] Uncomment this line to install global node packages. -# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 +# Make sure RUBY_VERSION matches the Ruby version in .ruby-version +ARG RUBY_VERSION=3.4.5 +FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/compose.yaml similarity index 52% rename from .devcontainer/docker-compose.yml rename to .devcontainer/compose.yaml index 87dae876..d13bc430 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/compose.yaml @@ -1,29 +1,34 @@ -version: '3' +name: "openneo_impress_items" services: - app: + rails-app: build: context: .. dockerfile: .devcontainer/Dockerfile volumes: - - ../..:/workspaces:cached + - ../..:/workspaces:cached # 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. - network_mode: service:db + # Uncomment the next line to use a non-root user for all processes. + # user: vscode # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. # (Adding the "ports" property to this file will not forward from a Codespace.) + depends_on: + - mysql - db: - image: mysql:latest + mysql: + image: mariadb:10.6 restart: unless-stopped - volumes: - - ./create-db.sql:/docker-entrypoint-initdb.d/create-db.sql environment: - MYSQL_ROOT_PASSWORD: impress_dev - MYSQL_USER: impress_dev - MYSQL_PASSWORD: impress_dev + MYSQL_ALLOW_EMPTY_PASSWORD: 'true' + volumes: + - mysql-data:/var/lib/mysql + networks: + - default + +volumes: + mysql-data: diff --git a/.devcontainer/create-db.sql b/.devcontainer/create-db.sql deleted file mode 100644 index b5a805a1..00000000 --- a/.devcontainer/create-db.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE DATABASE openneo_impress; -GRANT ALL PRIVILEGES ON openneo_impress.* TO impress_dev; - -CREATE DATABASE openneo_id; -GRANT ALL PRIVILEGES ON openneo_id.* TO impress_dev; diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5b6accc2..f69d7175 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,46 +1,31 @@ -// 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 +// For format details, see https://containers.dev/implementors/json_reference/. +// For config options, see the README at: https://github.com/devcontainers/templates/tree/main/src/ruby { - "name": "Dress to Impress", - "dockerComposeFile": "docker-compose.yml", - "service": "app", + "name": "openneo_impress_items", + "dockerComposeFile": "compose.yaml", + "service": "rails-app", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - "features": { - "ghcr.io/devcontainers/features/node:1": { - "nodeGypDependencies": true, - "version": "lts" - } - }, // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // This can be used to network with other containers or the host. - "forwardPorts": [3000], - - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": ".devcontainer/post-create.sh", + "features": { + "ghcr.io/devcontainers/features/node:1": {}, + "ghcr.io/rails/devcontainer/features/mysql-client": {} + }, "containerEnv": { - // Because the database is hosted on the local network at the hostname `db`, - // we partially override `config/database.yml` to connect to `db`! - "DATABASE_URL_PRIMARY_DEV": "mysql2://db", - "DATABASE_URL_OPENNEO_ID_DEV": "mysql2://db", - "DATABASE_URL_PRIMARY_TEST": "mysql2://db", - "DATABASE_URL_OPENNEO_ID_TEST": "mysql2://db", + "DB_HOST": "mysql" + }, - // HACK: Out of the box, this dev container doesn't allow installation to - // the default GEM_HOME, because of a weird thing going on with RVM. - // Instead, we set a custom GEM_HOME and GEM_PATH in our home directory! - // https://github.com/devcontainers/templates/issues/188 - "GEM_HOME": "~/.rubygems", - "GEM_PATH": "~/.rubygems" - } + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000], // Configure tool-specific properties. // "customizations": {}, - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" + // Uncomment to connect as root instead. More info: https://containers.dev/implementors/json_reference/#remoteUser. + // "remoteUser": "root", + + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "bin/setup --skip-server" } diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh deleted file mode 100755 index 1aff43ad..00000000 --- a/.devcontainer/post-create.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -set -e # Quit if any part of this script fails. - -# Mark all git repositories as safe to execute, including cached gems. -# NOTE: This would be dangerous to run on a normal multi-user machine, -# but for a dev container that only we use, it should be fine! -git config --global safe.directory '*' - -# Install the app's Ruby gem dependencies. -bundle install - -# Set up the databases: create the schema, and load in some default data. -bin/rails db:schema:load db:seed - -# Install the app's JS dependencies. -yarn install - -# Run a first-time build of the app's JS, in development mode. -yarn build:dev diff --git a/Gemfile.lock b/Gemfile.lock index 551df9ef..ed7dbc7c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,3 @@ -GIT - remote: https://github.com/rubyamf/rocketamf.git - revision: 796f591d002b5cf47df436dbcbd6f2ab00e869ed - specs: - RocketAMF (1.0.0) - GEM remote: https://rubygems.org/ specs: @@ -533,7 +527,6 @@ PLATFORMS ruby DEPENDENCIES - RocketAMF! addressable (~> 2.8) async (~> 2.17) async-http (~> 0.89.0) diff --git a/Procfile.dev b/Procfile.dev index a55427be..5937e270 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,2 +1,2 @@ -web: unset PORT && env RUBY_DEBUG_OPEN=true bin/rails server +web: unset PORT && env RUBY_DEBUG_OPEN=true bin/rails server -b 0.0.0.0 js: yarn dev diff --git a/bin/setup b/bin/setup index be3db3c0..eb0dd996 100755 --- a/bin/setup +++ b/bin/setup @@ -12,7 +12,7 @@ FileUtils.chdir APP_ROOT do # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts "== Installing dependencies ==" + puts "== Installing Ruby dependencies ==" system("bundle check") || system!("bundle install") # puts "\n== Copying sample files ==" @@ -23,6 +23,17 @@ FileUtils.chdir APP_ROOT do puts "\n== Preparing database ==" system! "bin/rails db:prepare" + puts "\n== Importing public modeling data ==" + system! "bin/rails public_data:pull" + + puts "\n== Installing Yarn dependencies ==" + system! "corepack enable" + system! "corepack install" + system! "yarn install" + + puts "\n== Building development JS files ==" + system! "yarn build:dev" + puts "\n== Removing old logs and tempfiles ==" system! "bin/rails log:clear tmp:clear" diff --git a/config/database.yml b/config/database.yml index c2cd0cfb..52792505 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,12 +1,9 @@ development: primary: - # You can override these default settings with this environment variable, - # fully or partially. We do this in the .devcontainer setup! - url: <%= ENV['DATABASE_URL_PRIMARY_DEV'] %> adapter: mysql2 + host: <%= ENV.fetch("DB_HOST", "localhost") %> database: openneo_impress - username: impress_dev - password: impress_dev + username: root pool: 5 encoding: utf8mb4 collation: utf8mb4_unicode_520_ci @@ -14,13 +11,10 @@ development: sql_mode: TRADITIONAL openneo_id: - # You can override these default settings with this environment variable, - # fully or partially. We do this in the .devcontainer setup! - url: <%= ENV['DATABASE_URL_OPENNEO_ID_DEV'] %> adapter: mysql2 + host: <%= ENV.fetch("DB_HOST", "localhost") %> database: openneo_id - username: impress_dev - password: impress_dev + username: root pool: 2 variables: sql_mode: TRADITIONAL @@ -28,13 +22,10 @@ development: test: primary: - # You can override these default settings with this environment variable, - # fully or partially. We do this in the .devcontainer setup! - url: <%= ENV['DATABASE_URL_PRIMARY_TEST'] %> adapter: mysql2 + host: <%= ENV.fetch("DB_HOST", "localhost") %> database: openneo_impress_test - username: impress_dev - password: impress_dev + username: root pool: 5 encoding: utf8mb4 collation: utf8mb4_unicode_520_ci @@ -42,13 +33,10 @@ test: sql_mode: TRADITIONAL openneo_id: - # You can override these default settings with this environment variable, - # fully or partially. We do this in the .devcontainer setup! - url: <%= ENV['DATABASE_URL_OPENNEO_ID_TEST'] %> adapter: mysql2 + host: <%= ENV.fetch("DB_HOST", "localhost") %> database: openneo_id_test - username: impress_dev - password: impress_dev + username: root pool: 2 variables: sql_mode: TRADITIONAL diff --git a/vendor/cache/ffi-1.17.2-aarch64-linux-gnu.gem b/vendor/cache/ffi-1.17.2-aarch64-linux-gnu.gem new file mode 100644 index 00000000..8e391bce Binary files /dev/null and b/vendor/cache/ffi-1.17.2-aarch64-linux-gnu.gem differ diff --git a/vendor/cache/ffi-1.17.2-arm64-darwin.gem b/vendor/cache/ffi-1.17.2-arm64-darwin.gem new file mode 100644 index 00000000..2219753b Binary files /dev/null and b/vendor/cache/ffi-1.17.2-arm64-darwin.gem differ diff --git a/vendor/cache/nokogiri-1.18.9-aarch64-linux-gnu.gem b/vendor/cache/nokogiri-1.18.9-aarch64-linux-gnu.gem new file mode 100644 index 00000000..70a74363 Binary files /dev/null and b/vendor/cache/nokogiri-1.18.9-aarch64-linux-gnu.gem differ diff --git a/vendor/cache/nokogiri-1.18.9-arm64-darwin.gem b/vendor/cache/nokogiri-1.18.9-arm64-darwin.gem new file mode 100644 index 00000000..23284904 Binary files /dev/null and b/vendor/cache/nokogiri-1.18.9-arm64-darwin.gem differ