1
0
Fork 0
forked from OpenNeo/impress

Merge branch 'devcontainer'

This commit is contained in:
Emi Matchu 2023-10-26 14:42:30 -07:00
commit 556d50c4ed
8 changed files with 125 additions and 5 deletions

15
.devcontainer/Dockerfile Normal file
View file

@ -0,0 +1,15 @@
FROM mcr.microsoft.com/devcontainers/ruby:1-3.1-bullseye
# 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"
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# [Optional] Uncomment this line to install additional gems.
# RUN gem install <your-gem-names-here>
# [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

View file

@ -0,0 +1,5 @@
CREATE DATABASE openneo_impress;
GRANT ALL PRIVILEGES ON openneo_impress.* TO impress_dev;
CREATE DATABASE openneo_id;
GRANT ALL PRIVILEGES ON openneo_id.* TO impress_dev;

View file

@ -0,0 +1,44 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby-rails-postgres
{
"name": "Dress to Impress",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"nodeGypDependencies": true,
"version": "lts"
}
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// 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": ".devcontainer/post-create.sh",
"containerEnv": {
// Because the database is hosted on the local network at the hostname `db`,
// we partially override `config/database.yml` to connect to `db`!
"DATABASE_URL_PRIMARY_DEV": "mysql2://db",
"DATABASE_URL_OPENNEO_ID_DEV": "mysql2://db",
// HACK: Out of the box, this dev container doesn't allow installation to
// the default GEM_HOME, because of a weird thing going on with RVM.
// Instead, we set a custom GEM_HOME and GEM_PATH in our home directory!
// https://github.com/devcontainers/templates/issues/188
"GEM_HOME": "~/.rubygems",
"GEM_PATH": "~/.rubygems"
}
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

View file

@ -0,0 +1,29 @@
version: '3'
services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
volumes:
- ../..:/workspaces:cached
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db
# 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: mysql:latest
restart: unless-stopped
volumes:
- ./create-db.sql:/docker-entrypoint-initdb.d/create-db.sql
environment:
MYSQL_ROOT_PASSWORD: impress_dev
MYSQL_USER: impress_dev
MYSQL_PASSWORD: impress_dev

19
.devcontainer/post-create.sh Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e # Quit if any part of this script fails.
# Mark all git repositories as safe to execute, including cached gems.
# NOTE: This would be dangerous to run on a normal multi-user machine,
# but for a dev container that only we use, it should be fine!
git config --global safe.directory '*'
# Install the app's Ruby gem dependencies.
bundle install
# Set up the databases: create the schema, and load in some default data.
bin/rails db:schema:load db:seed
# Install the app's JS dependencies.
yarn install
# Run a first-time build of the app's JS, in development mode.
yarn build:dev

View file

@ -1,18 +1,24 @@
development: development:
primary: primary:
# You can override these default settings with this environment variable,
# fully or partially. We do this in the .devcontainer setup!
url: <%= ENV['DATABASE_URL_PRIMARY_DEV'] %>
adapter: mysql2 adapter: mysql2
database: openneo_impress database: openneo_impress
username: openneo_impress username: impress_dev
password: openneo_impress password: impress_dev
pool: 5 pool: 5
variables: variables:
sql_mode: TRADITIONAL sql_mode: TRADITIONAL
openneo_id: openneo_id:
# You can override these default settings with this environment variable,
# fully or partially. We do this in the .devcontainer setup!
url: <%= ENV['DATABASE_URL_OPENNEO_ID_DEV'] %>
adapter: mysql2 adapter: mysql2
database: openneo_id database: openneo_id
username: openneo_impress username: impress_dev
password: openneo_impress password: impress_dev
pool: 2 pool: 2
variables: variables:
sql_mode: TRADITIONAL sql_mode: TRADITIONAL

View file

@ -31,6 +31,7 @@
}, },
"scripts": { "scripts": {
"build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=/assets --asset-names=[name]-[hash].digested --loader:.js=jsx --loader:.png=file --loader:.svg=file --loader:.min.js=text", "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=/assets --asset-names=[name]-[hash].digested --loader:.js=jsx --loader:.png=file --loader:.svg=file --loader:.min.js=text",
"dev": "yarn build --watch --public-path=/dev-assets" "build:dev": "yarn build --public-path=/dev-assets",
"dev": "yarn build:dev --watch"
} }
} }

1
vendor/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/bundle