up
Up
Up makes it easier to start, build, and run Docker for local development.
- Much shorter commands. For example,
up node test
instead ofdocker-compose up run --rm web node test
- Automatic image rebuilds. When files your image depends on are changed (
package.json
,Dockerfile
, etc.), Up will rebuild the images before running commands. No more pulling from git and wondering why your project isn't working (oops, forgot to rundocker-compose build
). - Simple setup & installation.
Note that Up will not automatically rebuild containers that are running. You must stop them first. Then when you run any Up command it will rebuild the image.
Installation
On macOS:
brew tap paulcsmith/up
brew install docker-up
On Linux:
- Install Crystal
- Clone and build Up:
git clone https://github.com/paulcsmith/up.git
cd up
git checkout v0.1.7
shards install
crystal build src/run.cr -o up
cp up /usr/local/bin
echo "\nAll done! Run 'up install' in a project using Docker to get started."
Once it is installed, you can remove the leftovers: cd .. && rm -rf up
Basic usage
Before doing anything else, set up your project with Docker and Docker compose.
Once you've got your Dockerfile
and docker-compose.yml
set up:
- Run
up install
to create anup.yml
settings file in your project directory. - Check the
up.yml
settings. You'll probably want to add files that Up can track to rebuild images automatically if they change.
Now you're ready to get running with Up! Take a look at the commands below (or use up help
).
Commands
up
- starts your containers (e.g.docker-compose up
). This will also build the container if not already built, and will rebuild automatically if tracked files change.up -d
- same as above but starts containers in the background.up <any non-Up command>
- if there is no matching Up command, Up will run the command in the main app container (which is configured inup.yml
). For example,up bin/rake
would rundocker-compose run --rm app bin/rake
.up run <args>
- run<args>
using Docker compose. Similar todocker-compose run --rm <args>
.up stop
- stop any running containers. Similar todocker-compose down
.up ssh <optional container name>
- Run bash on the main container or<optional container name>
.up install
- create anup.yml
file. Theup.yml
file is where you can configure which files should trigger automatic rebuilds, what the main app container is, etc.up compose <command>
- runs the docker compose command. Takes into account thedocker_compose_command
defined inup.yml
, which is handy if your default compose configuration is a little more custom. Exampleup compose logs
Configuring Up
Up can be configured using the up.yml
file in your project. A default up.yml
is generated for you when you run up install
.
main_container
up <any command>
will default to running in this container. Defaults to app
For example, up node test
will run node index.js
in the app
container.
docker_compose_command
You can customize the docker compose command here. Defaults to docker-compose
.
Here's an example of how would tell up to use a different docker-compose file:
docker_compose_command: docker-compose -f docker-compose.dev.yml
Note: for most projects the default is fine.
rebuild_when_changed
Up automatically rebuilds images when you run a command and any of these files have changed.
More details below.
Automatic rebuilding
Up uses the files and paths in rebuild_when_changed
in your up.yml
to determine when it should rebuild the containers.
By default Up tracks the common docker files and directories, but you will likely want to watch other files your images depend on.
Below are some hints to get started.
Crystal & Lucky
rebuild_when_changed:
# Add these in your up.yml
- shard.*
- db/*
- webpack.mix.js
- package.json
Node
rebuild_when_changed:
# Add these in your up.yml
- yarn.lock
- package.json
- npm-shrinkwrap.json
Rails
rebuild_when_changed:
# Add these entries to up.yml
- db/*
- Gemfile
- Gemfile.lock
Contributing
- Fork it (https://github.com/paulcsmith/up/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Paul Smith - creator and maintainer
up
- 18
- 0
- 15
- 1
- 2
- over 5 years ago
- March 16, 2019
MIT License
Sun, 17 Nov 2024 07:25:19 GMT