Skip to content

Commit

Permalink
Codespaces (#1088)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericboehs authored Apr 24, 2024
1 parent c83c1b5 commit eed1056
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 13 deletions.
12 changes: 12 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
52 changes: 52 additions & 0 deletions .devcontainer/compose.yaml
Original file line number Diff line number Diff line change
@@ -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:
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
8 changes: 3 additions & 5 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ 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.

puts '== Installing dependencies =='
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'
Expand Down
8 changes: 6 additions & 2 deletions config/application.yml.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
ADMIN_EMAIL: 'something...'
ADMIN_PW: 'something...'
ADMIN_EMAIL: '[email protected]'
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'

Expand Down
5 changes: 1 addition & 4 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions db/seeds/01_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
end

0 comments on commit eed1056

Please sign in to comment.