Skip to content

Commit

Permalink
Add devcontainer configuration for Codespaces
Browse files Browse the repository at this point in the history
This configuration allows Scenic development to be done via Codespaces
for anyone with access to that feature on GitHub. Creating a Codespace
in this project will drop you into an environment ready to run `rake`
and get a fully passing test suite.

I personally do this using the `gh` cli, connecting via SSH, but one
could also connect via VSCode or the web.

Either way, I'm in a fully working environment within 1-2 minutes, which
I find helpful when I've stepped away from development work for a bit
and can't be bothered to figure out my local environment again.

I believe this same configuration should be usable locally for folks who
want to use Docker (see scenic-views#319), but that is less interesting to me
personally.
  • Loading branch information
derekprior committed Dec 17, 2021
1 parent c625d1b commit f3b8f73
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ARG VARIANT=2-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}

ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev"
ENV POSTGRES_USER="postgres"
ENV POSTGRES_PASSWORD="postgres"
11 changes: 11 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Scenic Development",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
"settings": { },
"extensions": ["rebornix.Ruby"],
"postCreateCommand": "bin/setup",
"remoteUser": "vscode",
"features": { "github-cli": "latest" }
}
24 changes: 24 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3'

services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
args:
VARIANT: "3"
volumes:
- ..:/workspace:cached
command: sleep infinity
network_mode: service:db
db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
volumes:
postgres-data: null
2 changes: 1 addition & 1 deletion spec/dummy/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ development: &default
encoding: unicode
host: localhost
pool: 5
<% if ENV.fetch("GITHUB_ACTIONS", false) %>
<% if ENV.fetch("GITHUB_ACTIONS", false) || ENV.fetch("CODESPACES", false) %>
username: <%= ENV.fetch("POSTGRES_USER") %>
password: <%= ENV.fetch("POSTGRES_PASSWORD") %>
<% end %>
Expand Down

0 comments on commit f3b8f73

Please sign in to comment.