/redmined

A docked CLI for Redmine development environment.

Primary LanguageShellMIT LicenseMIT

Redmined

A docked CLI for Redmine development environment. Inspired by rails/docked.

Build

Features

  • Requires only Docker CLI
  • Supports running most Redmine tests
  • CLI can be executed in subdirectories
  • Supports multiple Redmine development environments

Prerequisites

Installation

Download redmined and place it in a location in your PATH, such as ~/.local/bin/, and grant execution permission.

Or, you can install it directly by running the following command.

wget -qO- https://raw.githubusercontent.com/hidakatsuya/redmined/main/install.sh | sh
curl -sSL https://raw.githubusercontent.com/hidakatsuya/redmined/main/install.sh | sh

Usage

cd your-redmine-root-directory

Create configuration for SQLite database.

cat <<EOS > config/database.yml
development:
  adapter: sqlite3
  database: db/development.sqlite3
test:
  adapter: sqlite3
  database: db/test.sqlite3
EOS

Setup and start Redmine.

redmined bundle install
redmined bin/rails db:prepare
redmined bin/rails s

Run tests.

redmined bin/rails test
redmined bin/rails test:system

Note

Since Chrome is not installed on the ARM64 platform, test:system task can't be executed.

Settings

Global settings

  • REDMINED_CONTAINER_NAME Container name for redmined. If not set, use "redmined-container" as default.
  • REDMINED_MAP_HOST_USER_TO_CONTAINER_USER Map the UID and GID of the host user to the container user
  • REDMINED_BUNDLE_CACHE_VOLUME Volume name for bundler cache. If not set, use "redmine-bundle-cache" as default.
  • REDMINED_IMAGE Docker image for redmined. If not set, use "ghcr.io/hidakatsuya/redmined" as default.
  • REDMINED_REDMINE_PORT Port number for Redmine. If not set, use "3000" as default.
  • REDMINED_CONTAINER_ENVS Additional environment variables for redmined container. Multiple variables can be set by separating them with a space. If not set, use "" as default.
  • REDMINED_PUBLISH_PORT Port mapping for Redmine. If not set, use "3000:3000" as default.

See redmined for further details.

Individual settings

You can create the configuration file named .redmined.json for different Redmine environments in the Redmine root directory.

{
  "default": {
    "name": "redmine",
    "ruby": "3.3",
    "port": "3000",
    "env": {
      "PUMA_MIN_THREADS": 1
    }
  }
}

Then, you can use Redmine in the above environment by executing the command as usual. The details of the configuration are as follows:

  • name: It determines to the following settings
    • REDMINED_BUNDLE_CACHE_VOLUME=redmined-<name>-bundle-cache
    • REDMINED_CONTAINER_NAME=redmined-<name>-container
  • ruby: It determines the container image redmined uses
    • REDMINED_IMAGE=REDMINED_IMAGE:ruby<ruby>
  • port: It determines the --expose settings of docker run and $PORT which rails server respects
    • REDMINED_REDMINE_PORT=<port>
    • REDMINED_PUBLISH_PORT=<port>:<port>
  • env: It determines additional environment variables for the redmined container
    • REDMINED_CONTAINER_ENVS=values of <env>

Additionally, you can add the configuration for the different Redmine environment.

{
  "default": {
    "name": "redmine",
    "ruby": "3.3"
  },
  "ruby3.2": {
    "name": "redmine-ruby3.2",
    "ruby": "3.2",
    "port": "3001"
  }
}

The environment added above can be used as follows:

redmined -n ruby3.2 bin/rails server

Tips

Using separate environments for multiple Redmines

You can configure the indivisual settings for different Redmine environments. See Individual settings for further details.

Developing a Redmine plugin with Redmined CLI

Since Redmined CLI supports running in subdirectories, you can run redmined in plugins/redmine_xxxx/.

This means you can develop a Redmine plugin in the following way.

Suppose your Redmine source code is stored as follow:

/home/you/redmine
  ├── app/
  ├── plugins/
  :

Then, place your Redmine plugin in plugins/redmine_your_plugin and go to that directory.

cd plugins/redmine_your_plugin

You can run commands such as bin/rails s or bin/rails redmine:plugins:test under the plugins directory. You don't need to navigate to the Redmine root directory to run those commands.

pwd
/path/to/redmine/plugins/redmine_your_plugin

redmined bin/rails redmine:plugins:test
redmined bin/rails s

Executing redmined command with modified environment variables

redmined env RAILS_ENV=development bin/about