Skip to content

Commit

Permalink
add a devcontainer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
pcai committed Oct 19, 2023
1 parent dc3385a commit 0bbc1f8
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.1, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.1-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.1-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
ARG VARIANT
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
ARG BUNDLER_VERSION
ARG NODE_VERSION
ARG RAILS_VERSION

# Install Rails
RUN gem install rails:${RAILS_VERSION} webdrivers

# Default value to allow debug server to serve content over GitHub Codespace's port forwarding service
# The value is a comma-separated list of allowed domains
ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev,.preview.app.github.dev,.app.github.dev"

RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"

# set correct folder permissions for gems folder
RUN chown -R vscode /usr/local/rvm/gems/default

# install flyctl
RUN su vscode -c "curl -L https://fly.io/install.sh | sh"
ENV FLYCTL_INSTALL "/home/vscode/.fly"
ENV PATH "$FLYCTL_INSTALL/bin:$PATH"

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
RUN echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends postgresql-client-15

# [Optional] Uncomment this line to install additional gems.
# RUN gem install <gems>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.224.3/containers/ruby-rails-postgres
// Update the VARIANT arg in docker-compose.yml to pick a Ruby version
{
"name": "Ruby on Rails",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
"customizations": {
"vscode": {
"settings": {},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"bung87.rails",
"Shopify.ruby-lsp"
]
}
},
// Set *default* container specific settings.json values on container create.
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// This can be used to network with other containers or the host.
"forwardPorts": [3000],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
18 changes: 18 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3"

services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
args:
VARIANT: "3.2-bullseye"
NODE_VERSION: "18"
BUNDLER_VERSION: "2.4.6"
RAILS_VERSION: "7.0.5"

volumes:
- ..:/workspace

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

0 comments on commit 0bbc1f8

Please sign in to comment.