Skip to content

Instantly share code, notes, and snippets.

@AivanF
Last active November 5, 2024 08:32
Show Gist options
  • Save AivanF/1178ee4a75d0d008886f87670137abcf to your computer and use it in GitHub Desktop.
Save AivanF/1178ee4a75d0d008886f87670137abcf to your computer and use it in GitHub Desktop.
Docker Compose build system for Sublime Text

In case you use Sublime Text and periodically edit, run local Docker Compose configs, this might be useful to you!

All you need to do is to save the following JSON Build System definition into your ST:

  • Click "Tools -> Build System -> New Build System" and save the file below.
  • Alternatively, follow "Preferences -> Browse Packages", navigate to the "User" folder, then copy and save the file there.

After that you'll be able to select new Docker-Compose build system to handle currently open Docker Compose configuration file. It's made in such a way that contains several sub-commands:

  • Up interactively: prints container's logs into the ST console, and pressing Ctrl+C stops containers.
  • Up Detached: containers get started in daemon mode.
  • Down: drop containers from the open file.

You can switch between the commands with Shift+Cmd+B shortcut.


PS: this is my first open source thing related to ST, I'm not sure if it's needed to anyone, maybe there are better plugins available, or maybe I should publish my snippet as a plugin somwehre... Well, feedback and suggestions are welcome!

{
"shell_cmd": "echo 'Please click \"Tools -> Build With\" or Shift+Cmd+B and choose a specific command'",
"variants": [
{
"name": "Up interactive",
"shell_cmd": "CMD=\"docker-compose -f $file up\"; echo \"\\$CMD\n\"; bash -c \"\\$CMD\""
},
{
"name": "Up Detached",
"shell_cmd": "CMD=\"docker-compose -f $file up -d\"; echo \"\\$CMD\n\"; bash -c \"\\$CMD\""
},
{
"name": "Down",
"shell_cmd": "CMD=\"docker-compose -f $file down\"; echo \"\\$CMD\n\"; bash -c \"\\$CMD\""
},
{
"name": "About",
"shell_cmd": "echo 'ST Build System, made by AivanF.\nVersion: 2024.11.04\nLicense: MIT.\nHave nice time with cool projects!'"
}
],
"file_patterns": ["*.yaml"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment