-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add devcontainer for Codespaces #2948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
88f32f2
f160946
d3c3d38
3b32b08
926d264
7178ba0
02981e6
cd3fafd
0957c32
bb06890
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
| // README at: https://github.com/devcontainers/templates/tree/main/src/universal | ||
| { | ||
| "name": "For Codespaces", | ||
|
|
||
| "image": "mcr.microsoft.com/devcontainers/universal:4", | ||
|
|
||
| "containerEnv": { | ||
| "DATABASE_URL": "postgresql://postgres:@localhost" | ||
| }, | ||
|
|
||
| "onCreateCommand": "bash --login .devcontainer/codespaces/onCreateCommand.sh", | ||
|
|
||
| "postCreateCommand": "bash --login .devcontainer/codespaces/postCreateCommand.sh", | ||
|
|
||
| "postStartCommand": "bash --login .devcontainer/codespaces/postStartCommand.sh" | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Workaround for install Ruby 4.0.0 with RVM | ||
| rvm list | ||
| curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - | ||
| curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import - | ||
| rvm get master | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ruby 4.0 isn’t available in the stable RVM release yet, so I’m installing it from |
||
| rvm list known | ||
|
|
||
| # Install Ruby | ||
| rvm install 3.4.6 | ||
| rvm install 4.0.0 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some older PR branches still use older Ruby versions, so I install several versions to allow switching easily via RVM when needed. |
||
| rvm --default use 4.0.0 | ||
| rvm list | ||
| ruby --version | ||
|
|
||
| # Install Google Chrome | ||
| wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O /tmp/google-chrome.deb | ||
| sudo apt update && sudo apt install -y /tmp/google-chrome.deb && rm /tmp/google-chrome.deb | ||
| google-chrome --version | ||
|
|
||
| # Install Chromedriver | ||
| CHROMEDRIVER_VERSION=$(google-chrome --version | awk '{print $3}') | ||
| wget https://storage.googleapis.com/chrome-for-testing-public/${CHROMEDRIVER_VERSION}/linux64/chromedriver-linux64.zip | ||
| unzip chromedriver-linux64.zip | ||
| sudo mv chromedriver-linux64/chromedriver /usr/local/bin/ | ||
| rm -rf chromedriver-linux64.zip chromedriver-linux64 | ||
| chromedriver --version | ||
|
|
||
| # Install libs | ||
| sudo apt install -y libvips | ||
|
|
||
| # Cleanup | ||
| sudo apt-get clean | ||
| sudo rm -rf /var/lib/apt/lists/* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| rvm --default use $(cat ./.ruby-version) | ||
|
|
||
| until docker info >/dev/null 2>&1; do sleep 1; done | ||
| docker rm postgres >/dev/null 2>&1 | ||
| docker run -d -i --name postgres -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres | ||
| until docker exec postgres pg_isready -U postgres; do sleep 1; done | ||
|
|
||
| # Create config/database.yml | ||
| ./bin/setup | ||
| # Setup & Create .env | ||
| ./bin/setup | ||
|
|
||
| # Create test database and run seeds | ||
| RAILS_ENV=test ./bin/rails dev:prime | ||
|
|
||
| docker stop postgres |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
|
|
||
| docker start postgres |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn’t required for the installation itself, but when it fails, the cause is often unclear, so I’m outputting version information and similar details to the build logs.