From 3e938b5683a00de8cf398be31ae5eb81bc54af28 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Thu, 26 Oct 2023 14:48:54 -0300 Subject: [PATCH 01/24] Adds the Dockerfile we can use to build the new image --- Dockerfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..da18486e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM php:8.1-cli-alpine + +COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx + +# Install the PHP extensions & Docker +RUN apk add --no-cache --update build-base git docker openrc \ + && docker-php-ext-configure pcntl --enable-pcntl \ + && docker-php-ext-install -j$(nproc) pcntl \ + && rc-update add docker boot + +WORKDIR /takeout + +COPY builds/takeout /usr/local/bin/takeout + +ENTRYPOINT ["takeout"] + From 0bbe2b86571b9a8be7dde9bac4cfdc66ea05382c Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 27 Oct 2023 11:19:29 -0300 Subject: [PATCH 02/24] Adds a workflow that will build and publish the Docker image whenever there's a release/tag --- .github/workflows/docker-publish.yml | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 00000000..0367b5c3 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,55 @@ +name: Docker + +on: + workflow_dispatch: + inputs: + tagInput: + description: 'Tag' + required: true + + release: + types: [created] + tags: + - 'v*' + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + registry: docker.io + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Determine version tag + id: version-tag + run: | + INPUT_VALUE="${{ github.event.inputs.tagInput }}" + if [ -z "$INPUT_VALUE" ]; then + INPUT_VALUE="${{ github.ref_name }}" + fi + echo "::set-output name=value::$INPUT_VALUE" + - + name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + tighten/takeout:latest + tighten/takeout:${{ steps.version-tag.outputs.value }} From 63ad63cdf0e2709793d4f35c2142164086d9b91a Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 27 Oct 2023 11:45:39 -0300 Subject: [PATCH 03/24] Update install instructions --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4e461f01..0762ea73 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,19 @@ With `takeout enable mysql` you're running MySQL, and never have to worry about 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 -## Requirements +## Installation -- macOS, Linux, Windows 10 or WSL2 -- [Composer](https://getcomposer.org/) installed -- Docker installed (macOS: [Docker for Mac](https://docs.docker.com/docker-for-mac/), Windows: [Docker for Windows](https://docs.docker.com/docker-for-windows/)) +Takeout works on macOS, Linux, and Windows. First of all, make sure you have [Docker installed](https://docs.docker.com/get-docker/). -## Installation +You may use the dockerized version via an alias. Add this to your `~/.bashrc` (or similar): + +```bash +alias takeout="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -it tighten/takeout:latest" +``` + +This is the preffered way, since it doesn't require you to have PHP installed locally and, even if you have, doesn't conflict with your local PHP version. -Install Takeout with Composer by running: +Otherwise, if you have PHP (8.0+) and [Composer](https://getcomposer.org/) installed locally, you may install Takeout globally with: ```bash composer global require tightenco/takeout From fd3db36c14714f3aca1b9aa5938065a9b366a0e6 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 27 Oct 2023 11:47:25 -0300 Subject: [PATCH 04/24] Tweaks wording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0762ea73..77fb7aa8 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ But you can also easily enable ElasticSearch, PostgreSQL, MSSQL, Mongo, Redis, a ## Installation -Takeout works on macOS, Linux, and Windows. First of all, make sure you have [Docker installed](https://docs.docker.com/get-docker/). +Takeout works on macOS, Linux, and Windows. To get started, make sure you have [Docker installed](https://docs.docker.com/get-docker/) on your system. You may use the dockerized version via an alias. Add this to your `~/.bashrc` (or similar): From 136c7ce8ed27780cfab5eb5d7e0ddac8961f8b09 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 27 Oct 2023 11:50:01 -0300 Subject: [PATCH 05/24] Fix default postgres version has been updated --- tests/Feature/DockerTagsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/DockerTagsTest.php b/tests/Feature/DockerTagsTest.php index 3197e30b..509c65b1 100644 --- a/tests/Feature/DockerTagsTest.php +++ b/tests/Feature/DockerTagsTest.php @@ -42,7 +42,7 @@ function it_sorts_the_versions_naturally() $tags = collect($dockerTags->getTags()); $this->assertEquals('latest', $tags->shift()); - $this->assertEquals('bullseye', $tags->shift()); + $this->assertEquals('buster', $tags->shift()); } /** @test */ From c3df03d4f7d6025273b7f5c0b641e39d7038ab46 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 27 Oct 2023 12:05:09 -0300 Subject: [PATCH 06/24] Remove unused dependencies --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index da18486e..232cb134 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM php:8.1-cli-alpine COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx # Install the PHP extensions & Docker -RUN apk add --no-cache --update build-base git docker openrc \ +RUN apk add --no-cache --update docker openrc \ && docker-php-ext-configure pcntl --enable-pcntl \ && docker-php-ext-install -j$(nproc) pcntl \ && rc-update add docker boot From 2eae54932a6c1990783c773e352a6fcecf0a9860 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 27 Oct 2023 12:08:50 -0300 Subject: [PATCH 07/24] Drop the mention of composer global require --- README.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/README.md b/README.md index 77fb7aa8..517bfcec 100644 --- a/README.md +++ b/README.md @@ -19,22 +19,12 @@ But you can also easily enable ElasticSearch, PostgreSQL, MSSQL, Mongo, Redis, a Takeout works on macOS, Linux, and Windows. To get started, make sure you have [Docker installed](https://docs.docker.com/get-docker/) on your system. -You may use the dockerized version via an alias. Add this to your `~/.bashrc` (or similar): +To install Takeout locally, add this alias to your `.bashrc` (or similar): ```bash alias takeout="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -it tighten/takeout:latest" ``` -This is the preffered way, since it doesn't require you to have PHP installed locally and, even if you have, doesn't conflict with your local PHP version. - -Otherwise, if you have PHP (8.0+) and [Composer](https://getcomposer.org/) installed locally, you may install Takeout globally with: - -```bash -composer global require tightenco/takeout -``` - -Make sure the `~/.composer/vendor/bin` directory is in your system's "PATH". - ## Usage Run `takeout` and then a command name from anywhere in your terminal. From 4de5754b1e1c338e997323f2737566e84c3cf2f4 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 27 Oct 2023 15:30:06 -0300 Subject: [PATCH 08/24] Adds ncurses package for the cli-menu --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 232cb134..45db4e14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM php:8.1-cli-alpine COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx # Install the PHP extensions & Docker -RUN apk add --no-cache --update docker openrc \ +RUN apk add --no-cache --update docker openrc ncurses \ && docker-php-ext-configure pcntl --enable-pcntl \ && docker-php-ext-install -j$(nproc) pcntl \ && rc-update add docker boot From cdeecdf243dd6d2ebeb083aa2e956b22432980ee Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 27 Oct 2023 20:52:03 -0300 Subject: [PATCH 09/24] Fix alpine ARM64 uname is different than macos --- app/Shell/DockerTags.php | 44 +++++--------------------------- tests/Feature/DockerTagsTest.php | 4 +++ 2 files changed, 11 insertions(+), 37 deletions(-) diff --git a/app/Shell/DockerTags.php b/app/Shell/DockerTags.php index 6b977a66..a9ec6978 100644 --- a/app/Shell/DockerTags.php +++ b/app/Shell/DockerTags.php @@ -43,11 +43,9 @@ public function getLatestTag(): string public function getTags(): Collection { $response = json_decode($this->getTagsResponse()->getContents(), true); - $platform = $this->platform(); [$numericTags, $alphaTags] = collect($response['results']) - ->when($platform === 'arm64', $this->armSupportedImagesOnlyFilter()) - ->when($platform !== 'arm64', $this->nonArmOnlySupportImagesFilter()) + ->filter($this->onlySupportedImagesFilter()) ->pluck('name') ->partition(function ($tag) { return is_numeric($tag[0]); @@ -64,42 +62,14 @@ public function getTags(): Collection return $sortedTags->values()->filter(); } - /** - * Return a function intended to filter tags, ensuring images that do not support arm architecture are filtered out. - * - * @return callable - */ - protected function armSupportedImagesOnlyFilter() + protected function onlySupportedImagesFilter() { - return function ($tags) { - return $tags->filter(function ($tag) { - return collect($tag['images']) - ->pluck('architecture') - ->contains('arm64'); - }); - }; - } + $platform = $this->platform(); - /** - * Return a function intended to filter tags, that ensures are arm-only images are filtered out. - * - * @return callable - */ - protected function nonArmOnlySupportImagesFilter() - { - return function ($tags) { - return $tags->filter(function ($tag) { - $supportedArchitectures = collect($tag['images']) - ->pluck('architecture') - ->unique() - ->values(); - - // When removing the arm64 option from the list, there should - // still be other options in the supported architectures - // so we can consider that the tag is not arm-only. - - return $supportedArchitectures->diff(['arm64'])->count() > 0; - }); + return function ($tag) use ($platform) { + return collect($tag['images']) + ->pluck('architecture') + ->contains($platform); }; } diff --git a/tests/Feature/DockerTagsTest.php b/tests/Feature/DockerTagsTest.php index 509c65b1..4e275e2f 100644 --- a/tests/Feature/DockerTagsTest.php +++ b/tests/Feature/DockerTagsTest.php @@ -77,13 +77,16 @@ private function mockImagesResponseHandler() [ 'name' => 'latest', 'images' => [ + ['architecture' => 'x86_64'], ['architecture' => 'amd64'], ['architecture' => 'arm64'], + ['architecture' => 'aarch64'], ], ], [ 'name' => '1.0.0', 'images' => [ + ['architecture' => 'x86_64'], ['architecture' => 'amd64'], ], ], @@ -91,6 +94,7 @@ private function mockImagesResponseHandler() 'name' => '1.0.0-arm64', 'images' => [ ['architecture' => 'arm64'], + ['architecture' => 'aarch64'], ], ], ], From c33a95cacccf2def5ee643fa4db5295c8a406498 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 27 Oct 2023 22:02:48 -0300 Subject: [PATCH 10/24] Tweaks the platform check code --- app/Shell/DockerTags.php | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/app/Shell/DockerTags.php b/app/Shell/DockerTags.php index a9ec6978..deb64263 100644 --- a/app/Shell/DockerTags.php +++ b/app/Shell/DockerTags.php @@ -44,8 +44,11 @@ public function getTags(): Collection { $response = json_decode($this->getTagsResponse()->getContents(), true); + $platform = $this->platform(); + [$numericTags, $alphaTags] = collect($response['results']) - ->filter($this->onlySupportedImagesFilter()) + ->when($this->isArm($platform), $this->onlyArmImagesFilter()) + ->when(! $this->isArm($platform), $this->onlyNonArmImagesFilter()) ->pluck('name') ->partition(function ($tag) { return is_numeric($tag[0]); @@ -62,14 +65,29 @@ public function getTags(): Collection return $sortedTags->values()->filter(); } - protected function onlySupportedImagesFilter() + protected function onlyArmImagesFilter() { - $platform = $this->platform(); + return function ($tags) { + return $tags->filter(function ($tag) { + return collect($tag['images']) + ->pluck('architecture') + ->first(function (string $platform) { + return $this->isArm($platform); + }); + }); + }; + } - return function ($tag) use ($platform) { - return collect($tag['images']) - ->pluck('architecture') - ->contains($platform); + protected function onlyNonArmImagesFilter() + { + return function ($tags) { + return $tags->filter(function ($tag) { + return collect($tag['images']) + ->pluck('architecture') + ->first(function (string $platform) { + return ! $this->isArm($platform); + }); + }); }; } @@ -78,6 +96,11 @@ protected function platform(): string return php_uname('m'); } + protected function isArm(string $platform): bool + { + return in_array($platform, ['arm64', 'aarch64']); + } + protected function getTagsResponse(): StreamInterface { return $this->guzzle From a3978b56e40c18b257074c3186c615a3f6963e88 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 3 Nov 2023 09:54:16 -0300 Subject: [PATCH 11/24] Simplify the platform tests --- app/Shell/DockerTags.php | 3 +-- tests/Feature/DockerTagsTest.php | 27 +++++++++++++++--------- tests/Support/FakePlatformDockerTags.php | 26 +++++++++++++++++++++++ tests/Support/IntelDockerTags.php | 13 ------------ tests/Support/M1DockerTags.php | 13 ------------ 5 files changed, 44 insertions(+), 38 deletions(-) create mode 100644 tests/Support/FakePlatformDockerTags.php delete mode 100644 tests/Support/IntelDockerTags.php delete mode 100644 tests/Support/M1DockerTags.php diff --git a/app/Shell/DockerTags.php b/app/Shell/DockerTags.php index deb64263..f8750132 100644 --- a/app/Shell/DockerTags.php +++ b/app/Shell/DockerTags.php @@ -47,8 +47,7 @@ public function getTags(): Collection $platform = $this->platform(); [$numericTags, $alphaTags] = collect($response['results']) - ->when($this->isArm($platform), $this->onlyArmImagesFilter()) - ->when(! $this->isArm($platform), $this->onlyNonArmImagesFilter()) + ->when($this->isArm($platform), $this->onlyArmImagesFilter(), $this->onlyNonArmImagesFilter()) ->pluck('name') ->partition(function ($tag) { return is_numeric($tag[0]); diff --git a/tests/Feature/DockerTagsTest.php b/tests/Feature/DockerTagsTest.php index 4e275e2f..a1ffcb4a 100644 --- a/tests/Feature/DockerTagsTest.php +++ b/tests/Feature/DockerTagsTest.php @@ -10,8 +10,7 @@ use GuzzleHttp\HandlerStack; use GuzzleHttp\Psr7\Response; use Mockery as M; -use Tests\Support\IntelDockerTags; -use Tests\Support\M1DockerTags; +use Tests\Support\FakePlatformDockerTags; use Tests\TestCase; class DockerTagsTest extends TestCase @@ -45,14 +44,17 @@ function it_sorts_the_versions_naturally() $this->assertEquals('buster', $tags->shift()); } - /** @test */ - function it_detects_arm64_based_images_when_running_on_arm64_based_host() + /** + * @test + * + * @dataProvider armPlatforms + */ + function it_detects_arm_based_images_when_running_on_arm64_based_host($platform) { $handlerStack = HandlerStack::create($this->mockImagesResponseHandler()); $client = new Client(['handler' => $handlerStack]); - /** @var DockerTags $dockerTags */ - $dockerTags = M::mock(M1DockerTags::class, [$client, app(MySql::class)])->makePartial(); + $dockerTags = (new FakePlatformDockerTags($client, app(MySql::class)))->withFakePlatform($platform); $this->assertEquals('1.0.0-arm64', $dockerTags->getLatestTag()); } @@ -63,12 +65,19 @@ function it_gets_latest_tag_on_intel_platform() $handlerStack = HandlerStack::create($this->mockImagesResponseHandler()); $client = new Client(['handler' => $handlerStack]); - /** @var DockerTags $dockerTags */ - $dockerTags = M::mock(IntelDockerTags::class, [$client, app(MySql::class)])->makePartial(); + $dockerTags = (new FakePlatformDockerTags($client, app(MySql::class)))->withFakePlatform(FakePlatformDockerTags::INTEL_ARM_PLATFORM); $this->assertEquals('1.0.0', $dockerTags->getLatestTag()); } + public static function armPlatforms() + { + return [ + [FakePlatformDockerTags::M1_ARM_PLATFORM], + [FakePlatformDockerTags::LINUX_ARM_PLATFORM], + ]; + } + private function mockImagesResponseHandler() { return new MockHandler([ @@ -79,8 +88,6 @@ private function mockImagesResponseHandler() 'images' => [ ['architecture' => 'x86_64'], ['architecture' => 'amd64'], - ['architecture' => 'arm64'], - ['architecture' => 'aarch64'], ], ], [ diff --git a/tests/Support/FakePlatformDockerTags.php b/tests/Support/FakePlatformDockerTags.php new file mode 100644 index 00000000..dc4b7dc4 --- /dev/null +++ b/tests/Support/FakePlatformDockerTags.php @@ -0,0 +1,26 @@ +fakePlatform = $platform; + + return $this; + } + + protected function platform(): string + { + return $this->fakePlatform; + } +} diff --git a/tests/Support/IntelDockerTags.php b/tests/Support/IntelDockerTags.php deleted file mode 100644 index 423c0003..00000000 --- a/tests/Support/IntelDockerTags.php +++ /dev/null @@ -1,13 +0,0 @@ - Date: Fri, 3 Nov 2023 09:57:45 -0300 Subject: [PATCH 12/24] Tweaks the README --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 517bfcec..93e99e20 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,12 @@ With `takeout enable mysql` you're running MySQL, and never have to worry about 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 -## Installation +## Requirements + +- macOS, Linux, Windows 10 or WSL2 +- Docker installed (macOS: [Docker for Mac](https://docs.docker.com/docker-for-mac/), Windows: [Docker for Windows](https://docs.docker.com/docker-for-windows/)) -Takeout works on macOS, Linux, and Windows. To get started, make sure you have [Docker installed](https://docs.docker.com/get-docker/) on your system. +## Installation To install Takeout locally, add this alias to your `.bashrc` (or similar): @@ -25,6 +28,8 @@ To install Takeout locally, add this alias to your `.bashrc` (or similar): alias takeout="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -it tighten/takeout:latest" ``` +_Note: Previous versions of Takeout required installing it via `composer global require`. That's discouraged now and the Docker image is the preferred way._ + ## Usage Run `takeout` and then a command name from anywhere in your terminal. From f5a786e319bf514fadd0bb4ef01a186ba5f829f3 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 3 Nov 2023 10:01:03 -0300 Subject: [PATCH 13/24] Fix tlint --- tests/Feature/DockerTagsTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Feature/DockerTagsTest.php b/tests/Feature/DockerTagsTest.php index a1ffcb4a..81c7da4f 100644 --- a/tests/Feature/DockerTagsTest.php +++ b/tests/Feature/DockerTagsTest.php @@ -15,6 +15,14 @@ class DockerTagsTest extends TestCase { + public static function armPlatforms(): array + { + return [ + [FakePlatformDockerTags::M1_ARM_PLATFORM], + [FakePlatformDockerTags::LINUX_ARM_PLATFORM], + ]; + } + /** @test */ function it_gets_the_latest_tag_not_named_latest() { @@ -70,14 +78,6 @@ function it_gets_latest_tag_on_intel_platform() $this->assertEquals('1.0.0', $dockerTags->getLatestTag()); } - public static function armPlatforms() - { - return [ - [FakePlatformDockerTags::M1_ARM_PLATFORM], - [FakePlatformDockerTags::LINUX_ARM_PLATFORM], - ]; - } - private function mockImagesResponseHandler() { return new MockHandler([ From 290de4fe3fd27e0f91a69fde2786de2daee7fcc8 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 3 Nov 2023 11:15:18 -0300 Subject: [PATCH 14/24] Adds docs for manually building and publishing the docker image --- README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 93e99e20..bbd6cded 100644 --- a/README.md +++ b/README.md @@ -232,7 +232,6 @@ The best way to see our future plans is to check out the [Projects Board](https: If you're working with us and are assigned to push a release, here's the easiest process: - 1. Visit the [Takeout Releases page](https://github.com/tighten/takeout/releases); 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) 2. On your local machine, pull down the latest version of `main` (`git checkout main && git pull`) 3. Build for the version you're targeting (`php ./takeout app:build`) @@ -241,4 +240,29 @@ If you're working with us and are assigned to push a release, here's the easiest 6. [Draft a new release](https://github.com/tighten/takeout/releases/new) with both the tag version and release title of your tag (e.g. `v1.5.1`) 7. Use the "Generate release notes" button to generate release notes from the merged PRs. 8. Hit `Publish release` -9. Profit 😆 +9. The new tag and release will trigger the [`docker-publish.yml`](.github/workflows/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) +10. Profit 😆 + +## Building The Docker Image Manually + +The important thing is to remember to build both `linux/amd64` and `linux/arm64` images. We rely on Docker's `buildx` command, which uses Docker's [BuildKit](https://github.com/moby/buildkit) 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: + +```bash +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: + +```bash +docker buildx create --use +``` + +After that, retrying the `buildx` command should work. Please, note that building the contianer will simply copy the current version of the Takeout `phar` file at [builds/takeout](./builds/takeout) to inside the container and publish that, so make sure you have to most recently built phar file locally. If you don't, follow the release process to build the new version before building the Docker image. From 4eb995e6b8d52c8ee38a9cb7528e4ea63a90c225 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 3 Nov 2023 11:19:26 -0300 Subject: [PATCH 15/24] wip --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bbd6cded..518fc946 100644 --- a/README.md +++ b/README.md @@ -265,4 +265,6 @@ This means that you first need to create a builder container, which you maydo li docker buildx create --use ``` -After that, retrying the `buildx` command should work. Please, note that building the contianer will simply copy the current version of the Takeout `phar` file at [builds/takeout](./builds/takeout) to inside the container and publish that, so make sure you have to most recently built phar file locally. If you don't, follow the release process to build the new version before building the Docker image. +After that, retrying the `buildx` command should work. + +Please, note that building the contianer will simply copy the current version of the Takeout `phar` file at [builds/takeout](./builds/takeout) to inside the container and publish that, so make sure you have to most recently built phar file locally. If you don't, follow the release process to build the new version before building the Docker image. From f3f0ebd5d454ee8f2c67fab063e92db724bda559 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 3 Nov 2023 11:20:29 -0300 Subject: [PATCH 16/24] wip --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 518fc946..5d545ec7 100644 --- a/README.md +++ b/README.md @@ -267,4 +267,4 @@ docker buildx create --use After that, retrying the `buildx` command should work. -Please, note that building the contianer will simply copy the current version of the Takeout `phar` file at [builds/takeout](./builds/takeout) to inside the container and publish that, so make sure you have to most recently built phar file locally. If you don't, follow the release process to build the new version before building the Docker image. +Please, note that building the container will simply copy the current version of the Takeout `phar` file at [builds/takeout](./builds/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. From 58a23c1d9465fe0160c6ffd96034ed2cf837f2bc Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 3 Nov 2023 11:56:18 -0300 Subject: [PATCH 17/24] Adds a TAKEOUT_CONTAINER env variable inside the container (which we can detect within takeout itself, if needed) --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 45db4e14..258204bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM php:8.1-cli-alpine +ENV TAKEOUT_CONTAINER=1 + COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx # Install the PHP extensions & Docker From 9aa200e2bdf3d7dc46e1ac2551cba64bab4cb96e Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Sat, 4 Nov 2023 14:45:21 -0300 Subject: [PATCH 18/24] Tweaks --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d545ec7..5ed34e2a 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ But you can also easily enable ElasticSearch, PostgreSQL, MSSQL, Mongo, Redis, a ## Installation -To install Takeout locally, add this alias to your `.bashrc` (or similar): +To install Takeout locally, add this alias to your `~/.bashrc` (or similar): ```bash alias takeout="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -it tighten/takeout:latest" From 0f83b0e7c72d2bcc23ea4e2f05d8c0ceb690fcd9 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 6 Dec 2024 19:43:45 -0300 Subject: [PATCH 19/24] wording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e659e1ed..8d354206 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ The recommended way to install Takeout is the dockerized version via an alias (a alias takeout="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -it tighten/takeout:latest" ``` -That's it. You can now use Takeout like normal. The first time you use this alias, it will pull the Takeout image from Docker Hub. +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, run `docker pull tighten/takeout` when you want to get the newest release. From 13be11cd7390c6cd5f4ed38fcfbd98a8334ac2e4 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 6 Dec 2024 21:05:30 -0300 Subject: [PATCH 20/24] Adds the Windows alias tweak --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d354206..fd16c195 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,20 @@ If you opt for the PHP/Composer installation, you also need: ## Installation -The recommended way to install Takeout is the dockerized version via an alias (add this to your `~/.bashrc`, `~/.zshrc` or equivalent): +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: ```bash alias takeout="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -it tighten/takeout:latest" ``` +On Windows, use: + +```bash +alias takeout="docker run --rm -v //var/run/docker.sock:/var/run/docker.sock -it tighten/takeout:latest" +``` + 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, run `docker pull tighten/takeout` when you want to get the newest release. From 1fd7157c788b1e11d36822fc11d61d96d4ab6f8e Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 6 Dec 2024 21:33:43 -0300 Subject: [PATCH 21/24] Wording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fd16c195..852b125f 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Otherwise, if you have a PHP environment available, you may install Takeout via composer global require "tightenco/takeout:~2.8" ``` -If you use the Composer installation path, make sure you're on the latest PHP version, as we'll try to keep it always up-to-date. We'll reserve the rights to only support the latest major version, and we'll try to keep up-to-date with PHP's release. +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. ## Usage From 060a03ad1268a568b775a35946ed3984d6af6c68 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Fri, 6 Dec 2024 21:58:34 -0300 Subject: [PATCH 22/24] Adds the powershell version of the alias Co-authored-by: Guillermo Cava --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 852b125f..2bac30e7 100644 --- a/README.md +++ b/README.md @@ -35,12 +35,18 @@ On Linux or macOS, use: alias takeout="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -it tighten/takeout:latest" ``` -On Windows, use: +On Windows 10, if you're using Bash, use: ```bash alias takeout="docker run --rm -v //var/run/docker.sock:/var/run/docker.sock -it tighten/takeout:latest" ``` +On Windows 10, if you're using PowerShell, use: + +```bash +function takeout { docker run --rm -v //var/run/docker.sock:/var/run/docker.sock -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, run `docker pull tighten/takeout` when you want to get the newest release. From 656306646c81feb0fadec694aa1224b854f01684 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Mon, 9 Dec 2024 10:52:09 -0300 Subject: [PATCH 23/24] Bump the actions versions Co-authored-by: Anthony Clark --- .github/workflows/docker-publish.yml | 10 +++++----- README.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 0367b5c3..14ef7f25 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -21,16 +21,16 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: docker.io username: ${{ secrets.DOCKER_HUB_USER }} @@ -45,7 +45,7 @@ jobs: echo "::set-output name=value::$INPUT_VALUE" - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64,linux/arm64 diff --git a/README.md b/README.md index 2bac30e7..01f09d49 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ To update the image, run `docker pull tighten/takeout` when you want to get the Otherwise, if you have a PHP environment available, you may install Takeout via Composer: ```bash -composer global require "tightenco/takeout:~2.8" +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. From 4468c350a7efcd444935c6752b447b81cab919f8 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Mon, 16 Dec 2024 11:30:38 -0300 Subject: [PATCH 24/24] Tweaks --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 01f09d49..13f540f9 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ But you can also easily enable ElasticSearch, PostgreSQL, MSSQL, Mongo, Redis, a - macOS, Linux, Windows 10 or WSL2 - Docker installed (macOS: [Docker for Mac](https://docs.docker.com/docker-for-mac/), Windows: [Docker for Windows](https://docs.docker.com/docker-for-windows/)) -If you opt for the PHP/Composer installation, you also need: +If you opt for the PHP/Composer installation (not recommended), you also need: - PHP installed (latest major version) - Composer installed