- Notifications
You must be signed in to change notification settings - Fork84
Docker-based development-only dependency manager. macOS, Linux, and WSL2-only and installs via PHP's Composer... for now.
License
tighten/takeout
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Takeout is a CLI tool for spinning up tiny Docker containers, one for each of your development environment dependencies.
It's meant to be paired with a tool likeLaravel Valet. It's currently compatible with macOS, Linux, Windows 10 and WSL2.
Withtakeout enable mysql
you're running MySQL, and never have to worry about managing or fixing Homebrew MySQL again.
But you can also easily enable ElasticSearch, PostgreSQL, MSSQL, Mongo, Redis, and more, with a simple command. For a current list of services, look at the classes available in this directory:https://github.com/tighten/takeout/tree/main/app/Services
- macOS, Linux, Windows 10 or WSL2
- Docker installed (macOS:Docker for Mac, Windows:Docker for Windows)
If you opt for the PHP/Composer installation (not recommended), you also need:
- PHP installed (latest major version)
- Composer installed
The recommended way to install Takeout is the dockerized version via an alias (add this to your~/.bashrc
,~/.zshrc
or equivalent).
On Linux or macOS, use:
alias takeout="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --add-host=host.docker.internal:host-gateway -it tighten/takeout:latest"
On Windows 10|11, if you're using Bash, use:
alias takeout="docker run --rm -v //var/run/docker.sock:/var/run/docker.sock --add-host=host.docker.internal:host-gateway -it tighten/takeout:latest"
On Windows 10|11, if you're using PowerShell, use:
functiontakeout { docker run --rm -v //var/run/docker.sock:/var/run/docker.sock --add-host=host.docker.internal:host-gateway -it tighten/takeout:latest$args }
That's it. You may now use Takeout on your terminal. The first time you use this alias, it will pull the Takeout image from Docker Hub.
To update the image, rundocker pull tighten/takeout
when you want to get the newest release.
Otherwise, if you have a PHP environment available, you may install Takeout via Composer:
composer global require"tightenco/takeout:~2.9"
If you use the PHP/Composer installation, make sure you're on the latest version of PHP. We'll only support the current major version of PHP using this installation approach.
Runtakeout
and then a command name from anywhere in your terminal.
One of Takeout's primary benefits is that it boots ("enables") or deletes ("disables") Docker containers for your various dependencies quickly and easily.
Because Docker offers persistent volume storage, deleting a container (which we call "disabling" it) doesn't actually delete its data. That means you can enable and disable services with reckless abandon.
Show a list of all services you can enable.
takeoutenable
Passed the short name of one or more services, enable them.
takeoutenable mysqltakeoutenable redis meilisearch
If you want to skip over being asked for each parameter and just accept the defaults. This also works with multiple services in one command.
takeoutenable mysql --defaulttakeoutenable redis meilisearch --default
You may specify extra arguments to the container after a--
sepatator:
takeoutenable mysql -- -hsome.mysql.host -usome-user
Notice that these are arguments for the container Entrypoint, not extra docker run options (see below).
Under the hood, thetakeout enable
command generates adocker run
command. Sometimes you may want to specify extra options to thedocker run
command such as an extra environment variable or an extra volume mapping. You can pass a string with all the extradocker run
options using the--run=
option:
takeoutenable mysql --run="{docker-run-options}"
Which would generate the following command:
docker run {docker-run-options} {service-options} mysql/mysql-server
Where{docker-run-options}
are the options you specify inside the--run
option and{service-options}
are generated based on the default options for that service.
You may mix and match therun
options with the container arguments:
takeoutenable mysql --run="{docker-run-options}" -- -hsome.mysql.host -usome-user
Show a list of all enabled services you can disable.
takeout disable
Passed the short name of one or more services, disable the enabled services that match them most closely.
takeout disable mysqltakeout disable redis meilisearch
takeout disable --all
Show a list of all stopped containers you can start.
takeout start
Passed the container ID of one or more stopped containers, start the stopped containers that matches them.
takeout start {container_id}takeout start {container_id1} {container_id2}
You may pass the-all
flag to start all enabled containers.
takeout start --all
Show a list of all running containers you can stop.
takeout stop
Passed the container ID of one or more running containers, stop the running containers that matches them.
takeout stop {container_id}takeout stop {container_id1} {container_id2}
To get a shell inside any container that is started with Takeout, you may run:
takeout shell {service}
Here are some examples:
takeout shell mysqltakeout shell neo4jtakeout shell pgvector
This will open a shell inside the running container for the service you provide. Takeout will start either abash
or ash
process inside the container, depending on what the container supports.
Another of Takeout's benefits is that it allows you to have multiple versions of a dependency installed and running at the same time. That means, for example, that you can run both MySQL 5.7 and 8.0 at the same time, on different ports.
Runtakeout enable mysql
twice; the first time, you'll want to choose the default port (3306
) and the first version (5.7
), and the second time, you'll want to choose a second port (3307
), the second version (8.0
) and a different volume name (so that they don't share the samemysql_data
).
Now, if you runtakeout list
, you'll see both services running at the same time.
+--------------+----------------+---------------+-----------------------------------+| CONTAINER ID| NAMES| STATUS| PORTS|+--------------+----------------+---------------+-----------------------------------+| 4bf3379ab2f5| TO--mysql--5.7| Up 2 seconds| 33060/tcp, 0.0.0.0:3306->3306/tcp|| 983acf46ceef| TO--mysql--8.0| Up 35 seconds| 33060/tcp, 0.0.0.0:3307->3306/tcp|+--------------+----------------+---------------+-----------------------------------+
Takeout containers are automatically added to a Docker network namedtakeout
. This allows you to use the same aliasing and base aliasing that is used for the other containers.
Each container is given two aliases on this network:
- A base_alias based on the core dependency name (e.g. mysql, postgres)
- A full_alias combining the base alias and version (e.g. mysql8.0, postgres13)
Other containers on the takeout network can access Takeout containers by their aliases.Check this article on how you can use sail and takeout together
Will this enable the PHP drivers for me via PECL?
Sadly, no.
If I disable a service but Takeout still shows the port as taken, how do I proceed?
First, runlsof -i :3306
(where 3306 is the port that's unavailable.)
If you see output like this:
com.docke 936 mattstauffer 52u IPv6 0xc0d6f0b06d5c4efb 0t0 TCP localhost:mysql->localhost:62919 (FIN_WAIT_2)TablePlus 96155 mattstauffer 16u IPv4 0xc0d6f0b0b6dccf6b 0t0 TCP localhost:62919->localhost:mysql (CLOSE_WAIT)
The solution is to just close your database GUI, and then it should be released.
Why would you use this instead of `docker-compose`?
Usingdocker-compose
sets up your dependencies on a project-by-project basis, which is a perfectly fine way to do things. If it makes more sense to you to have a single copy of each of your dependencies for your entire global environment, Takeout makes more sense.
Will disabling a service permanently delete my databases?
Nope! Your data will stick around! By default almost all of our services use a "volume" to attach your data to for exactly this reason.
So, when you disable the MySQL service, for example, that volume--with all your data in it--will just sit there quietly. And when you re-enable, as long as you attach it to the same volume, all your data will still be there.
The best way to see our future plans is to check out theProjects Board, but here are a few plans for the future:
- Electron-based GUI
self-remove
command: Deletes all enabled services and then maybe self-uninstalls?upgrade
: destroys the old container, brings up a new one with a newly-specified tag (prompt user for it, defaultlatest
) and keeps all other parameters (e.g. port, volume) exactly the same as the old onept/passthrough
: proxy commands through to docker (./takeout pt mysql stop
)- Deliver package in a way that's friendly to non-PHP developers (Homebrew? NPM?)
- Allow other people to extend Takeout by adding their own plugins (thanks to @angrybrad for the idea!)
If you're working with us and are assigned to push a release, here's the easiest process:
- Visit theTakeout Releases page; figure out what your next tag will be (increase the third number if it's a patch or fix; increase the second number if it's adding features)
- On your local machine, pull down the latest version of
main
(git checkout main && git pull
) - Build for the version you're targeting (
php ./takeout app:build
) - Run the build once to make sure it works (
php ./builds/takeout list
) - Commit your build and push it up
- Draft a new release with both the tag version and release title of your tag (e.g.
v1.5.1
) - Use the "Generate release notes" button to generate release notes from the merged PRs.
- Hit
Publish release
- The new tag and release will trigger the
docker-publish.yml
workflow, which should take care of building and pushing the new image of the Docker container (see the "Building The Docker Image Manually" section below) - Profit 😆
The important thing is to remember to build bothlinux/amd64
andlinux/arm64
images. We rely on Docker'sbuildx
command, which uses Docker'sBuildKit behind the scenes, which allows us to build for multiple platforms, independently of the platform of the machine building the image.
You may build and publish a new version of the docker image using the following command:
docker buildx build --platform=linux/amd64,linux/arm64 -t tighten/takeout:latest --push.
If it's the first time you're building the image, you may get the following error:
ERROR: Multiple platforms feature is currently not supported for docker driver. Please switch to a different driver (eg. "docker buildx create --use")
This means that you first need to create a builder container, which you maydo like so:
docker buildx create --use
After that, retrying thebuildx
command should work.
Please, note that building the container will simply copy the current version of the Takeoutphar
file atbuilds/takeout to inside the container and publish that, so make sure you have to most recent version built locally. If you don't, follow the release process to build the new version before building the Docker image.
About
Docker-based development-only dependency manager. macOS, Linux, and WSL2-only and installs via PHP's Composer... for now.