Skip to content

Commit

Permalink
resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjcumming committed Apr 11, 2024
2 parents 365af49 + 26ce195 commit 9fb4d62
Show file tree
Hide file tree
Showing 722 changed files with 55,429 additions and 10,951 deletions.
83 changes: 83 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"name": "native",
"image": "mcr.microsoft.com/devcontainers/base:bookworm",

"customizations": {
"codespaces": {
"openFiles": [
"docs/setup/codespaces.md",
"README.md"
]
}
},
"features": {
"ghcr.io/devcontainers-contrib/features/ruby-asdf:0": {
"version": "3.2.3"
},
"ghcr.io/robbert229/devcontainer-features/postgresql-client:1": {
"version": "15"
},
"ghcr.io/devcontainers-contrib/features/redis-homebrew:1": {
"version": "6.2"
},
"ghcr.io/devcontainers/features/sshd:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "latest"
}
},

"forwardPorts": [
3000,
9293,
5432,
6379
],
"portsAttributes": {
"3000": {
"label": "vets-api",
"onAutoForward": "notify",
"requireLocalPort": true
},
"9293": {
"label": "vets-api-healthcheck",
"onAutoForward": "silent",
"requireLocalPort": true
},
"5432": {
"label": "postgis",
"onAutoForward": "silent",
"requireLocalPort": true
},
"6379": {
"label": "redis",
"onAutoForward": "silent",
"requireLocalPort": true
}
},

"onCreateCommand": "sh .devcontainer/on-create.sh",
"postCreateCommand": "sh .devcontainer/post-create.sh",
"postStartCommand": "sh .devcontainer/post-start.sh",
"postAttachCommand": {
"server": "bin/rails server",
"sidekiq": "bundle exec sidekiq"
},

"customizations": {
"codespaces": {
"repositories": {
"department-of-veterans-affairs/vets-api-mockdata": {
"permissions": {
"contents": "read",
"pull_requests": "write"
}
}
}
},
"vscode": {
"extensions": ["Shopify.ruby-lsp"]
}
}
}
80 changes: 80 additions & 0 deletions .devcontainer/on-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/sh

# this runs as part of pre-build

echo "on-create start"
echo "$(date +'%Y-%m-%d %H:%M:%S') on-create start" >> "$HOME/status"

# Homebrew/asdf paths to zsh
{
echo "export PATH=\"/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:\$PATH\""
echo "source \"\$HOME/.asdf/asdf.sh\""
} >> ~/.zshrc

export PATH="${HOME}/.asdf/shims:${HOME}/.asdf/bin:${PATH}"
asdf install ruby $( cat .ruby-version )
asdf global ruby $( cat .ruby-version )

# Clone needed repos
git clone https://github.com/department-of-veterans-affairs/vets-api-mockdata.git /workspaces/vets-api-mockdata

# Install dependencies
sudo apt-get update
sudo apt-get install -y libpq-dev pdftk shared-mime-info postgresql-15-postgis-3 tmux xclip

# only run apt upgrade on pre-build
if [ "$CODESPACE_NAME" = "null" ]
then
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get autoremove -y
sudo apt-get clean -y
fi

gem install bundler
NUM_CORES=$( cat /proc/cpuinfo | grep '^processor'|wc -l )
bundle config --global jobs `expr $NUM_CORES - 1`

# Update test DB config
echo 'test_database_url: postgis://postgres:password@localhost:5432/vets_api_test?pool=4' > config/settings/test.local.yml

# Add service config
if [ ! -f config/settings.local.yml ]; then
cp config/settings.local.yml.example config/settings.local.yml
cat <<EOT >> config/settings.local.yml
database_url: postgis://postgres:password@localhost:5432/vets_api_development?pool=4
test_database_url: postgis://postgres:password@localhost:5432/vets_api_test?pool=4
redis:
host: localhost
port: 6379
app_data:
url: redis://localhost:6379
sidekiq:
url: redis://localhost:6379
betamocks:
cache_dir: ../vets-api-mockdata
# Allow access from localhost and shared github URLs.
virtual_hosts: ["127.0.0.1", "localhost", !ruby/regexp /.*\.app\.github\.dev/]
EOT
fi

# Start redis
mkdir -p log
nohup bash -c '/home/linuxbrew/.linuxbrew/opt/[email protected]/bin/redis-server /home/linuxbrew/.linuxbrew/etc/redis.conf' >> log/redis.log 2>&1 &

# Start postgres
sudo /etc/init.d/postgresql restart
pg_isready -t 60
sudo -u root sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'password';"

# Install gems and setup DB
./bin/setup

# Prewarm Bootsnap
bundle exec bootsnap precompile --gemfile app/ lib/

echo "on-create complete"
echo "$(date +'%Y-%m-%d %H:%M:%S') on-create complete" >> "$HOME/status"
22 changes: 22 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# this runs at Codespace creation - not part of pre-build

echo "post-create start"
echo "$(date) post-create start" >> "$HOME/status"

# update the repos
git -C /workspaces/vets-api-mockdata pull
git -C /workspaces/vets-api pull

mkdir /workspaces/vets-api/.vscode
{
{
"rubyLsp.rubyVersionManager": "none"
}
} >> /workspaces/vets-api/.vscode/settings.json

bundle install

echo "post-create complete"
echo "$(date +'%Y-%m-%d %H:%M:%S') post-create complete" >> "$HOME/status"
9 changes: 9 additions & 0 deletions .devcontainer/post-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

echo "Starting redis..."
nohup /home/linuxbrew/.linuxbrew/opt/[email protected]/bin/redis-server /home/linuxbrew/.linuxbrew/etc/redis.conf >> log/redis.log 2>&1 &

echo "Starting postgres..."
sudo /etc/init.d/postgresql restart
echo "Waiting for postgres to be ready..."
pg_isready -t 60
9 changes: 9 additions & 0 deletions .devcontainer/welcome.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
~~~~~~ Welcome to vets-api on codespaces! ~~~~~~

For more information, see the codespaces README in docs/setup.

~~~~~~ Quickstart ~~~~~

To start vets-api, run this command:

foreman start -m all=1,clamd=0,freshclam=0
Loading

0 comments on commit 9fb4d62

Please sign in to comment.