Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jbigler committed Feb 9, 2024
0 parents commit ec10b29
Show file tree
Hide file tree
Showing 135 changed files with 3,086 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dev/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
APP_USER_UID=1000
APP_GROUP_GID=1000
RAILS_ENV=development
BUNDLE_WITHOUT=

66 changes: 66 additions & 0 deletions .dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
ARG RUBY_VER=3.2.3

# Base image
# Alpine 3.19 introduces some breaking changes in gems.
FROM ruby:${RUBY_VER}-alpine3.18 as base

ENV APP_PATH=/app
ARG APP_USER=appuser
ENV APP_USER=${APP_USER}
ARG APP_GROUP=appgroup
ENV APP_GROUP=${APP_GROUP}
ARG APP_USER_UID=1000
ENV APP_USER_UID=${APP_USER_UID}
ARG APP_GROUP_GID=1000
ENV APP_GROUP_GID=${APP_GROUP_GID}

# gcompat is currently needed for Tailwindcss to work in Alpine.
ENV BUILD_PACKAGES="curl-dev ruby-dev build-base zsh xdg-user-dirs" \
DEV_PACKAGES="ctags gzip py3-pip unzip zlib-dev libxml2-dev libxslt-dev tzdata yaml-dev sqlite-dev" \
VIM_PACKAGES="xclip stylua tree-sitter nodejs npm python3 go alpine-sdk neovim fd fd-zsh-completion fzf git lazygit ripgrep bottom lua xclip" \
RUBY_PACgKAGES="ruby-json" \
RAILS_PACKAGES="build-base gcompat vips tzdata git"

# Configure Bundler
ENV BUNDLE_JOBS=4 \
BUNDLE_RETRY=3

RUN --mount=type=cache,target=/var/cache/apk \
apk update && \
apk upgrade && \
apk add --update \
$BUILD_PACKAGES \
$DEV_PACKAGES \
$VIM_PACKAGES \
$RUBY_PACKAGES \
$RAILS_PACKAGES

RUN --mount=type=cache,target=$BUNDLE_APP_CONFIG \
gem update --system && \
gem install -N bundler && \
mkdir -p $APP_PATH

COPY extra/Gemfile* $APP_PATH/

RUN addgroup -g $APP_GROUP_GID $APP_GROUP \
&& adduser -G $APP_GROUP -u $APP_USER_UID $APP_USER -s /bin/zsh --disabled-password \
&& chgrp -R $APP_GROUP $BUNDLE_APP_CONFIG \
&& chmod -R g+w $BUNDLE_APP_CONFIG \
&& chown -R $APP_USER:$APP_GROUP $APP_PATH

USER $APP_USER
WORKDIR $APP_PATH
RUN bundle install

# Rails image
FROM base as rails

ENV RAILS_LOG_TO_STDOUT="1"
ENV BINDING="0.0.0.0"

USER $APP_USER

EXPOSE 3000
EXPOSE 7777

CMD ["bin/dev"]
66 changes: 66 additions & 0 deletions .dev/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
version: '3.7'

name: "i-can-has-kanban"

services:
app:
build:
target: rails
args:
- APP_USER_UID=$UID
- APP_GROUP_GID=$GID
- RUBY_VER=3.2.3
tty: true
env_file: .env
networks:
- dev
ports:
- "0.0.0.0:3000:3000"
volumes:
- ..:/app
- gems:/usr/local/bundle
- home:/home/appuser
command: ["bin/dev"]

selenium:
image: selenium/standalone-chrome:120.0
environment:
- SE_VNC_NO_PASSWORD=1
shm_size: 2gb
networks:
- dev
ports:
- "0.0.0.0:7900:7900"
ulimits: # https://github.com/SeleniumHQ/docker-selenium/issues/2045#issuecomment-1845782778
nofile:
soft: 65536
hard: 65536

nvim:
build:
target: rails
args:
- APP_USER_UID=$UID
- APP_GROUP_GID=$GID
volumes:
- ..:/app
- ./nvim_dotfiles:/home/appuser
- ./extra/agent:/home/appuser/.tabby-client/agent
- gems:/usr/local/bundle
- home:/home/appuser
tty: true
# env_file: .env
networks:
- dev
extra_hosts:
- host.docker.internal:host-gateway
ports:
- "0.0.0.0:7777:7777"
command: ["/usr/bin/nvim", "--headless", "--listen", "0.0.0.0:7777"]

volumes:
gems:
home:

networks:
dev:
7 changes: 7 additions & 0 deletions .dev/extra/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.2.3"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.3"
37 changes: 37 additions & 0 deletions .dev/extra/agent/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Tabby agent configuration file

## Online documentation: https://tabby.tabbyml.com/docs/extensions/configuration
## You can uncomment and edit the values below to change the default settings.
## Configurations in this file have lower priority than the IDE settings.

## Server
## You can set the server endpoint here and an optional authentication token if required.
[server]
endpoint = "http://host.docker.internal:8080" # http or https URL
# token = "your-token-here" # if token is set, request header Authorization = "Bearer $token" will be added automatically
token = "auth_a8618322e4c74fe193acb877692dc8cc"

## You can add custom request headers.
# [server.requestHeaders]
# Header1 = "Value1" # list your custom headers here
# Header2 = "Value2" # values can be strings, numbers or booleans

# Completion
## (Since 1.1.0) You can set the completion request timeout here.
## Note that there is also a timeout config at the server side.
[completion]
timeout = 10000 # 4s

## Logs
## You can set the log level here. The log file is located at ~/.tabby-client/agent/logs/.
[logs]
level = "debug" # "silent" or "error" or "debug"

## Anonymous usage tracking
## Tabby collects anonymous usage data and sends it to the Tabby team to help improve our products.
## Your code, generated completions, or any sensitive information is never tracked or sent.
## For more details on data collection, see https://tabby.tabbyml.com/docs/extensions/configuration#usage-collection
## Your contribution is greatly appreciated. However, if you prefer not to participate, you can disable anonymous usage tracking here.
# [anonymousUsageTracking]
# disable = false # set to true to disable

1 change: 1 addition & 0 deletions .dev/extra/agent/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"anonymousId":"0873d624-ac7f-4400-9c5e-fde1e18eb408"}
7 changes: 7 additions & 0 deletions .dev/extra/disconnect.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vim.keymap.set('n', '<leader>q', function()
for _, ui in pairs(vim.api.nvim_list_uis()) do
if ui.chan and not ui.stdout_tty then
vim.fn.chanclose(ui.chan)
end
end
end, { noremap = true })
15 changes: 15 additions & 0 deletions .dev/extra/entrypoint-nvim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/zsh
set -xeuo pipefail

mkdir -p ~/.config
mkdir -p ~/.local

# if [[ ! -f ~/.config/nvim/init.lua ]]; then
# git clone --depth 1 https://github.com/AstroNvim/AstroNvim ~/.config/nvim
# git clone https://github.com/jbigler/AstroNvim-user.git ~/.config/nvim/lua/user
# else
# git -C ~/.config/nvim/lua/user pull
# fi

# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
3 changes: 3 additions & 0 deletions .dev/extra/tabby_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[[repositories]]
name = "rails"
git_url = "file:///git/rails"
37 changes: 37 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.

# Ignore git directory.
/.git/

# Ignore bundler config.
/.bundle

# Ignore all environment files (except templates).
/.env*
!/.env*.erb

# Ignore all default key files.
/config/master.key
/config/credentials/*.key

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/.keep

# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/.keep

# Ignore assets.
/node_modules/
/app/assets/builds/*
!/app/assets/builds/.keep
/public/assets
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# See https://git-scm.com/docs/gitattributes for more about git attribute files.

# Mark the database schema as having been generated.
db/schema.rb linguist-generated

# Mark any vendored files as having been vendored.
vendor/* linguist-vendored
config/credentials/*.yml.enc diff=rails_credentials
config/credentials.yml.enc diff=rails_credentials
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore all environment files (except templates).
/.env*
!/.env*.erb

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep

# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/
!/tmp/storage/.keep

/public/assets

# Ignore master key for decrypting credentials and more.
/config/master.key

/app/assets/builds/*
!/app/assets/builds/.keep

tags
audit.json

/.dev/extra/agent/logs/

# Ignore default Litestack SQLite databases.
/db/**/*.sqlite3
/db/**/*.sqlite3-*

/coverage
19 changes: 19 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[env]
COMPOSE_FILE = "{{config_root}}/.dev/docker-compose.yml"
GID = 1000

[tasks.nvim]
description = "Connect to Neovim in the container."
run = "nvim --remote-ui --server localhost:7777"
alias = "n"

[tasks.guard]
description = "Start the Guard runner."
run = "docker-compose run --rm -it app bundle exec guard"

[tasks.rails]
description = "Enter the running Rails container."
run = "docker-compose exec app /bin/zsh"

[tools]
ruby = "3.2.3"
13 changes: 13 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require:
- rubocop-rails
- rubocop-minitest
- rubocop-capybara
- rubocop-factory_bot

AllCops:
NewCops: enable

Style/StringLiterals:
EnforcedStyle: double_quotes
Metrics/MethodLength:
Max: 20
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-3.2.3
Loading

0 comments on commit ec10b29

Please sign in to comment.