Last active
May 18, 2022 21:39
-
-
Save jhandel/5ad3fe224ce8d698fb403fab2c310193 to your computer and use it in GitHub Desktop.
.devcontainer for jumpstartrails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE USER vscode CREATEDB; | |
CREATE DATABASE vscode WITH OWNER vscode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
// 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.233.0/containers/ruby-rails-postgres | |
// Update the VARIANT arg in docker-compose.yml to pick a Ruby version | |
{ | |
"name": "Ruby on Rails & Postgres", | |
"dockerComposeFile": "docker-compose.yml", | |
"service": "app", | |
"workspaceFolder": "/workspace", | |
// Set *default* container specific settings.json values on container create. | |
"settings": { | |
"sqltools.connections": [{ | |
"name": "Container database", | |
"driver": "PostgreSQL", | |
"previewLimit": 50, | |
"server": "db", | |
"port": 5432, | |
"database": "jumpstart_development", | |
"username": "postgres", | |
"password": "postgres" | |
}] | |
}, | |
// Add the IDs of extensions you want installed when the container is created. | |
"extensions": [ | |
"rebornix.Ruby", | |
"vortizhe.simple-ruby-erb", | |
"mtxr.sqltools", | |
"mtxr.sqltools-driver-pg" | |
], | |
// 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": "yarn install && bundle install && rake db:setup", | |
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | |
"remoteUser": "vscode", | |
"features": { | |
"github-cli": "latest" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
app: | |
build: | |
context: .. | |
dockerfile: .devcontainer/Dockerfile | |
args: | |
# Update 'VARIANT' to pick a version of Ruby: 3, 3.1, 3.0, 2, 2.7, 2.6 | |
# Append -bullseye or -buster to pin to an OS version. | |
# Use -bullseye variants on local arm64/Apple Silicon. | |
VARIANT: "3.1-bullseye" | |
# Optional Node.js version to install | |
NODE_VERSION: "lts/*" | |
volumes: | |
- ..:/workspace:cached | |
# Overrides default command so things don't shut down after the process ends. | |
command: sleep infinity | |
depends_on: | |
- db | |
- redis | |
environment: | |
- DATABASE_URL=postgres://db:5432/jumpstart_development | |
- REDIS_URL=redis://redis:6379 | |
# Uncomment the next line to use a non-root user for all processes. | |
# user: vscode | |
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally. | |
# (Adding the "ports" property to this file will not forward from a Codespace.) | |
db: | |
image: postgres:latest | |
restart: unless-stopped | |
volumes: | |
- postgres-data:/var/lib/postgresql/data | |
- ./create-db-user.sql:/docker-entrypoint-initdb.d/create-db-user.sql | |
environment: | |
POSTGRES_USER: postgres | |
POSTGRES_DB: jumpstart_development | |
POSTGRES_PASSWORD: postgres | |
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally. | |
# (Adding the "ports" property to this file will not forward from a Codespace.) | |
redis: | |
image: redis:alpine | |
ports: | |
- "6379:6379" | |
volumes: | |
postgres-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [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=3.1-bullseye | |
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT} | |
# Install Rails | |
RUN gem install rails 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" | |
# [Choice] Node.js version: lts/*, 16, 14, 12, 10 | |
ARG NODE_VERSION="lts/*" | |
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1" | |
# [Optional] Uncomment this section to install additional OS packages. | |
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | |
&& apt-get -y install --no-install-recommends postgresql-client imagemagick libvips libvips-dev libvips-tools libpq-dev | |
RUN wget https://github.com/stripe/stripe-cli/releases/download/v1.8.11/stripe_1.8.11_linux_amd64.deb | |
RUN sudo apt install ./stripe_1.8.11_linux_amd64.deb | |
# [Optional] Uncomment this line to install additional gems. | |
RUN gem install foreman | |
RUN gem install sidekiq | |
RUN yarn install | |
# RUN sudo service redis-server start | |
# [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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment