-
-
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
134afec
c71b5eb
4b9291a
3677fd3
ce5acc0
3bf48cf
7c1c13d
f1360cf
1bec0da
3b70cf4
73325d8
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,38 @@ | ||
| # 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 | ||
|
|
||
| # Workaround for Yarn GPG key | ||
| curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo gpg --dearmor -o /usr/share/keyrings/yarnkey.gpg | ||
| echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | ||
| sudo apt update | ||
|
|
||
| # 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 | ||
pablobm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # 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.