Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 2.1

orbs:
ruby: circleci/ruby@2.5.0
node: circleci/node@7.1.0
browser-tools: circleci/browser-tools@1.5.2
ruby: circleci/ruby@2.5.4
node: circleci/node@7.1.1
browser-tools: circleci/browser-tools@2.3.1
jobs:
build:
docker:
Expand All @@ -18,7 +18,7 @@ jobs:
- ruby/install-deps
- node/install:
install-yarn: true
node-version: '20.9.0'
node-version: '22.19.0'
- node/install-packages:
pkg-manager: yarn
check:
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
command: FAIL_ON_ERROR=1 bundle exec rake traceroute
- node/install:
install-yarn: true
node-version: '20.9.0'
node-version: '22.19.0'
- node/install-packages:
pkg-manager: yarn
- run:
Expand All @@ -65,22 +65,20 @@ jobs:
- image: cimg/postgres:14.4
resource_class: large
environment:
BUNDLE_JOBS: "3"
BUNDLE_RETRY: "3"
BUNDLE_JOBS: '3'
BUNDLE_RETRY: '3'
PGHOST: 127.0.0.1
PGUSER: postgres
PGPASSWORD: "postgres"
PGPASSWORD: 'postgres'
RAILS_ENV: test
DATABASE_URL: "postgres://postgres:postgres@localhost/ci_test"
DATABASE_URL: 'postgres://postgres:postgres@localhost/ci_test'
TZ: Asia/Tokyo
PARALLEL_WORKERS: 2
parallelism: 3
steps:
- checkout
- browser-tools/install-chrome:
replace-existing: true
chrome-version: 130.0.6723.116
- browser-tools/install-chromedriver
- browser-tools/install_browser_tools:
chrome-version: 130.0.6723.116
- run:
command: |
google-chrome --version
Expand All @@ -95,7 +93,7 @@ jobs:
clean-bundle: true
- node/install:
install-yarn: true
node-version: '20.9.0'
node-version: '22.19.0'
- node/install-packages:
pkg-manager: yarn
- run:
Expand Down Expand Up @@ -132,5 +130,3 @@ workflows:
- test:
requires:
- build

# VS Code Extension Version: 1.5.1
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG VARIANT=3.1-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/ruby:${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="lts/*"
ARG NODE_VERSION="22.19.0"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# Install OS packages
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ storage/
.envrc
.env.local
/test/reports

/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity
2 changes: 1 addition & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tools]
ruby = "3.1.6"
node = "20.9.0"
node = "22.19.0"
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.9.0
22.19.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.9.0
22.19.0
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ruby 3.1.6
nodejs 20.9.0
nodejs 22.19.0
42 changes: 42 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Repository Guidelines

## Project Structure & Module Organization
- `app/` Rails app code: `models/`, `controllers/`, `views/`, `jobs/`, `helpers/`, and frontend under `javascript/` (Shakapacker).
- `config/` environment, routes, and lints (see `.rubocop.yml`, `config/slim_lint.yml`).
- `db/` migrations and schema; `lib/` app-specific utilities; `public/` static assets.
- `test/` Minitest suite: `system/`, `models/`, `controllers/`, fixtures in `test/fixtures/`.
- `bin/` helper scripts; `Procfile.dev` runs Rails and asset dev server.

## Build, Test, and Development Commands
- Setup: `bin/setup` — install gems, prepare DB, yarn, etc.
- Run (dev): `foreman start -f Procfile.dev` — Rails on `:3000` + Shakapacker.
- Tests (headless): `rails test:all`.
- Tests (browser): `HEADFUL=1 rails test:all`.
- Tests (no parallel): `PARALLEL_WORKERS=1 rails test:all`.
- Lint: `./bin/lint` — RuboCop (auto-correct), Slim-Lint, ESLint/Prettier.
- Profiler: `PROFILE=1 rails server` to enable rack-mini-profiler.

## Coding Style & Naming Conventions
- Ruby: 2-space indent, snake_case methods, CamelCase classes; enforced by RuboCop (`.rubocop.yml`).
- Views: Slim templates, linted by `config/slim_lint.yml`.
- JS/TS: Code in `app/javascript/`; ESLint + Prettier via `yarn lint` scripts; React 17 and Shakapacker/Webpack 5.
- Files follow Rails conventions (e.g., `app/models/user.rb`, test `test/models/user_test.rb`).

## Testing Guidelines
- Frameworks: Minitest + Capybara for system tests.
- Structure: place unit/integration tests under matching `test/*` directories; name files `*_test.rb`.
- Run a single test or line: `rails test test/models/user_test.rb:42`.
- Keep tests deterministic; use fixtures in `test/fixtures/`.

## Commit & Pull Request Guidelines
- Commits: imperative mood and focused scope; reference issues (e.g., "Fix profile validation #123").
- PRs: clear description, linked issues, screenshots for UI changes, migration notes, and rollback plan if relevant.
- Quality gates: all linters pass (`bin/lint`) and CI (CircleCI) green; add/adjust tests when changing behavior.

## Security & Configuration Tips
- Never commit secrets; use `.env.local`. Respect `.ruby-version`, `.tool-versions`, and Node versions in `.node-version`/`.nvmrc`.
- Use `bin/setup` for local DB and dependencies; avoid manual tweaks in `config/` without discussion.

## Agent-Specific Instructions
- Follow these guidelines for any edits. Keep changes minimal, scoped to the task, and update docs/tests when adding commands or changing behavior.

91 changes: 78 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ruby:3.1.6-slim
# Build stage - includes devDependencies for asset compilation
FROM ruby:3.1.6-slim as builder

ENV RAILS_ENV production
WORKDIR /app
Expand All @@ -8,32 +9,40 @@ RUN gem update --system
RUN printf "install: --no-rdoc --no-ri\nupdate: --no-rdoc --no-ri" > ~/.gemrc
RUN gem install --no-document --force bundler -v 2.4.21

# Install packages
RUN apt-get update -qq && apt-get install -y \
# Install build dependencies with minimal footprint
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
build-essential \
git \
nodejs \
postgresql-client \
libpq-dev \
tzdata \
curl \
gnupg2 \
libyaml-dev
libyaml-dev \
ca-certificates \
libvips-dev && \
rm -rf /var/lib/apt/lists/*

# Install Node.js 22.19.0
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get update && \
apt-get install -y --no-install-recommends nodejs=22.19.0-1nodesource1 && \
apt-mark hold nodejs && \
rm -rf /var/lib/apt/lists/*

# Install latest yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y yarn
apt-get update && \
apt-get install -y --no-install-recommends yarn && \
rm -rf /var/lib/apt/lists/*

# Set timezone
RUN ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

# libvips
RUN apt-get install -y libvips-dev

# Install npm packages
# Install ALL npm packages (including devDependencies for asset compilation)
COPY package.json yarn.lock ./
RUN yarn install --prod --ignore-engines
RUN yarn install --ignore-engines

# Install gems
COPY Gemfile Gemfile.lock ./
Expand All @@ -42,11 +51,67 @@ RUN bundle install -j4
# Copy application code
COPY . ./

# Compile assets
# Compile assets (now with devDependencies available)
ENV RAILS_LOG_TO_STDOUT true
RUN SECRET_KEY_BASE=dummy NODE_OPTIONS=--openssl-legacy-provider bundle exec rails assets:precompile
RUN SECRET_KEY_BASE=dummy bundle exec rails assets:precompile

# Production stage - minimal runtime image
FROM ruby:3.1.6-slim as production

ENV RAILS_ENV production
WORKDIR /app

# Update rubygems
RUN gem update --system
RUN printf "install: --no-rdoc --no-ri\nupdate: --no-rdoc --no-ri" > ~/.gemrc
RUN gem install --no-document --force bundler -v 2.4.21

# Install only runtime dependencies
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
postgresql-client \
libpq-dev \
tzdata \
ca-certificates \
libvips && \
rm -rf /var/lib/apt/lists/*

# Set timezone
RUN ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

# Install Node.js 22.19.0 (runtime only)
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get update && \
apt-get install -y --no-install-recommends nodejs=22.19.0-1nodesource1 && \
apt-mark hold nodejs && \
rm -rf /var/lib/apt/lists/*

# Install yarn for runtime
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y --no-install-recommends yarn && \
rm -rf /var/lib/apt/lists/*

# Copy gems configuration
COPY Gemfile Gemfile.lock ./
RUN bundle install -j4

# Install only production npm packages
COPY package.json yarn.lock ./
RUN yarn install --prod --ignore-engines

# Copy application code from builder (excluding large directories)
COPY --from=builder /app/app ./app
COPY --from=builder /app/bin ./bin
COPY --from=builder /app/config ./config
COPY --from=builder /app/db ./db
COPY --from=builder /app/lib ./lib
COPY --from=builder /app/public ./public
COPY --from=builder /app/Rakefile ./Rakefile
COPY --from=builder /app/config.ru ./config.ru

ENV PORT 3000
ENV RAILS_LOG_TO_STDOUT true
EXPOSE 3000

CMD bin/rails server -p $PORT -e $RAILS_ENV
15 changes: 7 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ gem 'bootsnap', '>= 1.4.4', require: false
gem 'ffi', '1.17.1'
gem 'image_processing', '~> 1.12'
gem 'jbuilder', '~> 2.7'
gem 'puma', '~> 5.0'
gem 'rails', '~> 6.1.7.10'
gem 'webpacker', '~> 5.0'
gem 'puma', '~> 6.0'
gem 'rails', '7.2.2.2'
gem 'shakapacker', '~> 7.0'
gem 'sprockets-rails', '>= 2.0.0'

# not default
gem 'abstract_notifier', '~> 0.3.2'
Expand All @@ -32,7 +33,7 @@ gem 'diffy'
gem 'discord-notifier'
gem 'discordrb', '~> 3.5', require: false
gem 'doorkeeper'
gem 'good_job', '~> 3.14', github: 'komagata/good_job'
gem 'good_job', '~> 4.5'
gem 'google-cloud-storage', '~> 1.25', require: false
gem 'holiday_jp'
gem 'icalendar', '~> 2.8'
Expand Down Expand Up @@ -62,9 +63,9 @@ gem 'postmark-rails'
gem 'rack-cors', require: 'rack/cors'
gem 'rack-user_agent'
gem 'rails_autolink'
gem 'rails-i18n', '~> 6.0.0'
gem 'rails-i18n', '~> 7.0.0'
gem 'rails-patterns', '~> 0.2'
gem 'ransack', '3.1.0'
gem 'ransack', '~> 4.3'
gem 'react-rails'
gem 'recaptcha', '~> 5.12'
gem 'rollbar'
Expand Down Expand Up @@ -92,8 +93,6 @@ end

group :development do
gem 'listen', '~> 3.3'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'web-console', '>= 4.1.0'

# not default
Expand Down
Loading