diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 00000000000..23910283f53 --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,22 @@ +// For format details, see https://containers.dev/implementors/json_reference/. +{ + "name": "otwarchive", + "image": "mcr.microsoft.com/devcontainers/base:debian", + + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "moby": false + }, + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "sh script/docker/init.sh && docker compose up -d web", + + "remoteUser": "root" +} + diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 427940c98cc..00000000000 --- a/.gitpod.yml +++ /dev/null @@ -1,21 +0,0 @@ -tasks: - # See https://github.com/gitpod-io/gitpod/issues/7122 - - name: Configure Git committer email - before: | - git config --global user.email "${GIT_COMMITTER_EMAIL:-$(git config user.email)}" - - init: ./script/docker/init.sh - command: docker compose up -d web - -ports: - - port: 3000 - onOpen: open-browser - - port: 3306 - onOpen: ignore - - port: 6379 - onOpen: ignore - - port: 9200 - onOpen: ignore - - port: 9300 - onOpen: ignore - - port: 9400 - onOpen: ignore diff --git a/config/environments/development.rb b/config/environments/development.rb index 7f9337b8bc4..d257d44cc12 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -87,11 +87,14 @@ Bullet.counter_cache_enable = false end - # GitPod preview support; the preview URL begins with `port#-`, then details about the individual workspace. - # For more information about this, refer to https://www.gitpod.io/docs/configure/workspaces/ports#accessing-port-urls. - # Example: - # GITPOD_WORKSPACE_ID=brianjaustin-otwarchive-w2lj9jd79gm (username-repo-uuid) - # GITPOD_WORKSPACE_CLUSTER_HOST=ws-us114.gitpod.io - # results in 3000-brianjaustin-otwarchive-w2lj9jd79gm.ws-us114.gitpod.io - config.hosts << "3000-#{ENV['GITPOD_WORKSPACE_ID']}.#{ENV['GITPOD_WORKSPACE_CLUSTER_HOST']}" if ENV["GITPOD_WORKSPACE_ID"] + # GitHub codespaces support + if ENV["CODESPACES"] + # Unfortunately, the environment variables we need to set a specific codespace prefix are not available soon enough. + # Instead, we target the GitHub preview domain. Accessing the URL requires logging in with the right GitHub account + # anyways, so this should be OK. + config.hosts << "#{ENV['CODESPACE_NAME']}-3000.#{ENV['GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN']}" + # GitHub also messes with Origin header value(s), which does not play nicely with Rails' CSRF safety :( + # Just disable it for now as a workaround. + config.action_controller.forgery_protection_origin_check = false + end end diff --git a/docker-compose.yml b/docker-compose.yml index d8badc44514..2e7423c69cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -75,8 +75,9 @@ services: RAILS_ENV: development # Disable rack-timeout RACK_TIMEOUT_SERVICE_TIMEOUT: 0 - GITPOD_WORKSPACE_ID: ${GITPOD_WORKSPACE_ID:-} - GITPOD_WORKSPACE_CLUSTER_HOST: ${GITPOD_WORKSPACE_CLUSTER_HOST:-} + CODESPACES: ${CODESPACES:-} + CODESPACE_NAME: ${CODESPACE_NAME:-} + GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN: ${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN:-} ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: bEZjYLY9tCYGh6WlcMtEJpIi7GO2plZC ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: PpLWizzsQHIWnIihtECw8nDHZQd0amzf ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: 3S99KdpdEWLnCYudBgUfdCFDBWePWCud @@ -132,7 +133,7 @@ services: - CUCUMBER_PUBLISH_QUIET=true # Silence ebook-convert warning about running as root - QTWEBENGINE_CHROMIUM_FLAGS=--no-sandbox - command: bundle exec cucumber + command: sleep infinity volumes: - .:/otwa ports: