NOTE: This is experimental way to setup the project
Colima is a wrapper for Lima (Linux Machines) VM on Mac OS. Colima provides transparent access to container runtime inside a Lima VM so it looks like you work with container runtime on your host machine — you can use docker and docker-compose the same way as on Linux. Your home directory mounts directly inside the Lima VM in read/write mode. It provides a good performance with sshfs mounts but colima declare a much better performance with virtiofs
Mac OS version 13.0 or later with installed homebrew
Install docker, docker-compose and colima
brew install --cask docker docker-compose colimaEdit colima default template
$EDITOR ~/.colima/_templates/default.yamlMinimum recommended values:
cpu: 4
disk: 60
memory: 4
arch: host
runtime: docker
vmType: vz
mountType: virtiofsTo run project apps use the next command:
docker-compose upTo see information about running containers run:
docker-compose ps -aColima maps service ports to localhost so the apps will be available on your host machine
There are a few ways to use this setup depends on your workflow. The main idea is run bundle command by docker-compose inside console container which provides test environment in your project
Sample docker-compose config:
console:
build:
context: docker/
dockerfile: Dockerfile.dev
environment:
RACK_ENV: development
volumes:
- .:/app
- ~/.bash_history:/root/.bash_history
- ~/.pry_history:/root/.pry_history
- ~/.gitconfig:/root/.gitconfig
working_dir: /app
command: bashdocker/Dockerfile.dev:
FROM ruby:latest
RUN gem install solargraph &&\
solargraph download-core
Examples:
docker-compose run --rm console bundle exec rubocop
docker-compose run --rm console bundle exec rspec spec/lib
docker-compose run --rm -e PROFILE=1 -e LOG=1 console bundle exec rspec spec/libFor zsh:
alias dc-bundle="docker-compose run \$([ -n \"\$ENV\" ] && echo \" \$ENV\" | sed -r 's/[[:space:]]+/ -e /g') --rm console bundle \$@"
Example commands:
dc-bundle exec rubocop
dc-bundle exec rspec spec/lib
ENV="PROFILE=1 LOG=1" dc-bundle exec rspec spec/libMake it faster with a running console container:
alias dc-console="docker-compose ps -a --status running | cut -d\ -f1 | grep console | head -1"
alias dc-bundle="docker exec -ti \$([ -n \"\$ENV\" ] && echo \" \$ENV\" | sed -r 's/[[:space:]]+/ -e /g') -w /app/$(dc-dir) \$(DC_CONSOLE=\$(dc-console) [ -n \"\$DC_CONSOLE\" ] && echo $DC_CONSOLE || echo console) bundle \$@"Use commads from p.1 or aliases from p.2 to configure your editor
Use LSP server for Ruby development if you still don't. LSP server solargraph must be installed in console container
Example plugin config for lazyvim:
local function root_dir()
vim.fn.finddir(".git/..", vim.fn.expand("%:p")..";")
end
return {
"neovim/nvim-lspconfig",
dependencies = {
{ "folke/neodev.nvim", opts = { setup_jsonls = false } },
},
opts = {
servers = {
solargraph = {
cmd = {
"docker-compose",
"run",
"--rm",
"-v",
root_dir() .. ":" .. root_dir() .. ":z",
"-w",
root_dir(),
"console",
"solargraph",
"stdio"
}
},
},
},
}