{"id":13734770,"url":"https://github.com/palantir/gradle-docker","last_synced_at":"2025-04-12T20:39:14.821Z","repository":{"id":39006047,"uuid":"42682769","full_name":"palantir/gradle-docker","owner":"palantir","description":"a Gradle plugin for orchestrating docker builds and pushes.","archived":false,"fork":false,"pushed_at":"2025-04-12T09:40:38.000Z","size":1645,"stargazers_count":753,"open_issues_count":120,"forks_count":162,"subscribers_count":287,"default_branch":"develop","last_synced_at":"2025-04-12T10:36:52.163Z","etag":null,"topics":["docker","gradle","octo-correct-managed"],"latest_commit_sha":null,"homepage":null,"language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/palantir.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog/0.22.2/pr-296.v2.yml","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-09-17T21:24:35.000Z","updated_at":"2025-04-12T10:16:27.000Z","dependencies_parsed_at":"2024-01-14T07:43:58.954Z","dependency_job_id":"6526048b-196b-4caf-a848-b082c89489b7","html_url":"https://github.com/palantir/gradle-docker","commit_stats":{"total_commits":509,"total_committers":53,"mean_commits":9.60377358490566,"dds":"0.24165029469548138","last_synced_commit":"7eceb2223ff659f0bd1f2e6c744f076d3b07cd80"},"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palantir%2Fgradle-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palantir%2Fgradle-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palantir%2Fgradle-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palantir%2Fgradle-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/palantir","download_url":"https://codeload.github.com/palantir/gradle-docker/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631669,"owners_count":21136554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","gradle","octo-correct-managed"],"created_at":"2024-08-03T03:00:59.633Z","updated_at":"2025-04-12T20:39:14.797Z","avatar_url":"https://github.com/palantir.png","language":"Groovy","funding_links":[],"categories":["Plugins","Groovy","\u003ca name=\"Groovy\"\u003e\u003c/a\u003eGroovy"],"sub_categories":["VM and container"],"readme":"\u003cp align=\"right\"\u003e\n\u003ca href=\"https://autorelease.general.dmz.palantir.tech/palantir/gradle-docker\"\u003e\u003cimg src=\"https://img.shields.io/badge/Perform%20an-Autorelease-success.svg\" alt=\"Autorelease\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nDocker Gradle Plugin\n====================\n[![Build Status](https://circleci.com/gh/palantir/gradle-docker.svg?style=shield)](https://circleci.com/gh/palantir/gradle-docker)\n[![Gradle Plugins Release](https://img.shields.io/github/release/palantir/gradle-docker.svg)](https://plugins.gradle.org/plugin/com.palantir.docker)\n\nDisclaimer: This Repo is now Defunct\n-------------\n\n- This repo is on life support only - although we will keep it working, no new features are accepted;\n- It is no longer used internally at Palantir.\n\nDocker Plugin\n-------------\n\nThis repository provides three Gradle plugins for working with Docker containers:\n- `com.palantir.docker`: add basic tasks for building and pushing\n  docker images based on a simple configuration block that specifies the container\n  name, the Dockerfile, task dependencies, and any additional file resources\n  required for the Docker build.\n- `com.palantir.docker-compose`: adds a task for populating placeholders in a\n  docker-compose template file with image versions resolved from\n  dependencies.\n- `com.palantir.docker-run`: adds tasks for starting, stopping, statusing and cleaning\n  up a named container based on a specified image\n\nApply the plugin using standard gradle convention:\n\n````gradle\nplugins {\n    id 'com.palantir.docker' version '\u003cversion\u003e'\n}\n````\n\nSet the container name, and then optionally specify a Dockerfile, any task\ndependencies and file resources required for the Docker build. This plugin will\nautomatically include outputs of task dependencies in the Docker build context.\n\n**Docker Configuration Parameters**\n- `name` the name to use for this container, may include a tag\n- `tags` (deprecated) (optional) an argument list of tags to create; any tag in `name` will\n  be stripped before applying a specific tag; defaults to the empty set\n- `tag` (optional) a tag to create with a specified task name\n- `dockerfile` (optional) the dockerfile to use for building the image; defaults to\n  `project.file('Dockerfile')` and must be a file object\n- `files` (optional) an argument list of files to be included in the Docker build context, evaluated per `Project#files`. For example, `files tasks.distTar.outputs` adds the TAR/TGZ file produced by the `distTar` tasks, and `files tasks.distTar.outputs, 'my-file.txt'` adds the archive in addition to file `my-file.txt` from the project root directory. The specified files are collected in a Gradle CopySpec which may be copied `into` the Docker build context directory. The underlying CopySpec may also be used to copy entire directories into the build context. The following example adds the aforementioned archive and text file to the CopySpec, uses the CopySpec to add all files `from` `src/myDir` into the CopySpec, then finally executes the copy into the directory `myDir` in docker build context.\n````gradle\ndocker {\n    files tasks.distTar.outputs, 'my-file.txt'\n    copySpec.from(\"src/myDir\").into(\"myDir\")\n}\n````\nThe final structure will be:\n```\nbuild/\n  docker/\n    myDir/\n      my-file.txt\n      // contents of task.distTar.outputs\n      // files from src/myDir\n```\n- `buildArgs` (optional) an argument map of string to string which will set --build-arg\n  arguments to the docker build command; defaults to empty, which results in no --build-arg parameters\n- `labels` (optional) a map of string to string which will set --label arguments\n  to the docker build command; defaults to empty, which results in no labels applied.\n- `pull` (optional) a boolean argument which defines whether Docker should attempt to pull\n  a newer version of the base image before building; defaults to `false`\n- `noCache` (optional) a boolean argument which defines whether Docker build should add the option --no-cache,\n    so that it rebuilds the whole image from scratch; defaults to `false`\n- `buildx` (optional) a boolean argument which defines whether Docker build should use buildx for cross platform builds; defaults to `false`\n- `platform` (optional) a list of strings argument which defines which platforms buildx should target; defaults to empty\n- `builder` (optional) a string argument which defines which builder buildx should use; defaults to `null`\n- `load` (optional) a boolean argument which defines whether Docker buildx builder should add --load flag,\n  loading the image into the local repository; defaults to `false`\n- `push` (optional) a boolean argument which defines whether Docker buildx builder should add --push flag,\n  pushing the image into the remote registry; defaults to `false`\n\nTo build a docker container, run the `docker` task. To push that container to a\ndocker repository, run the `dockerPush` task.\n\nTag and Push tasks for each tag will be generated for each provided `tag` and `tags` entry.\n\n**Examples**\n\nSimplest configuration:\n\n```gradle\ndocker {\n    name 'hub.docker.com/username/my-app:version'\n}\n```\n\nCanonical configuration for building a Docker image from a distribution archive:\n\n```gradle\n// Assumes that Gradle \"distribution\" plugin is applied\ndocker {\n    name 'hub.docker.com/username/my-app:version'\n    files tasks.distTar.outputs   // adds resulting *.tgz to the build context\n}\n```\n\nConfiguration specifying all parameters:\n\n```gradle\ndocker {\n    name 'hub.docker.com/username/my-app:version'\n    tags 'latest' // deprecated, use 'tag'\n    tag 'myRegistry', 'my.registry.com/username/my-app:version'\n    dockerfile file('Dockerfile')\n    files tasks.distTar.outputs, 'file1.txt', 'file2.txt'\n    buildArgs([BUILD_VERSION: 'version'])\n    labels(['key': 'value'])\n    pull true\n    noCache true\n}\n```\n\n\nManaging Docker image dependencies\n----------------------------------\nThe `com.palantir.docker` and `com.palantir.docker-compose` plugins provide\nfunctionality to declare and resolve version-aware dependencies between docker\nimages. The primary use-case is to generate `docker-compose.yml` files whose\nimage versions are mutually compatible and up-to-date in cases where multiple\nimages depend on the existence of the same Dockerized service.\n\n### Specifying and publishing dependencies on Docker images\n\nThe `docker` plugin adds a `docker` Gradle component and a `docker` Gradle\nconfiguration that can be used to specify and publish dependencies on other\nDocker containers.\n\n**Example**\n\n```gradle\nplugins {\n    id 'maven-publish'\n    id 'com.palantir.docker'\n}\n\n...\n\ndependencies {\n    docker 'foogroup:barmodule:0.1.2'\n    docker project(\":someSubProject\")\n}\n\npublishing {\n    publications {\n        dockerPublication(MavenPublication) {\n            from components.docker\n            artifactId project.name + \"-docker\"\n        }\n    }\n}\n```\n\nThe above configuration adds a Maven publication that specifies dependencies on\n`barmodule` and the `someSubProject` Gradle sub project. The resulting POM file\nhas two `dependency` entries, one for each dependency. Each project can declare\nits dependencies on other docker images and publish an artifact advertising\nthose dependencies.\n\n### Generating docker-compose.yml files from dependencies\n\nThe `com.palantir.docker-compose` plugin uses the transitive dependencies of the\n`docker` configuration to populate a `docker-compose.yml.template` file with the\nimage versions specified by this project and all its transitive dependencies.\nThe plugin uses standard Maven/Ivy machanism for declaring and resolving\ndependencies.\n\nThe `generateDockerCompose` task generates a `docker-compose.yml` file from a\nuser-defined template by replacing each version variable by the concrete version\ndeclared by the transitive dependencies of the docker configuration.  The task\nperforms two operations: First, it generates a mapping `group:name --\u003e version`\nfrom the dependencies of the `docker` configuration (see above). Second, it\nreplaces all occurrences of version variables of the form `{{group:name}}` in\nthe `docker-compose.yml.template` file by the resolved versions and writes the\nresulting file as `docker-compose.yml`.\n\nThe `docker-compose` plugin also provides a `dockerComposeUp` task that starts\nthe docker images specified in the `dockerComposeFile` in detached mode.\nYou can also use the `dockerComposeDown` task to stop the containers.\n\n\n**Example**\n\nAssume a `docker-compose.yml.template` as follows:\n\n```yaml\nmyservice:\n  image: 'repository/myservice:latest'\notherservice:\n  image: 'repository/otherservice:{{othergroup:otherservice}}'\n```\n\n`build.gradle` declares a dependency on a docker image published as\n'othergroup:otherservice' in version 0.1.2:\n\n```gradle\nplugins {\n    id 'com.palantir.docker-compose'\n}\n\ndependencies {\n    docker 'othergroup:otherservice:0.1.2'\n}\n```\n\nThe `generateDockerCompose` task creates a `docker-compose.yml` as follows:\n\n```yaml\nmyservice:\n  image: 'repository/myservice:latest'\notherservice:\n  image: 'repository/otherservice:0.1.2'\n```\n\nThe `generateDockerCompose` task fails if the template file contains variables\nthat cannot get resolved using the provided `docker` dependencies. Version\nconflicts between transitive dependencies of the same artifact are handled with\nthe standard Gradle semantics: each artifact is resolved to the highest declared\nversion.\n\n**Configuring file locations**\n\nThe template and generated file locations are customizable through the\n`dockerCompose` extension:\n\n```gradle\ndockerCompose {\n    template 'my-template.yml'\n    dockerComposeFile 'my-docker-compose.yml'\n}\n```\n\nDocker Run Plugin\n-----------------\nApply the plugin using standard gradle convention:\n\n```gradle\nplugins {\n    id 'com.palantir.docker-run' version '\u003cversion\u003e'\n}\n```\n\nUse the `dockerRun` configuration block to configure the name, image and optional\ncommand to execute for the `dockerRun` tasks:\n\n```gradle\ndockerRun {\n    name 'my-container'\n    image 'busybox'\n    volumes 'hostvolume': '/containervolume'\n    ports '7080:5000'\n    daemonize true\n    env 'MYVAR1': 'MYVALUE1', 'MYVAR2': 'MYVALUE2'\n    command 'sleep', '100'\n    arguments '--hostname=custom', '-P'\n}\n```\n\n**Docker Run Configuration Parameters**\n- `name` the name to use for this container, may include a tag.\n- `image` the name of the image to use.\n- `volumes` optional map of volumes to mount in the container. The key is the path\n  to the host volume, resolved using [`project.file()`](https://docs.gradle.org/current/userguide/working_with_files.html#sec:locating_files).\n  The value is the exposed container volume path.\n- `ports` optional mapping `local:container` of local port to container port.\n- `env` optional map of environment variables to supply to the running container.\n  These must be exposed in the Dockerfile with `ENV` instructions.\n- `daemonize` defaults to true to daemonize the container after starting. However\n  if your container runs a command and exits, you can set this to false.\n- `ignoreExitValue` (optional) to ignore the exit code returned from the execution of the docker command; defaults to `false`\n- `clean` (optional) a boolean argument which adds `--rm` to the `docker run`\n  command to ensure that containers are cleaned up after running; defaults to `false`\n- `command` the command to run.\n- `arguments` additional arguments to be passed into the docker run command.\n   Please see https://docs.docker.com/engine/reference/run/ for possible values.\n   \nTasks\n-----\n\n * **Docker**\n   * `docker`: build a docker image with the specified name and Dockerfile\n   * `dockerTag`: tag the docker image with all specified tags\n   * `dockerTag\u003ctag\u003e`: tag the docker image with `\u003ctag\u003e`\n   * `dockerPush`: push the specified image to a docker repository\n   * `dockerPush\u003ctag\u003e`: push the `\u003ctag\u003e` docker image to a docker repository\n   * `dockerTagsPush`: push all tagged docker images to a docker repository\n   * `dockerPrepare`: prepare to build a docker image by copying\n     dependent task outputs, referenced files, and `dockerfile` into a temporary\n     directory\n   * `dockerClean`: remove temporary directory associated with the docker build\n   * `dockerfileZip`: builds a ZIP file containing the configured Dockerfile\n * **Docker Compose**\n   * `generateDockerCompose`: Populates a docker-compose file template with image\n     versions declared by dependencies\n   * `dockerComposeUp`: Brings up services defined in `dockerComposeFile` in\n     detacted state\n   * `dockerComposeDown`: Stops services defined in `dockerComposeFile`\n * **Docker Run**\n   * `dockerRun`: run the specified image with the specified name\n   * `dockerStop`: stop the running container\n   * `dockerRunStatus`: indicate the run status of the container\n   * `dockerRemoveContainer`: remove the container\n\nLicense\n-------\nThis plugin is made available under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).\n\nContributing\n------------\nContributions to this project must follow the [contribution guide](CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalantir%2Fgradle-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpalantir%2Fgradle-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalantir%2Fgradle-docker/lists"}