A month ago, we announced our
configure-docker command, and we're excited to announce an expansion of it that covers Docker Compose and other tools that leverage
docker buildx build!
Our latest release of the Depot CLI expands our new command that installs Depot as a Docker CLI plugin to configure a default
buildx driver to use Depot as well. Allowing you to leverage Depot for any workloads that use
docker buildx build, like Docker Compose. All without having to change a single line of code 🎉
How it works
Once you have the latest version of the CLI installed, you can run the following command:
Successfully installed Depot as a Docker CLI plugin
Behind the scenes, in addition to installing Depot as a Docker CLI plugin, the command configures a default
buildx driver that routes builds to Depot. Allowing any
docker buildx build commands to use Depot, in addition to the existing
docker build command.
Using Depot with Docker Compose
configure-docker command is executed, you can use Depot with Docker Compose without changing a single line of code. All you need to do is ensure you have a Depot project configured for your build. You can do this via:
- Setting a
DEPOT_PROJECT_IDenvironment variable to the project ID of the project you want to use for builds.
depot initin the root of the repository in which you're building your image. The command creates a
depot.jsonfile that our plugin will detect.
If you have a Depot project configured, you can run
docker compose build, and Depot will build the images in your Docker compose file. You can see this in action in the following example.
Here is our example Docker compose file with a single service:
The Dockerfile that it is building looks like this:
FROM node:16 AS build
COPY package.json yarn.lock tsconfig.json ./
COPY src/ ./src/
RUN yarn install --immutable
RUN yarn build
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
COPY gifs-to-upload/ dist/gifs-to-upload/
ENV NODE_ENV production
CMD ["node", "--enable-source-maps", "./dist/index.js"]
Now, all you have to do is call
up just as you usually would.
docker compose build
#1 [app depot] build: https://depot.dev/orgs/123/projects/456/builds/000
#1 DONE 0.0s
#2 [app depot] build: https://depot.dev/orgs/123/projects/456/builds/111
#2 DONE 0.0s
# ...continued output from Docker Compose
You can see that the Docker is building with Depot. It creates a separate build for each architecture and service defined in the
If you want to use Depot with Docker Compose but prefer to use the
up command, you can also do that. Just run
docker compose up, and Depot will build your images.
docker compose up
[+] Building 33.0s (19/19)
=> [app depot] build: https://depot.dev/orgs/123/projects/456/builds/222 0.0s
=> [app depot] launching arm64 machine 2.0s
=> [app depot] connecting to arm64 machine 6.9s
=> [app internal] load build definition from Dockerfile.app
=> ...continued output from Docker Compose
Note on Docker Compose
Docker Compose creates a new build for each service and architecture defined in the
compose.yml. If you have a
docker-compose.yml that defines 3 services, and you're building for 2 architectures, you will have 6 builds created in Depot.
Power of Depot for all tools
Before this command, these tools couldn't integrate with Depot. They call
docker build or
docker buildx build directly, and there was no way to configure them to use a different builder.
depot configure-docker, all tools using Docker or
buildx internally can route their image builds to Depot. We have an integration guide and documentation for how this works with Dev Containers and
docker build and
docker buildx build in general.
We're excited about what this new command will unlock for folks! We will put out some new integration guides for other tools that need to build a Docker container on demand, so stay tuned for those. You can also hop in our Community Discord and let us know which tools you'd like us to integrate with next!