diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..b126df693 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,12 @@ +# Make sure RUBY_VERSION matches the Ruby version in .ruby-version +ARG RUBY_VERSION=3.3.0 +FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION + +# Install packages needed to build gems +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y \ + libpq-dev libvips \ + # For video thumbnails + ffmpeg \ + # For pdf thumbnails. If you want to use mupdf instead of poppler, + poppler-utils diff --git a/.devcontainer/compose.yaml b/.devcontainer/compose.yaml new file mode 100644 index 000000000..fd268f00b --- /dev/null +++ b/.devcontainer/compose.yaml @@ -0,0 +1,52 @@ +services: + rails-app: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + + volumes: + - ../..:/workspaces:cached + + command: sleep infinity + + networks: + - default + + user: vscode + + ports: + - 45678:45678 + + depends_on: + - selenium + - redis + - postgres + + selenium: + image: seleniarm/standalone-chromium + restart: unless-stopped + networks: + - default + + redis: + image: redis:7.2 + restart: unless-stopped + networks: + - default + volumes: + - redis-data:/data + + postgres: + image: postgres:16.1 + restart: unless-stopped + networks: + - default + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + +volumes: + redis-data: + postgres-data: diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..9ad83d01b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "gibct-data-service", + "dockerComposeFile": "compose.yaml", + "service": "rails-app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + + "features": { + "ghcr.io/devcontainers/features/docker-outside-of-docker": {}, + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/devcontainers/features/sshd:1": { } + }, + + "containerEnv": { + "CAPYBARA_SERVER_PORT": "45678", + "SELENIUM_HOST": "selenium", + "REDIS_URL": "redis://redis:6379/1", + "DATABASE_URL": "postgres://postgres:postgres@postgres:5432/gibct-data-service_development?pool=4" + }, + + "forwardPorts": [3000], + + "onCreateCommand": "bin/setup", + "postCreateCommand": "bin/setup" +} diff --git a/bin/setup b/bin/setup index 507a253db..f9c0d11f2 100755 --- a/bin/setup +++ b/bin/setup @@ -10,7 +10,7 @@ def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end -chdir APP_ROOT do +Dir.chdir APP_ROOT do # This script is a way to set up or update your development environment automatically. # This script is idempotent, so that you can run it at any time and get an expectable outcome. @@ -18,10 +18,8 @@ chdir APP_ROOT do system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') - # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' - # end + puts "\n== Copying sample files ==" + FileUtils.cp 'config/application.yml.example', 'config/application.yml' unless File.exist?('config/application.yml') puts "\n== Preparing database ==" system! 'bin/rails db:setup' diff --git a/config/application.yml.example b/config/application.yml.example index 4901cd732..da61ec616 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -1,7 +1,11 @@ -ADMIN_EMAIL: 'something...' -ADMIN_PW: 'something...' +ADMIN_EMAIL: 'admin@example.com' +ADMIN_PW: 'password' +DEPLOYMENT_ENV: 'vagov-dev' SECRET_KEY_BASE: 'something ...' LINK_HOST: 'http://localhost:3000' # https://api.va.gov +GOVDELIVERY_URL: 'stage-tms.govdelivery.com' +GOVDELIVERY_TOKEN: 'abc123' +GOVDELIVERY_STAGING_SERVICE: 'false' GIBCT_URL: 'http://localhost:3002/gi-bill-comparison-tool' SANDBOX_URL: 'http://localhost:3001/gi-bill-comparison-tool-sandbox' diff --git a/config/settings.yml b/config/settings.yml index 71a88269a..bf67f98db 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -58,7 +58,4 @@ search: - "&" - "-" -virtual_hosts: ["127.0.0.1", "localhost", "10.0.2.2", "192.168.2.2", "host.docker.internal"] # Safe host names - - - +virtual_hosts: ["127.0.0.1", "localhost", "10.0.2.2", "192.168.2.2", "host.docker.internal", !ruby/regexp /.*\.app\.github\.dev/] # Safe host names diff --git a/db/seeds/01_users.rb b/db/seeds/01_users.rb index 9a5814453..7d5cb1c94 100644 --- a/db/seeds/01_users.rb +++ b/db/seeds/01_users.rb @@ -2,10 +2,11 @@ puts 'Destroy previous users ... ' User.destroy_all - user = User.create(email: ENV['ADMIN_EMAIL'], password: ENV['ADMIN_PW']) + user = User.create(email: ENV.fetch('ADMIN_EMAIL'), password: ENV.fetch('ADMIN_PW')) unless user.persisted? puts "Error creating #{user.email}: " + raise else puts 'created user.' end -end \ No newline at end of file +end