├── testdata ├── bar ├── foo ├── test │ ├── test │ ├── py_image_using_layers.py │ ├── py_image_library_using_addict.py │ └── BUILD ├── baz ├── dockerfile_build │ ├── Data_file.txt │ ├── More_data.txt │ ├── file_to_copy.txt │ ├── Dockerfile │ └── BUILD ├── pause.tar ├── package.json ├── cc_image_wrapper.sh ├── nodejs_image.js ├── pause_piecemeal │ └── layers.bzl ├── cc_image_library.h ├── main.rs ├── py_image_library.py ├── main.d ├── Binary.groovy ├── cc_image.cc ├── py_image_library_using_six.py ├── cc_image_library.cc ├── ArgEcho.java ├── Binary.scala ├── py_image_complex.py ├── Binary.java ├── Library.groovy ├── Library.scala ├── Library.java ├── main.go ├── py_image_complex_library.py ├── py3_image.py ├── py_image.py ├── stamp_info.bzl ├── Runfiles.java ├── Servlet.java ├── launcher_main.go └── pause_piecemeal_gz │ └── BUILD ├── container ├── __init__.py ├── go │ ├── pkg │ │ ├── oci │ │ │ └── testdata │ │ │ │ ├── test_index1 │ │ │ │ ├── oci-layout │ │ │ │ ├── blobs │ │ │ │ │ └── sha256 │ │ │ │ │ │ ├── 26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 │ │ │ │ │ │ ├── 2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca │ │ │ │ │ │ ├── 3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af │ │ │ │ │ │ ├── 93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569 │ │ │ │ │ │ └── 4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46 │ │ │ │ └── index.json │ │ │ │ ├── test_index2 │ │ │ │ ├── oci-layout │ │ │ │ └── blobs │ │ │ │ │ └── sha256 │ │ │ │ │ ├── 26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 │ │ │ │ │ ├── 2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca │ │ │ │ │ ├── 3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af │ │ │ │ │ ├── 93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569 │ │ │ │ │ └── 4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46 │ │ │ │ ├── test_index3 │ │ │ │ ├── oci-layout │ │ │ │ ├── blobs │ │ │ │ │ └── sha256 │ │ │ │ │ │ ├── 26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 │ │ │ │ │ │ ├── 2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca │ │ │ │ │ │ ├── 3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af │ │ │ │ │ │ └── 93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569 │ │ │ │ └── index.json │ │ │ │ ├── test_index4 │ │ │ │ ├── oci-layout │ │ │ │ ├── blobs │ │ │ │ │ └── sha256 │ │ │ │ │ │ ├── 26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 │ │ │ │ │ │ ├── 2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca │ │ │ │ │ │ ├── 3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af │ │ │ │ │ │ └── 4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46 │ │ │ │ └── index.json │ │ │ │ └── test_index5 │ │ │ │ ├── oci-layout │ │ │ │ ├── blobs │ │ │ │ └── sha256 │ │ │ │ │ ├── 2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca │ │ │ │ │ ├── 3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af │ │ │ │ │ ├── 93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569 │ │ │ │ │ └── 4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46 │ │ │ │ └── index.json │ │ └── utils │ │ │ ├── BUILD │ │ │ └── utils.go │ └── cmd │ │ ├── flattener │ │ └── BUILD │ │ ├── join_layers │ │ └── BUILD │ │ ├── extract_config │ │ └── BUILD │ │ ├── digester │ │ └── BUILD │ │ └── loader │ │ └── BUILD ├── utils.py ├── push-tag.sh.tpl └── testenv.sh ├── testing ├── examples │ ├── BUILD │ ├── extended │ │ ├── image_data │ │ │ ├── Data_file.txt │ │ │ ├── More_data.txt │ │ │ ├── file_to_copy.txt │ │ │ └── BUILD │ │ ├── Dockerfile │ │ ├── test_configs │ │ │ └── BUILD │ │ └── cloudbuild.yaml │ ├── basic │ │ ├── Dockerfile │ │ ├── test_configs │ │ │ ├── basic_alpine.yaml │ │ │ └── BUILD │ │ ├── cloudbuild.yaml │ │ └── BUILD │ ├── java_app │ │ ├── test_configs │ │ │ ├── java_app_dockerfile.yaml │ │ │ ├── java_app_bazel.yaml │ │ │ └── BUILD │ │ ├── Dockerfile │ │ ├── image_data │ │ │ ├── Greeting.java │ │ │ └── ProjectRunner.java │ │ ├── cloudbuild.yaml │ │ └── BUILD │ ├── run_instruction_apt_pkgs │ │ ├── Dockerfile │ │ └── test_configs │ │ │ ├── BUILD │ │ │ └── java_python.yaml │ ├── run_instruction_arbitrary │ │ ├── test_configs │ │ │ ├── BUILD │ │ │ └── bazel_gcloud.yaml │ │ ├── Dockerfile │ │ └── cloudbuild.yaml │ ├── .bazelrc │ └── README.md ├── java_image │ ├── foo │ ├── cloudbuild.yaml │ ├── BUILD │ ├── WORKSPACE │ └── Runfiles.java ├── docker-config │ ├── htpasswd │ ├── config.json │ └── config.yml ├── custom_toolchain_auth │ ├── .gitignore │ └── BUILD ├── default_toolchain │ ├── .gitignore │ └── BUILD ├── download_pkgs_at_root │ ├── download_pkgs_at_root_run_test.sh │ ├── .bazelrc │ └── cloudbuild.yaml ├── e2e │ ├── test_top_level.yaml │ ├── test_launcher.yaml │ ├── test_nodejs_image.yaml │ ├── launcher.sh │ ├── test_py_image.yaml │ ├── nodejs_image.sh │ ├── test_go_image.yaml │ ├── test_groovy_image.yaml │ ├── test_scala_image.yaml │ ├── groovy_image.sh │ ├── scala_image.sh │ ├── test_docker_run_flags.yaml │ └── test_cc_image.yaml └── new_pusher_tests │ └── BUILD ├── CODEOWNERS ├── tests ├── container │ ├── configs │ │ ├── set_cmd.yaml │ │ ├── set_entrypoint.yaml │ │ ├── null_cmd_and_entrypoint.yaml │ │ ├── set_cmd_and_entrypoint.yaml │ │ ├── set_env_make_vars.yaml │ │ ├── set_env_csv.yaml │ │ ├── alpine_arm.yaml │ │ ├── alpine_amd64.yaml │ │ ├── alpine_ppc64le.yaml │ │ ├── stripped_directory_name.yaml │ │ ├── test.yaml │ │ ├── windows_image.yaml │ │ ├── special_characters.yaml │ │ ├── BUILD │ │ └── verify_new_pusher.yaml │ ├── rust │ │ ├── configs │ │ │ ├── rust_image.yaml │ │ │ └── BUILD │ │ └── BUILD │ ├── python │ │ ├── configs │ │ │ ├── py_image.yaml │ │ │ └── BUILD │ │ └── BUILD │ ├── python3 │ │ ├── configs │ │ │ ├── py3_image.yaml │ │ │ └── BUILD │ │ └── BUILD │ ├── go │ │ └── configs │ │ │ ├── go_image.yaml │ │ │ ├── go_static_image.yaml │ │ │ └── BUILD │ ├── nodejs │ │ └── configs │ │ │ ├── nodejs_image_custom_binary.yaml │ │ │ ├── nodejs_image.yaml │ │ │ ├── nodejs_image_no_args.yaml │ │ │ ├── nodejs_image_custom_binary_with_args.yaml │ │ │ ├── nodejs_image_none_args.yaml │ │ │ ├── nodejs_image_empty_list_args.yaml │ │ │ ├── nodejs_image_list_with_empty_string_args.yaml │ │ │ └── BUILD │ ├── java │ │ └── configs │ │ │ ├── java_partial_entrypoint.yaml │ │ │ ├── simple_java_entrypoint.yaml │ │ │ ├── BUILD │ │ │ ├── java_image.yaml │ │ │ └── java_runfiles_image.yaml │ ├── cc │ │ ├── configs │ │ │ ├── BUILD │ │ │ └── cc_image.yaml │ │ └── BUILD │ ├── groovy │ │ └── configs │ │ │ ├── BUILD │ │ │ └── groovy_image.yaml │ ├── scala │ │ └── configs │ │ │ ├── BUILD │ │ │ └── scala_image.yaml │ ├── windowsservercore.1803.manifest.json │ ├── empty_layers.bzl │ ├── apple.bzl │ ├── windowsservercore.1803.config.json │ └── build_tar_test.py ├── docker │ ├── util │ │ └── container_commit.yaml │ ├── package_managers │ │ ├── gpg_test.yaml │ │ ├── download_pkgs_with_additional_repos_run_test.sh │ │ ├── download_pkgs_run_test.sh │ │ └── test_complex_packages.yaml │ ├── BUILD │ ├── security │ │ └── cloudbuild.yaml │ └── toolchain_container │ │ └── tests.yaml ├── contrib │ ├── mv_project_root.sh │ ├── configs │ │ └── BUILD │ ├── automatic_container_release │ │ ├── BUILD │ │ └── deps_spec_no_fus_deps.yaml │ └── rename_image_test.sh └── BUILD ├── renovate.json ├── repositories ├── requirements-pip.txt ├── BUILD ├── images.bzl ├── deps.bzl └── pip_repositories.bzl ├── contrib ├── structure-test.sh.tpl ├── automatic_container_release │ └── BUILD ├── with-tag.bzl └── kaniko_run_and_extract.sh.tpl ├── .bazelignore ├── docker ├── security │ ├── security_check_whitelist.json │ └── BUILD ├── package_managers │ ├── installer.sh.tpl │ ├── run_download.sh.tpl │ ├── run_install.sh.tpl │ └── BUILD ├── util │ ├── extract.sh.tpl │ ├── image_util.sh │ ├── to_json.py │ ├── commit.sh.tpl │ └── BUILD ├── BUILD └── toolchain_container │ └── BUILD ├── AUTHORS ├── OWNERS ├── toolchains └── docker │ ├── pull.bzl.tpl │ └── BUILD.tpl ├── .gitignore ├── CONTRIBUTORS ├── cc ├── BUILD └── cc.bzl ├── d └── BUILD ├── go ├── BUILD ├── go.bzl └── static.bzl ├── java ├── BUILD ├── java.bzl └── jetty.bzl ├── oci ├── BUILD └── oci.bzl ├── rust └── BUILD ├── groovy └── BUILD ├── nodejs ├── BUILD └── nodejs.bzl ├── python3 ├── BUILD └── python3.bzl ├── scala └── BUILD ├── .travis.yml ├── tools └── BUILD ├── skylib ├── filetype.bzl ├── BUILD └── label.bzl ├── .bazelrc ├── lang └── BUILD ├── CONTRIBUTING.md ├── python └── python.bzl └── update_deps.sh /testdata/bar: -------------------------------------------------------------------------------- 1 | blah -------------------------------------------------------------------------------- /testdata/foo: -------------------------------------------------------------------------------- 1 | asdf -------------------------------------------------------------------------------- /testdata/test/test: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /container/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /testdata/baz: -------------------------------------------------------------------------------- 1 | blah 2 | -------------------------------------------------------------------------------- /testing/examples/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /testing/java_image/foo: -------------------------------------------------------------------------------- 1 | asdf -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @nlopezgi @smukherj1 @alex1545 2 | -------------------------------------------------------------------------------- /testdata/dockerfile_build/Data_file.txt: -------------------------------------------------------------------------------- 1 | Some data... 2 | -------------------------------------------------------------------------------- /testdata/dockerfile_build/More_data.txt: -------------------------------------------------------------------------------- 1 | Additional data -------------------------------------------------------------------------------- /testdata/dockerfile_build/file_to_copy.txt: -------------------------------------------------------------------------------- 1 | Another file to copy -------------------------------------------------------------------------------- /testing/examples/extended/image_data/Data_file.txt: -------------------------------------------------------------------------------- 1 | Some data... 2 | -------------------------------------------------------------------------------- /testing/examples/extended/image_data/More_data.txt: -------------------------------------------------------------------------------- 1 | Additional data -------------------------------------------------------------------------------- /testing/examples/extended/image_data/file_to_copy.txt: -------------------------------------------------------------------------------- 1 | Another file to copy -------------------------------------------------------------------------------- /testdata/pause.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/testdata/pause.tar -------------------------------------------------------------------------------- /testdata/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "jsesc": "2.5.2" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index1/oci-layout: -------------------------------------------------------------------------------- 1 | { 2 | "imageLayoutVersion": "1.0.0" 3 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index2/oci-layout: -------------------------------------------------------------------------------- 1 | { 2 | "imageLayoutVersion": "1.0.0" 3 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index3/oci-layout: -------------------------------------------------------------------------------- 1 | { 2 | "imageLayoutVersion": "1.0.0" 3 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index4/oci-layout: -------------------------------------------------------------------------------- 1 | { 2 | "imageLayoutVersion": "1.0.0" 3 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index5/oci-layout: -------------------------------------------------------------------------------- 1 | { 2 | "imageLayoutVersion": "1.0.0" 3 | } -------------------------------------------------------------------------------- /testing/examples/basic/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.8 2 | ENTRYPOINT ["echo"] 3 | CMD ["Hello World!"] 4 | -------------------------------------------------------------------------------- /tests/container/configs/set_cmd.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: ["foo"] 5 | -------------------------------------------------------------------------------- /testing/docker-config/htpasswd: -------------------------------------------------------------------------------- 1 | foo:$2y$05$a2SPoa9qOEpw41WkKOapo.6Lr4HIC0TfowpoYsS6FRtp5pqORB.vW 2 | 3 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "schedule": "at 7am on Monday" 6 | } 7 | -------------------------------------------------------------------------------- /testdata/cc_image_wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | "$1" || { echo "FAIL!"; exit 1; } 5 | -------------------------------------------------------------------------------- /tests/container/configs/set_entrypoint.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: ["bar"] 5 | -------------------------------------------------------------------------------- /testing/custom_toolchain_auth/.gitignore: -------------------------------------------------------------------------------- 1 | bazel-* 2 | 3 | # Automatically generated by e2e test driver 4 | def.bzl 5 | 6 | -------------------------------------------------------------------------------- /testing/default_toolchain/.gitignore: -------------------------------------------------------------------------------- 1 | bazel-* 2 | 3 | # Automatically generated by e2e test driver 4 | def.bzl 5 | 6 | -------------------------------------------------------------------------------- /tests/docker/util/container_commit.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: '2.0.0' 2 | metadataTest: 3 | cmd: ["/bin/sh", "-c", "/bin/bash"] 4 | -------------------------------------------------------------------------------- /testing/docker-config/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "auths": { 3 | "localhost:5000": { 4 | "auth": "Zm9vOmZvbw==" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /testdata/nodejs_image.js: -------------------------------------------------------------------------------- 1 | var jsesc = require('jsesc'); 2 | 3 | console.log(jsesc('Hello World!')); 4 | console.log(process.argv.slice(2)) 5 | -------------------------------------------------------------------------------- /tests/container/configs/null_cmd_and_entrypoint.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: Null 5 | cmd: Null 6 | -------------------------------------------------------------------------------- /tests/container/configs/set_cmd_and_entrypoint.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: ["foo"] 5 | entrypoint: ["bar"] 6 | -------------------------------------------------------------------------------- /tests/container/configs/set_env_make_vars.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | env: 5 | - key: my_key 6 | value: my_value 7 | -------------------------------------------------------------------------------- /testing/examples/basic/test_configs/basic_alpine.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: ['echo'] 5 | cmd: ['Hello World!'] 6 | -------------------------------------------------------------------------------- /tests/container/configs/set_env_csv.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | env: 5 | - key: NO_PROXY 6 | value: 127.0.0.1,localhost 7 | -------------------------------------------------------------------------------- /repositories/requirements-pip.txt: -------------------------------------------------------------------------------- 1 | # required by container_image py tests 2 | six==1.11.0 3 | addict==2.1.2 4 | # required by docker/security & deps 5 | PyYAML==5.1 6 | 7 | -------------------------------------------------------------------------------- /contrib/structure-test.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | %{load_statement} 6 | 7 | %{test_executable} version 8 | 9 | %{test_executable} %{args} 10 | -------------------------------------------------------------------------------- /testing/examples/java_app/test_configs/java_app_dockerfile.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: 5 | - "/bin/bash" 6 | - "-c" 7 | - "java ProjectRunner" 8 | -------------------------------------------------------------------------------- /tests/container/configs/alpine_arm.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | fileContentTests: 4 | - name: "validate apk arch file" 5 | path: "/etc/apk/arch" 6 | expectedContents: ["armhf"] 7 | -------------------------------------------------------------------------------- /tests/container/configs/alpine_amd64.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | fileContentTests: 4 | - name: "validate apk arch file" 5 | path: "/etc/apk/arch" 6 | expectedContents: ["x86_64"] 7 | -------------------------------------------------------------------------------- /tests/container/configs/alpine_ppc64le.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | fileContentTests: 4 | - name: "validate apk arch file" 5 | path: "/etc/apk/arch" 6 | expectedContents: ["ppc64le"] 7 | -------------------------------------------------------------------------------- /tests/container/configs/stripped_directory_name.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: '2.0.0' 2 | fileExistenceTests: 3 | - name: Output file that is placed in directory structure 4 | path: /pear/grape 5 | shouldExist: true 6 | -------------------------------------------------------------------------------- /.bazelignore: -------------------------------------------------------------------------------- 1 | # Disable targets that are part of an embedded bazel project as buildkite 2 | # only recognizes a single top level WORKSPACE file. 3 | testing/examples 4 | testing/java_image 5 | testing/download_pkgs_at_root 6 | -------------------------------------------------------------------------------- /docker/security/security_check_whitelist.json: -------------------------------------------------------------------------------- 1 | [ 2 | "projects/goog-vulnz/notes/CVE-2012-1148", 3 | "projects/goog-vulnz/notes/CVE-2012-0876", 4 | "projects/goog-vulnz/notes/CVE-2016-8568", 5 | "projects/goog-vulnz/notes/CVE-2016-8569" 6 | ] 7 | 8 | -------------------------------------------------------------------------------- /testing/examples/run_instruction_apt_pkgs/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM l.gcr.io/google/ubuntu1604:latest 2 | 3 | RUN \ 4 | apt-get update && \ 5 | apt-get install -y openjdk-8-jdk python python3 python-dev python-pip python3-pip && \ 6 | rm -rf /var/lib/apt/lists/* 7 | -------------------------------------------------------------------------------- /tests/container/rust/configs/rust_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: ['/app/tests/container/rust/rust_image_binary'] 5 | cmd: [ 6 | 'arg0', 7 | 'arg1', 8 | 'tests/container/rust/BUILD', 9 | ] 10 | -------------------------------------------------------------------------------- /tests/contrib/mv_project_root.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | # Move contents to a subdirectory so that output base can be set to 6 | # /workspace/output_base 7 | mkdir rules_docker 8 | mv * rules_docker || true 9 | mv .bazelrc rules_docker 10 | -------------------------------------------------------------------------------- /testdata/pause_piecemeal/layers.bzl: -------------------------------------------------------------------------------- 1 | """Defines shas for layers used in tests.""" 2 | 3 | PAUSE_LAYERS = [ 4 | "9285c41a2f85a67c85185be04743004e806fd1e16777f2230166281f4e49cb4c", 5 | "da7bd81140ca921a067c604a3ba3f54d4e0d51ba5276cd9f32ad6a28e588f470", 6 | ] 7 | -------------------------------------------------------------------------------- /tests/container/configs/test.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | fileExistenceTests: 4 | - name: "foo" 5 | path: "/foo" 6 | shouldExist: true 7 | 8 | fileContentTests: 9 | - name: "foo" 10 | path: "/foo" 11 | expectedContents: ["asdf$"] 12 | -------------------------------------------------------------------------------- /testing/docker-config/config.yml: -------------------------------------------------------------------------------- 1 | version: 0.1 2 | storage: 3 | filesystem: 4 | rootdirectory: /var/lib/registry 5 | maxthreads: 12 6 | http: 7 | addr: :5000 8 | secret: foo 9 | auth: 10 | htpasswd: 11 | realm: basic-realm 12 | path: /.htpasswd 13 | -------------------------------------------------------------------------------- /tests/docker/package_managers/gpg_test.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: '2.0.0' 2 | commandTests: 3 | - name: 'gpg' 4 | setup: [["apt-get", "update"], ["apt-get", "install", "-y", "-q", "gnupg"]] 5 | command: 'apt-key' 6 | args: ['list'] 7 | expectedOutput: ['Bazel APT repository key'] 8 | -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index1/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index1/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index1/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index1/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index1/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index1/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index2/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index2/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index2/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index2/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index2/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index2/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index3/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index3/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index3/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index3/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index3/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index3/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index4/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index4/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index4/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index4/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index4/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index4/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index5/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index5/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index5/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i/rules_docker/master/container/go/pkg/oci/testdata/test_index5/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af -------------------------------------------------------------------------------- /container/go/pkg/utils/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["utils.go"], 6 | importpath = "github.com/bazelbuild/rules_docker/container/go/pkg/utils", 7 | visibility = ["//visibility:public"], 8 | ) 9 | -------------------------------------------------------------------------------- /tests/container/python/configs/py_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: [ 5 | '/usr/bin/python', 6 | '/app/tests/container/python/py_image.binary', 7 | ] 8 | cmd: [ 9 | 'arg0', 10 | 'arg1', 11 | 'tests/container/python/BUILD', 12 | ] 13 | -------------------------------------------------------------------------------- /tests/container/python3/configs/py3_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: [ 5 | '/usr/bin/python', 6 | '/app/tests/container/python3/py3_image.binary', 7 | ] 8 | cmd: [ 9 | 'arg0', 10 | 'arg1', 11 | 'tests/container/python3/BUILD', 12 | ] 13 | -------------------------------------------------------------------------------- /testing/examples/java_app/test_configs/java_app_bazel.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: 5 | - "/usr/bin/java" 6 | - "-cp" 7 | - "/app/dockerfile_examples/java_app/java_app_bazel.binary.jar:/app/dockerfile_examples/java_app/java_app_bazel.binary" 8 | - "ProjectRunner" 9 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This the official list of Bazel authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as: 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | Google Inc. 10 | -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index1/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 2, 3 | "manifests": [ 4 | { 5 | "mediaType": "application/vnd.docker.distribution.manifest.v2+json", 6 | "size": 772, 7 | "digest": "sha256:4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46" 8 | } 9 | ] 10 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index3/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 2, 3 | "manifests": [ 4 | { 5 | "mediaType": "application/vnd.docker.distribution.manifest.v2+json", 6 | "size": 772, 7 | "digest": "sha256:4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46" 8 | } 9 | ] 10 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index4/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 2, 3 | "manifests": [ 4 | { 5 | "mediaType": "application/vnd.docker.distribution.manifest.v2+json", 6 | "size": 772, 7 | "digest": "sha256:4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46" 8 | } 9 | ] 10 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index5/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 2, 3 | "manifests": [ 4 | { 5 | "mediaType": "application/vnd.docker.distribution.manifest.v2+json", 6 | "size": 772, 7 | "digest": "sha256:4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46" 8 | } 9 | ] 10 | } -------------------------------------------------------------------------------- /tests/container/configs/windows_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | fileExistenceTests: 4 | - name: 'Files' 5 | path: '/' 6 | shouldExist: true 7 | permissions: 'drwx------' 8 | 9 | - name: 'Hives' 10 | path: '/' 11 | shouldExist: true 12 | permissions: 'drwx------' 13 | 14 | metadataTest: 15 | cmd: ["echo bar"] 16 | 17 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | # See Config struct in https://github.com/kubernetes/test-infra/blob/master/prow/repoowners/repoowners.go 2 | 3 | # Reviewers may be auto-assigned by blunderbuss 4 | reviewers: 5 | - nlopezgi 6 | - smukherj1 7 | - alex1545 8 | 9 | # Approvers can /approve changes to files within this directory tree. 10 | approvers: 11 | - nlopezgi 12 | - smukherj1 13 | - alex1545 14 | -------------------------------------------------------------------------------- /tests/docker/package_managers/download_pkgs_with_additional_repos_run_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | BASEDIR=$(dirname "$0") 5 | 6 | EXIT_CODE=0 7 | 8 | if tar -tvf "$BASEDIR/test_download_pkgs_with_additional_repos.tar" | grep "bazel"; then 9 | echo "bazel found" 10 | else 11 | echo "bazel not found" 12 | EXIT_CODE=1 13 | fi 14 | 15 | exit "$EXIT_CODE" 16 | -------------------------------------------------------------------------------- /docker/package_managers/installer.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script installs debs in installables.tar through dpkg and apt-get. 3 | # It expects to be volume-mounted inside a docker image, in /tmp along with the 4 | # installables.tar. 5 | set -ex 6 | pushd /tmp 7 | %{install_commands} 8 | popd 9 | umount -l /tmp/installer.sh 10 | umount -l /tmp/%{installables_tar} 11 | rm -rf /tmp/* 12 | -------------------------------------------------------------------------------- /testdata/test/py_image_using_layers.py: -------------------------------------------------------------------------------- 1 | """Ensure the "six" module can be imported. 2 | 3 | Used to end to end test python dependencies to py_image work when specified 4 | as layers. https://github.com/bazelbuild/rules_docker/issues/161 5 | """ 6 | 7 | import six 8 | 9 | if __name__ == "__main__": 10 | print("Successfully imported {} {}.".format(six.__name__, six.__version__)) 11 | -------------------------------------------------------------------------------- /testing/examples/java_app/Dockerfile: -------------------------------------------------------------------------------- 1 | # Simple Dockerfile that creates an image to act as a java executable given the 2 | # required source files. It copies the source files and compiles them inside 3 | # the image. 4 | FROM openjdk 5 | 6 | WORKDIR /java_app 7 | 8 | COPY image_data/*.java ./ 9 | 10 | RUN javac Greeting.java ProjectRunner.java 11 | 12 | ENTRYPOINT ["/bin/bash", "-c", "java ProjectRunner"] 13 | -------------------------------------------------------------------------------- /testing/examples/extended/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.8 2 | ENV envVar My environment variable 3 | ENV xyz=321 4 | ENTRYPOINT ["echo", "Hello"] 5 | CMD ["World"] 6 | ADD image_data/Data_file.txt / 7 | ADD image_data/More_data.txt /usr 8 | ADD image_data/tarfile.tar / 9 | COPY image_data/file_to_copy.txt / 10 | LABEL version="7.7" \ 11 | desc="Description for version 7.7" 12 | EXPOSE 8080/tcp 13 | EXPOSE 9876/udp 14 | VOLUME /myVol1 /usr/myVol2 15 | -------------------------------------------------------------------------------- /tests/container/go/configs/go_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: ['/app/tests/container/go/go_image.binary'] 5 | cmd: [ 6 | 'arg0', 7 | 'arg1', 8 | 'tests/container/go/BUILD', 9 | ] 10 | 11 | # File info taken from https://github.com/GoogleContainerTools/distroless/tree/master/base 12 | 13 | fileExistenceTests: 14 | - name: "openssl" 15 | path: "/usr/bin/openssl" 16 | shouldExist: true 17 | 18 | -------------------------------------------------------------------------------- /testdata/dockerfile_build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ALPINE_version 2 | 3 | FROM alpine:${ALPINE_version} 4 | ENTRYPOINT ["echo"] 5 | CMD ["Hello World!"] 6 | 7 | ENV envVar My environment variable 8 | ENV xyz=321 9 | ADD Data_file.txt / 10 | ADD More_data.txt /usr/ 11 | COPY file_to_copy.txt / 12 | LABEL version="7.7" \ 13 | desc="Description for version 7.7" 14 | EXPOSE 8080/tcp 15 | EXPOSE 9876/udp 16 | VOLUME /myVol1 /usr/myVol2 17 | 18 | RUN apk add gcc python2 19 | -------------------------------------------------------------------------------- /tests/container/go/configs/go_static_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: ['/app/tests/container/go/go_static_image.binary'] 5 | cmd: [ 6 | 'arg0', 7 | 'arg1', 8 | 'tests/container/go/BUILD', 9 | ] 10 | 11 | # File info taken from https://github.com/GoogleContainerTools/distroless/tree/master/base 12 | 13 | fileExistenceTests: 14 | - name: "openssl" 15 | path: "/usr/bin/openssl" 16 | shouldExist: false 17 | 18 | -------------------------------------------------------------------------------- /tests/container/nodejs/configs/nodejs_image_custom_binary.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: Null 5 | env: 6 | - key: PORT 7 | value: "8080" 8 | - key: DEBIAN_FRONTEND 9 | value: "noninteractive" 10 | - key: PATH 11 | value: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 12 | entrypoint: ['/app/tests/container/nodejs/my_custom_binary'] 13 | workdir: "/app/tests/container/nodejs/my_custom_binary.runfiles/io_bazel_rules_docker" 14 | -------------------------------------------------------------------------------- /tests/container/nodejs/configs/nodejs_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: ["arg0", "arg1"] 5 | env: 6 | - key: PORT 7 | value: "8080" 8 | - key: DEBIAN_FRONTEND 9 | value: "noninteractive" 10 | - key: PATH 11 | value: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 12 | entrypoint: ['/app/tests/container/nodejs/nodejs_image.binary'] 13 | workdir: "/app/tests/container/nodejs/nodejs_image.binary.runfiles/io_bazel_rules_docker" 14 | -------------------------------------------------------------------------------- /tests/docker/package_managers/download_pkgs_run_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | BASEDIR=$(dirname "$0") 5 | 6 | EXIT_CODE=0 7 | 8 | if tar -tvf "$BASEDIR/test_download_pkgs.tar" | grep "netbase"; then 9 | echo "Netbase found" 10 | else 11 | echo "Netbase not found" 12 | EXIT_CODE=1 13 | fi 14 | 15 | if tar -tvf "$BASEDIR/test_download_pkgs.tar" | grep "curl"; then 16 | echo "curl found" 17 | else 18 | echo "curl not found" 19 | EXIT_CODE=1 20 | fi 21 | 22 | exit "$EXIT_CODE" 23 | -------------------------------------------------------------------------------- /tests/container/nodejs/configs/nodejs_image_no_args.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: Null 5 | env: 6 | - key: PORT 7 | value: "8080" 8 | - key: DEBIAN_FRONTEND 9 | value: "noninteractive" 10 | - key: PATH 11 | value: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 12 | entrypoint: ['/app/tests/container/nodejs/nodejs_image_no_args.binary'] 13 | workdir: "/app/tests/container/nodejs/nodejs_image_no_args.binary.runfiles/io_bazel_rules_docker" 14 | -------------------------------------------------------------------------------- /tests/container/nodejs/configs/nodejs_image_custom_binary_with_args.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: ["arg0", "arg1"] 5 | env: 6 | - key: PORT 7 | value: "8080" 8 | - key: DEBIAN_FRONTEND 9 | value: "noninteractive" 10 | - key: PATH 11 | value: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 12 | entrypoint: ['/app/tests/container/nodejs/my_custom_binary'] 13 | workdir: "/app/tests/container/nodejs/my_custom_binary.runfiles/io_bazel_rules_docker" 14 | -------------------------------------------------------------------------------- /tests/container/nodejs/configs/nodejs_image_none_args.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: Null 5 | env: 6 | - key: PORT 7 | value: "8080" 8 | - key: DEBIAN_FRONTEND 9 | value: "noninteractive" 10 | - key: PATH 11 | value: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 12 | entrypoint: ['/app/tests/container/nodejs/nodejs_image_none_args.binary'] 13 | workdir: "/app/tests/container/nodejs/nodejs_image_none_args.binary.runfiles/io_bazel_rules_docker" 14 | -------------------------------------------------------------------------------- /testing/download_pkgs_at_root/download_pkgs_at_root_run_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | BASEDIR=$(dirname "$0") 5 | 6 | EXIT_CODE=0 7 | 8 | if tar -tvf "$BASEDIR/test_download_pkgs_at_root.tar" | grep "netbase"; then 9 | echo "Netbase found" 10 | else 11 | echo "Netbase not found" 12 | EXIT_CODE=1 13 | fi 14 | 15 | if tar -tvf "$BASEDIR/test_download_pkgs_at_root.tar" | grep "curl"; then 16 | echo "curl found" 17 | else 18 | echo "curl not found" 19 | EXIT_CODE=1 20 | fi 21 | 22 | exit "$EXIT_CODE" 23 | -------------------------------------------------------------------------------- /toolchains/docker/pull.bzl.tpl: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_docker//container:pull.bzl", 2 | _container_pull="container_pull") 3 | 4 | # Call container_pull with the docker client config directory set. 5 | def container_pull(**kwargs): 6 | if "docker_client_config" in kwargs: 7 | fail("docker_client_config attribute should not be set on the container_pull created by the custom docker toolchain configuration") 8 | _container_pull( 9 | docker_client_config="%{docker_client_config}", 10 | **kwargs 11 | ) 12 | -------------------------------------------------------------------------------- /tests/container/nodejs/configs/nodejs_image_empty_list_args.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: Null 5 | env: 6 | - key: PORT 7 | value: "8080" 8 | - key: DEBIAN_FRONTEND 9 | value: "noninteractive" 10 | - key: PATH 11 | value: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 12 | entrypoint: ['/app/tests/container/nodejs/nodejs_image_empty_list_args.binary'] 13 | workdir: "/app/tests/container/nodejs/nodejs_image_empty_list_args.binary.runfiles/io_bazel_rules_docker" 14 | -------------------------------------------------------------------------------- /tests/container/nodejs/configs/nodejs_image_list_with_empty_string_args.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: [""] 5 | env: 6 | - key: PORT 7 | value: "8080" 8 | - key: DEBIAN_FRONTEND 9 | value: "noninteractive" 10 | - key: PATH 11 | value: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 12 | entrypoint: ['/app/tests/container/nodejs/nodejs_image_list_with_empty_string_args.binary'] 13 | workdir: "/app/tests/container/nodejs/nodejs_image_list_with_empty_string_args.binary.runfiles/io_bazel_rules_docker" 14 | -------------------------------------------------------------------------------- /docker/util/extract.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | # Resolve the docker tool path 6 | DOCKER="%{docker_tool_path}" 7 | 8 | if [[ -z "$DOCKER" ]]; then 9 | echo >&2 "error: docker not found; do you need to manually configure the docker toolchain?" 10 | exit 1 11 | fi 12 | 13 | # Load the image and remember its name 14 | image_id=$(%{image_id_extractor_path} %{image_tar}) 15 | $DOCKER load -i %{image_tar} 16 | 17 | id=$($DOCKER run -d %{docker_run_flags} $image_id %{commands}) 18 | 19 | $DOCKER wait $id 20 | $DOCKER cp $id:%{extract_file} %{output} 21 | $DOCKER rm $id 22 | -------------------------------------------------------------------------------- /tests/container/configs/special_characters.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | fileContentTests: 4 | - name: "special characters can be used in files" 5 | path: "/root= dir/gen= foo.out" 6 | expectedContents: ["generated"] 7 | - name: "special characters can be used in symlinks" 8 | path: "/foo= symlink" 9 | expectedContents: ["generated"] 10 | 11 | fileExistenceTests: 12 | - name: "special characters can be used in emptyfiles" 13 | path: '/empty= file' 14 | shouldExist: true 15 | - name: "special characters can be used in emptydirs" 16 | path: '/empty= dir' 17 | shouldExist: true 18 | -------------------------------------------------------------------------------- /tests/container/java/configs/java_partial_entrypoint.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | env: 5 | - key: JAVA_RUNFILES 6 | value: "/app" 7 | entrypoint: 8 | - "/usr/bin/java" 9 | - "-cp" 10 | - "/app/io_bazel_rules_docker/tests/container/java/libjava_bin_as_lib.jar:/app/io_bazel_rules_docker/tests/container/java/libjava_image_library.jar:/app/io_bazel_rules_docker/../com_google_guava_guava/guava-18.0.jar:/app/io_bazel_rules_docker/tests/container/java/java_partial_entrypoint_image.binary.jar:/app/io_bazel_rules_docker/tests/container/java/java_partial_entrypoint_image.binary" 11 | -------------------------------------------------------------------------------- /tests/container/java/configs/simple_java_entrypoint.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | env: 5 | - key: JAVA_RUNFILES 6 | value: "/app" 7 | entrypoint: 8 | - "/usr/bin/java" 9 | - "-cp" 10 | - "/app/io_bazel_rules_docker/tests/container/java/libjava_bin_as_lib.jar:/app/io_bazel_rules_docker/tests/container/java/libjava_image_library.jar:/app/io_bazel_rules_docker/../com_google_guava_guava/guava-18.0.jar:/app/io_bazel_rules_docker/tests/container/java/simple_java_image.binary.jar:/app/io_bazel_rules_docker/tests/container/java/simple_java_image.binary" 11 | - "examples.images.Binary" 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | *.smod 19 | 20 | # Python 2 bytecode files 21 | *.pyc 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Emacs garbage 35 | *~ 36 | 37 | # Vim garbage 38 | *.swp 39 | 40 | # Bazel directories 41 | bazel-* 42 | bazel-bin 43 | bazel-genfiles 44 | bazel-out 45 | bazel-testlogs 46 | 47 | # Eclipse and PyDev 48 | .project 49 | .pydevproject 50 | -------------------------------------------------------------------------------- /container/go/cmd/flattener/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["flattener.go"], 6 | importpath = "github.com/bazelbuild/rules_docker/container/go/cmd/flattener", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//container/go/pkg/compat:go_default_library", 10 | "//container/go/pkg/utils:go_default_library", 11 | "@com_github_google_go_containerregistry//pkg/v1/mutate:go_default_library", 12 | ], 13 | ) 14 | 15 | go_binary( 16 | name = "flattener", 17 | embed = [":go_default_library"], 18 | visibility = ["//visibility:public"], 19 | ) 20 | -------------------------------------------------------------------------------- /docker/util/image_util.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | reset_cmd() { 4 | local original_image_name=$1 5 | local container_id=$2 6 | local output_image_name=$3 7 | 8 | local old_cmd 9 | # docker inspect input cannot be piped into docker commit directly, we need to JSON format it. 10 | old_cmd=$(docker inspect -f "{{range .Config.Cmd}}{{.}} {{end}}" "${original_image_name}") 11 | fmt_cmd=$(echo "$old_cmd" | ${TO_JSON_TOOL}) 12 | # If CMD wasn't set, set it to a sane default. 13 | if [ "$fmt_cmd" == "" ] || [ "$fmt_cmd" == "[]" ]; 14 | then 15 | fmt_cmd='["/bin/sh", "-c"]' 16 | fi 17 | 18 | docker commit -c "CMD $fmt_cmd" "${container_id}" "${output_image_name}" 19 | } 20 | -------------------------------------------------------------------------------- /testdata/cc_image_library.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | void SayHello(); 16 | -------------------------------------------------------------------------------- /testdata/dockerfile_build/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*"])) 16 | -------------------------------------------------------------------------------- /tests/contrib/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /tests/container/cc/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /tests/container/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /tests/container/go/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /testing/default_toolchain/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Placeholder top level BUILD file 16 | -------------------------------------------------------------------------------- /testing/examples/extended/image_data/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*"])) 16 | -------------------------------------------------------------------------------- /tests/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | -------------------------------------------------------------------------------- /tests/container/groovy/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /tests/container/java/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /tests/container/nodejs/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /tests/container/python/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /tests/container/python3/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /tests/container/rust/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /tests/container/scala/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /testing/custom_toolchain_auth/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Placeholder top level BUILD file 16 | -------------------------------------------------------------------------------- /testing/examples/basic/test_configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /testdata/main.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | fn main() { 16 | println!("Hello world"); 17 | } -------------------------------------------------------------------------------- /testing/examples/extended/test_configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /testing/examples/java_app/test_configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # People who have agreed to one of the CLAs and can contribute patches. 2 | # The AUTHORS file lists the copyright holders; this file 3 | # lists people. For example, Google employees are listed here 4 | # but not in AUTHORS, because Google holds the copyright. 5 | # 6 | # https://developers.google.com/open-source/cla/individual 7 | # https://developers.google.com/open-source/cla/corporate 8 | # 9 | # Names should be added to this file as: 10 | # Name 11 | 12 | Matthew Moore 13 | Nathan Herring 14 | Nicolas Lopez 15 | Oleksandr Mogilevskyi 16 | Suvanjan Mukherjee 17 | Xin Gao 18 | -------------------------------------------------------------------------------- /tests/docker/package_managers/test_complex_packages.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: 'l.gcr.io/google/bazel' 3 | entrypoint: ./tests/docker/package_managers/test_complex_packages.sh 4 | args: [setup] 5 | 6 | - name: 'l.gcr.io/google/bazel' 7 | entrypoint: ./tests/docker/package_managers/test_complex_packages.sh 8 | args: [run_download_pkgs] 9 | dir: 'rules_docker' 10 | 11 | - name: 'l.gcr.io/google/bazel' 12 | entrypoint: ./tests/docker/package_managers/test_complex_packages.sh 13 | args: [run_install_pkgs] 14 | dir: 'rules_docker' 15 | 16 | - name: 'l.gcr.io/google/bazel' 17 | entrypoint: ./tests/docker/package_managers/test_complex_packages.sh 18 | args: [run_build_dockerfile_and_compare] 19 | dir: 'rules_docker' 20 | 21 | -------------------------------------------------------------------------------- /docker/package_managers/run_download.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | # Resolve the docker tool path 5 | DOCKER="%{docker_tool_path}" 6 | 7 | if [[ -z "$DOCKER" ]]; then 8 | echo >&2 "error: docker not found; do you need to manually configure the docker toolchain?" 9 | exit 1 10 | fi 11 | 12 | # Load the image and remember its name 13 | image_id=$(%{image_id_extractor_path} %{image_tar}) 14 | $DOCKER load -i %{image_tar} 15 | 16 | # Run the builder image. 17 | cid=$($DOCKER run -w="/" -d --privileged $image_id sh -c $'%{download_commands}') 18 | $DOCKER attach $cid 19 | $DOCKER cp $cid:%{installables}_packages.tar %{output} 20 | $DOCKER cp $cid:%{installables}_metadata.csv %{output_metadata} 21 | # Cleanup 22 | $DOCKER rm $cid 23 | -------------------------------------------------------------------------------- /testdata/py_image_library.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | def fn(what_comes_in): 17 | return what_comes_in + 3 18 | -------------------------------------------------------------------------------- /testing/examples/run_instruction_apt_pkgs/test_configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /testing/examples/run_instruction_arbitrary/test_configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(glob(["*.yaml"])) 16 | -------------------------------------------------------------------------------- /testdata/main.d: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | import std.stdio; 15 | 16 | void main() { 17 | writeln("Hello world"); 18 | } -------------------------------------------------------------------------------- /cc/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index1/blobs/sha256/93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569: -------------------------------------------------------------------------------- 1 | {"architecture": "amd64", "author": "Bazel", "config": {}, "created": "1970-01-01T00:00:00Z", "history": [{"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}, {"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}, {"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}], "os": "linux", "rootfs": {"diff_ids": ["sha256:cfebe149e813482640cd5509f6c866bd83709a56aaa82bda6b05d633bd571591", "sha256:7bb7138798ce1c3019d6e2f306296ef3712a6ebd52368bf8ee3a2c97a6ffda41", "sha256:f2cc51d9aa9896cb1491b84be069511dccbe7140284c363c2223770aec9fcb74"], "type": "layers"}} 2 | -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index2/blobs/sha256/93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569: -------------------------------------------------------------------------------- 1 | {"architecture": "amd64", "author": "Bazel", "config": {}, "created": "1970-01-01T00:00:00Z", "history": [{"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}, {"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}, {"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}], "os": "linux", "rootfs": {"diff_ids": ["sha256:cfebe149e813482640cd5509f6c866bd83709a56aaa82bda6b05d633bd571591", "sha256:7bb7138798ce1c3019d6e2f306296ef3712a6ebd52368bf8ee3a2c97a6ffda41", "sha256:f2cc51d9aa9896cb1491b84be069511dccbe7140284c363c2223770aec9fcb74"], "type": "layers"}} 2 | -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index3/blobs/sha256/93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569: -------------------------------------------------------------------------------- 1 | {"architecture": "amd64", "author": "Bazel", "config": {}, "created": "1970-01-01T00:00:00Z", "history": [{"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}, {"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}, {"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}], "os": "linux", "rootfs": {"diff_ids": ["sha256:cfebe149e813482640cd5509f6c866bd83709a56aaa82bda6b05d633bd571591", "sha256:7bb7138798ce1c3019d6e2f306296ef3712a6ebd52368bf8ee3a2c97a6ffda41", "sha256:f2cc51d9aa9896cb1491b84be069511dccbe7140284c363c2223770aec9fcb74"], "type": "layers"}} 2 | -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index5/blobs/sha256/93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569: -------------------------------------------------------------------------------- 1 | {"architecture": "amd64", "author": "Bazel", "config": {}, "created": "1970-01-01T00:00:00Z", "history": [{"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}, {"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}, {"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}], "os": "linux", "rootfs": {"diff_ids": ["sha256:cfebe149e813482640cd5509f6c866bd83709a56aaa82bda6b05d633bd571591", "sha256:7bb7138798ce1c3019d6e2f306296ef3712a6ebd52368bf8ee3a2c97a6ffda41", "sha256:f2cc51d9aa9896cb1491b84be069511dccbe7140284c363c2223770aec9fcb74"], "type": "layers"}} 2 | -------------------------------------------------------------------------------- /d/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /go/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /java/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /oci/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /rust/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /groovy/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /nodejs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /python3/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /scala/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /repositories/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /tests/docker/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) # Apache 2.0 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | sudo: required 3 | 4 | os: 5 | - linux 6 | 7 | python: 8 | - "2.7" 9 | 10 | jdk: 11 | - oraclejdk8 # Building Bazel requires JDK8. 12 | 13 | language: go 14 | go: 1.10.x 15 | install: true 16 | 17 | services: 18 | - docker 19 | 20 | addons: 21 | apt: 22 | sources: 23 | - sourceline: 'deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8' 24 | key_url: 'https://bazel.build/bazel-release.pub.gpg' 25 | packages: 26 | - bazel 27 | 28 | install: 29 | - wget -q https://github.com/bazelbuild/buildtools/releases/download/0.22.0/buildifier 30 | - chmod +x ./buildifier 31 | 32 | script: 33 | # Test things by executing the various build configurations under testing/ 34 | - ./testing/e2e.sh 35 | -------------------------------------------------------------------------------- /testing/examples/.bazelrc: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | build --host_force_python=PY2 16 | test --host_force_python=PY2 17 | run --host_force_python=PY2 18 | -------------------------------------------------------------------------------- /tests/container/java/configs/java_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | env: 5 | - key: JAVA_RUNFILES 6 | value: "/app" 7 | entrypoint: [ 8 | '/usr/bin/java', 9 | '-cp', 10 | '/app/io_bazel_rules_docker/tests/container/java/libjava_image_library.jar:/app/io_bazel_rules_docker/../com_google_guava_guava/guava-18.0.jar:/app/io_bazel_rules_docker/tests/container/java/java_image.binary.jar:/app/io_bazel_rules_docker/tests/container/java/java_image.binary:/app/io_bazel_rules_docker/tests/container/java/BUILD', 11 | '-XX:MaxPermSize=128M', 12 | '-Dbuild.location=tests/container/java/BUILD', 13 | 'examples.images.Binary', 14 | 'arg0', 15 | 'arg1', 16 | 'tests/container/java/BUILD'] 17 | -------------------------------------------------------------------------------- /testdata/Binary.groovy: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples.images 16 | 17 | import examples.Library 18 | 19 | println(Library.SayHello()) 20 | -------------------------------------------------------------------------------- /docker/util/to_json.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2017 The Bazel Authors. All rights reserved. 4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | import json 18 | import sys 19 | 20 | print json.dumps(sys.stdin.read().strip().split()) 21 | -------------------------------------------------------------------------------- /testdata/cc_image.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "testdata/cc_image_library.h" 16 | 17 | int main() { 18 | SayHello(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /testing/download_pkgs_at_root/.bazelrc: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | build --host_force_python=PY2 16 | test --host_force_python=PY2 17 | run --host_force_python=PY2 18 | -------------------------------------------------------------------------------- /testdata/py_image_library_using_six.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import six 16 | 17 | def fn(what_comes_in): 18 | return what_comes_in + "Six version: " + six.__version__ 19 | -------------------------------------------------------------------------------- /testdata/test/py_image_library_using_addict.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import addict 16 | 17 | def fn(what_comes_in): 18 | return what_comes_in + "Addict version: " + addict.__version__ 19 | -------------------------------------------------------------------------------- /testing/examples/java_app/image_data/Greeting.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | public class Greeting { 16 | public static void sayHi() { 17 | System.out.println("Hi!"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /contrib/automatic_container_release/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:public"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | 18 | exports_files(["run_checker.sh.tpl"]) 19 | -------------------------------------------------------------------------------- /testing/examples/java_app/image_data/ProjectRunner.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | public class ProjectRunner { 16 | public static void main(String args[]) { 17 | Greeting.sayHi(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testing/examples/run_instruction_apt_pkgs/test_configs/java_python.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | commandTests: 4 | - name: "java_test" 5 | command: "java" 6 | args: ["-version"] 7 | expectedError: ["openjdk version \"1\\.8\\..*"] 8 | - name: "javac_test" 9 | command: "javac" 10 | args: ["-version"] 11 | expectedError: ["javac 1\\.8\\..*"] 12 | - name: "python2_test" 13 | command: "python" 14 | args: ["-V"] 15 | expectedError: ["Python 2\\..*"] 16 | - name: "python3_test" 17 | command: "python3" 18 | args: ["-V"] 19 | expectedOutput: ["Python 3\\..*"] 20 | - name: "pip_test" 21 | command: "pip" 22 | args: ["-V"] 23 | expectedOutput: ["pip \\d+\\..*"] 24 | - name: "pip3_test" 25 | command: "pip3" 26 | args: ["-V"] 27 | expectedOutput: ["pip \\d+\\..*"] 28 | -------------------------------------------------------------------------------- /testing/examples/run_instruction_arbitrary/test_configs/bazel_gcloud.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | commandTests: 4 | - name: "bazel_test" 5 | command: "bazel" 6 | args: ["version"] 7 | expectedError: ["Extracting Bazel installation.*"] 8 | expectedOutput: ["Build label: \\d+\\.\\d+.*"] 9 | - name: "gcloud_test" 10 | command: "gcloud" 11 | args: ["version"] 12 | expectedOutput: ["Google Cloud SDK \\d+\\..*"] 13 | - name: "kubectl_test" 14 | command: "kubectl" 15 | args: ["--help"] 16 | expectedOutput: ["kubectl controls the Kubernetes cluster manager.*"] 17 | - name: "pip_test" 18 | command: "pip" 19 | args: ["-V"] 20 | expectedOutput: ["pip \\d+.*"] 21 | - name: "wheel_test" 22 | command: "wheel" 23 | args: ["version"] 24 | expectedOutput: ["wheel \\d+.*"] 25 | -------------------------------------------------------------------------------- /tests/container/cc/configs/cc_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: ['/app/tests/container/cc/cc_image.binary'] 5 | cmd: [ 6 | 'arg0', 7 | 'arg1', 8 | 'tests/container/cc/BUILD', 9 | ] 10 | 11 | fileExistenceTests: 12 | - name: 'cc_image.binary' 13 | path: './app/tests/container/cc/cc_image.binary.runfiles/io_bazel_rules_docker/tests/container/cc/cc_image.binary' 14 | shouldExist: true 15 | permissions: '-r-xr-xr-x' 16 | 17 | - name: 'BUILD' 18 | path: './app/tests/container/cc/cc_image.binary.runfiles/io_bazel_rules_docker/tests/container/cc/BUILD' 19 | shouldExist: true 20 | permissions: '-r-xr-xr-x' 21 | 22 | - name: 'external' 23 | path: '/app/tests/container/cc/cc_image.binary.runfiles/io_bazel_rules_docker/external' 24 | shouldExist: true 25 | permissions: 'Lrwxrwxrwx' 26 | -------------------------------------------------------------------------------- /tests/container/groovy/configs/groovy_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: [ 5 | '/usr/bin/java', 6 | '-cp', 7 | '/app/io_bazel_rules_docker/tests/container/groovy/libgroovy_image_library-impl.jar:/app/io_bazel_rules_docker/../com_google_guava_guava/guava-18.0.jar:/app/io_bazel_rules_docker/../groovy_sdk_artifact/groovy-2.5.8/lib/groovy-2.5.8.jar:/app/io_bazel_rules_docker/tests/container/groovy/libgroovy_image.binary-lib-impl.jar:/app/io_bazel_rules_docker/tests/container/groovy/groovy_image.binary.jar:/app/io_bazel_rules_docker/tests/container/groovy/groovy_image.binary:/app/io_bazel_rules_docker/tests/container/groovy/BUILD', 8 | '-Dbuild.location=tests/container/groovy/BUILD', 9 | 'examples.images.Binary', 10 | 'arg0', 11 | 'arg1', 12 | 'tests/container/groovy/BUILD', 13 | ] 14 | -------------------------------------------------------------------------------- /testdata/cc_image_library.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "testdata/cc_image_library.h" 18 | 19 | void SayHello() { 20 | std::cout << "Hello World" << std::endl; 21 | } 22 | -------------------------------------------------------------------------------- /testing/e2e/test_top_level.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify d_image 16 | 17 | steps: 18 | - name: "l.gcr.io/google/bazel" 19 | entrypoint: "bash" 20 | args: 21 | - -c 22 | - ./testing/e2e/top_level.sh 23 | -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index1/blobs/sha256/4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46: -------------------------------------------------------------------------------- 1 | {"config": {"digest": "sha256:93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569", "mediaType": "application/vnd.docker.container.image.v1+json", "size": 658}, "layers": [{"digest": "sha256:2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 157}, {"digest": "sha256:26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 135}, {"digest": "sha256:3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 135}], "mediaType": "application/vnd.docker.distribution.manifest.v2+json", "schemaVersion": 2} -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index2/blobs/sha256/4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46: -------------------------------------------------------------------------------- 1 | {"config": {"digest": "sha256:93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569", "mediaType": "application/vnd.docker.container.image.v1+json", "size": 658}, "layers": [{"digest": "sha256:2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 157}, {"digest": "sha256:26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 135}, {"digest": "sha256:3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 135}], "mediaType": "application/vnd.docker.distribution.manifest.v2+json", "schemaVersion": 2} -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index4/blobs/sha256/4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46: -------------------------------------------------------------------------------- 1 | {"config": {"digest": "sha256:93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569", "mediaType": "application/vnd.docker.container.image.v1+json", "size": 658}, "layers": [{"digest": "sha256:2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 157}, {"digest": "sha256:26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 135}, {"digest": "sha256:3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 135}], "mediaType": "application/vnd.docker.distribution.manifest.v2+json", "schemaVersion": 2} -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index5/blobs/sha256/4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46: -------------------------------------------------------------------------------- 1 | {"config": {"digest": "sha256:93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569", "mediaType": "application/vnd.docker.container.image.v1+json", "size": 658}, "layers": [{"digest": "sha256:2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 157}, {"digest": "sha256:26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 135}, {"digest": "sha256:3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af", "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 135}], "mediaType": "application/vnd.docker.distribution.manifest.v2+json", "schemaVersion": 2} -------------------------------------------------------------------------------- /testing/e2e/test_launcher.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify the image launcher 16 | 17 | steps: 18 | - name: "l.gcr.io/google/bazel" 19 | entrypoint: "bash" 20 | args: 21 | - -c 22 | - ./testing/e2e/launcher.sh 23 | -------------------------------------------------------------------------------- /testdata/ArgEcho.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples.images; 16 | 17 | public class ArgEcho { 18 | public static void main(String[] args) { 19 | System.out.println(String.join(" ", args)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testdata/Binary.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples.images 16 | 17 | import examples.Library 18 | 19 | object Binary { 20 | def main(args: Array[String]): Unit = { 21 | println(Library.SayHello()) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/py_image_complex.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from testdata import py_image_complex_library 16 | 17 | def main(): 18 | print(py_image_complex_library.fn('Calling from main module: ')) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /docker/package_managers/run_install.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | # Resolve the docker tool path 5 | DOCKER="%{docker_tool_path}" 6 | 7 | if [[ -z "$DOCKER" ]]; then 8 | echo >&2 "error: docker not found; do you need to manually configure the docker toolchain?" 9 | exit 1 10 | fi 11 | 12 | # Setup tools and load utils 13 | TO_JSON_TOOL="%{to_json_tool}" 14 | source %{util_script} 15 | 16 | # Load the image and remember its name 17 | image_id=$(%{image_id_extractor_path} %{base_image_tar}) 18 | $DOCKER load -i %{base_image_tar} 19 | 20 | 21 | cid=$($DOCKER run -d -v $(pwd)/%{installables_tar}:/tmp/%{installables_tar} -v $(pwd)/%{installer_script}:/tmp/installer.sh --privileged $image_id /tmp/installer.sh) 22 | 23 | $DOCKER attach $cid || true 24 | 25 | reset_cmd $image_id $cid %{output_image_name} 26 | $DOCKER save %{output_image_name} > %{output_file_name} 27 | $DOCKER rm $cid 28 | -------------------------------------------------------------------------------- /testdata/Binary.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples.images; 16 | 17 | import examples.Library; 18 | 19 | public class Binary { 20 | public static void main(String[] args) { 21 | System.out.println(Library.SayHello()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testing/examples/basic/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify the basic example of rules_docker vs Dockerfile. 16 | 17 | steps: 18 | # Test the basic example. 19 | - name: "l.gcr.io/google/bazel" 20 | args: ["test", "//basic:all"] 21 | dir: "testing/examples" 22 | -------------------------------------------------------------------------------- /tests/container/scala/configs/scala_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: [ 5 | '/usr/bin/java', 6 | '-cp', 7 | '/app/io_bazel_rules_docker/tests/container/scala/scala_image_library.jar:/app/io_bazel_rules_docker/../com_google_guava_guava/guava-18.0.jar:/app/io_bazel_rules_docker/../io_bazel_rules_scala_scala_library/scala-library-2.11.12.jar:/app/io_bazel_rules_docker/../io_bazel_rules_scala_scala_reflect/scala-reflect-2.11.12.jar:/app/io_bazel_rules_docker/tests/container/scala/scala_image.binary.jar:/app/io_bazel_rules_docker/tests/container/scala/scala_image.binary:/app/io_bazel_rules_docker/tests/container/scala/BUILD:/app/io_bazel_rules_docker/tests/container/scala/scala_image.binary_wrapper.sh', 8 | '-Dbuild.location=tests/container/scala/BUILD', 9 | 'examples.images.Binary', 10 | 'arg0', 11 | 'arg1', 12 | 'tests/container/scala/BUILD', 13 | ] 14 | -------------------------------------------------------------------------------- /testing/examples/extended/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify the extended example of rules_docker vs Dockerfile. 16 | 17 | steps: 18 | # Test the extended example. 19 | - name: "l.gcr.io/google/bazel" 20 | args: ["test", "//extended:all"] 21 | dir: "testing/examples" 22 | -------------------------------------------------------------------------------- /testing/examples/java_app/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify the java_app example of rules_docker vs Dockerfile. 16 | 17 | steps: 18 | # Test the java_app example. 19 | - name: "l.gcr.io/google/bazel" 20 | args: ["test", "//java_app:all"] 21 | dir: "testing/examples" 22 | -------------------------------------------------------------------------------- /container/go/cmd/join_layers/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["join_layers.go"], 6 | importpath = "github.com/bazelbuild/rules_docker/container/go/cmd/join_layers", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//container/go/pkg/compat:go_default_library", 10 | "//container/go/pkg/utils:go_default_library", 11 | "@com_github_google_go_containerregistry//pkg/name:go_default_library", 12 | "@com_github_google_go_containerregistry//pkg/v1:go_default_library", 13 | "@com_github_google_go_containerregistry//pkg/v1/tarball:go_default_library", 14 | "@com_github_pkg_errors//:go_default_library", 15 | ], 16 | ) 17 | 18 | go_binary( 19 | name = "join_layers", 20 | embed = [":go_default_library"], 21 | visibility = ["//visibility:public"], 22 | ) 23 | -------------------------------------------------------------------------------- /tools/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | package(default_visibility = ["//visibility:private"]) 15 | 16 | py_binary( 17 | name = "update_deps", 18 | srcs = ["update_deps.py"], 19 | legacy_create_init = False, 20 | python_version = "PY2", 21 | deps = [ 22 | "@containerregistry", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /testdata/Library.groovy: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples 16 | 17 | import com.google.common.base.Joiner 18 | import com.google.common.collect.ImmutableList 19 | 20 | class Library { 21 | static SayHello() { 22 | return Joiner.on(" ").join(ImmutableList.of("Hello", "World")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /docker/util/commit.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | # Setup tools and load utils 6 | TO_JSON_TOOL="%{to_json_tool}" 7 | source %{util_script} 8 | 9 | # Resolve the docker tool path 10 | DOCKER="%{docker_tool_path}" 11 | 12 | if [[ -z "$DOCKER" ]]; then 13 | echo >&2 "error: docker not found; do you need to manually configure the docker toolchain?" 14 | exit 1 15 | fi 16 | 17 | # Load the image and remember its name 18 | image_id=$(%{image_id_extractor_path} %{image_tar}) 19 | $DOCKER load -i %{image_tar} 20 | 21 | id=$($DOCKER run -d %{docker_run_flags} $image_id %{commands}) 22 | # Actually wait for the container to finish running its commands 23 | retcode=$($DOCKER wait $id) 24 | # Trigger a failure if the run had a non-zero exit status 25 | if [ $retcode != 0 ]; then 26 | $DOCKER logs $id && false 27 | fi 28 | 29 | reset_cmd $image_id $id %{output_image} 30 | $DOCKER save %{output_image} -o %{output_tar} 31 | $DOCKER rm $id 32 | -------------------------------------------------------------------------------- /testdata/Library.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples 16 | 17 | import com.google.common.base.Joiner 18 | import com.google.common.collect.ImmutableList 19 | 20 | object Library { 21 | def SayHello(): String = { 22 | return Joiner.on(" ").join(ImmutableList.of("Hello", "World")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/Library.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples; 16 | 17 | import com.google.common.base.Joiner; 18 | import com.google.common.collect.ImmutableList; 19 | 20 | public class Library { 21 | public static String SayHello() { 22 | return Joiner.on(" ").join(ImmutableList.of("Hello", "World")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testing/download_pkgs_at_root/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify that download_pkgs targets can be declared 16 | # in the top level BUILD file. 17 | 18 | steps: 19 | # Test the download_pkgs examples. 20 | - name: "l.gcr.io/google/bazel" 21 | args: ["test", "//..."] 22 | dir: "testing/download_pkgs_at_root" 23 | -------------------------------------------------------------------------------- /testdata/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package main tells the linter to shut up. 16 | package main 17 | 18 | import ( 19 | "fmt" 20 | "os" 21 | ) 22 | 23 | func main() { 24 | message := "Hello, world!" 25 | if v, ok := os.LookupEnv("CUSTOM_MESSAGE"); ok { 26 | message = v 27 | } 28 | fmt.Println(message) 29 | } 30 | -------------------------------------------------------------------------------- /testing/examples/run_instruction_arbitrary/Dockerfile: -------------------------------------------------------------------------------- 1 | # Ubuntu with bazel, gcloud and its dependencies preinstalled. 2 | 3 | FROM launcher.gcr.io/google/bazel:latest 4 | 5 | # Install gcloud and kubectl 6 | RUN wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-220.0.0-linux-x86_64.tar.gz \ 7 | && tar -xzf google-cloud-sdk-220.0.0-linux-x86_64.tar.gz \ 8 | # Add the gcloud binaries to PATH 9 | && echo 'source /google-cloud-sdk/path.bash.inc' >> ~/.bashrc \ 10 | && ./google-cloud-sdk/install.sh -q \ 11 | # Install kubernetes as a component of gcloud 12 | && ./google-cloud-sdk/bin/gcloud components install --quiet kubectl 13 | 14 | ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/google-cloud-sdk/bin 15 | 16 | # Install python tools 17 | RUN apt-get update && apt-get install -y --no-install-recommends \ 18 | python-pip \ 19 | && apt-get clean \ 20 | && python -m pip install --upgrade pip setuptools wheel 21 | -------------------------------------------------------------------------------- /skylib/filetype.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Filetype constants.""" 15 | 16 | tgz = [ 17 | ".tar.gz", 18 | ".tgz", 19 | ] 20 | 21 | # Filetype to restrict inputs 22 | tar = [ 23 | ".tar", 24 | ".tar.xz", 25 | ] + tgz 26 | 27 | deb = [ 28 | ".deb", 29 | ".udeb", 30 | ] 31 | 32 | # Container images are tarballs (when exported). 33 | container = tar 34 | -------------------------------------------------------------------------------- /testing/new_pusher_tests/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_docker//contrib:test.bzl", "container_test") 16 | 17 | container_test( 18 | name = "new_push_verify_pushed_configs_and_files", 19 | configs = ["@io_bazel_rules_docker//tests/container/configs:verify_new_pusher.yaml"], 20 | image = "@verify_new_pusher_image_contents//image", 21 | ) 22 | -------------------------------------------------------------------------------- /testing/java_image/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify the java_image example of rules_docker. 16 | # This basic test verifies dependencies can be resolved correctly for a 17 | # simple repo using java_image. 18 | 19 | steps: 20 | # Test the java_image example. 21 | - name: "l.gcr.io/google/bazel" 22 | args: ["build", "//..."] 23 | dir: "testing/java_image" 24 | -------------------------------------------------------------------------------- /tests/docker/security/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify the security_check examples of rules_docker. 16 | # Needs to run on GCB as requires access to asci-toolchains images 17 | 18 | steps: 19 | # Test the security_check examples. 20 | - name: "gcr.io/asci-toolchain/nosla-ubuntu16_04-bazel-docker-gcloud" 21 | args: ["bazel","test", "//tests/docker/security/..."] 22 | -------------------------------------------------------------------------------- /.bazelrc: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # The following flags are set to test use of new features for python toolchains 16 | # These flags will only work with Bazel 0.25.0 or above. 17 | build --incompatible_use_python_toolchains 18 | build --host_force_python=PY2 19 | test --incompatible_use_python_toolchains 20 | test --host_force_python=PY2 21 | run --incompatible_use_python_toolchains 22 | run --host_force_python=PY2 23 | -------------------------------------------------------------------------------- /testing/e2e/test_nodejs_image.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify nodejs_image 16 | 17 | steps: 18 | - name: "l.gcr.io/google/bazel" 19 | entrypoint: "bash" 20 | args: 21 | - -c 22 | - ./testing/e2e/nodejs_image.sh test_nodejs_image -c opt 23 | 24 | - name: "l.gcr.io/google/bazel" 25 | entrypoint: "bash" 26 | args: 27 | - -c 28 | - ./testing/e2e/nodejs_image.sh test_nodejs_image -c dbg 29 | -------------------------------------------------------------------------------- /docker/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | licenses(["notice"]) # Apache 2.0 20 | 21 | bzl_library( 22 | name = "docker", 23 | srcs = ["docker.bzl"], 24 | deps = [ 25 | "@io_bazel_rules_docker//container", 26 | "@io_bazel_rules_docker//toolchains/docker", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /testdata/py_image_complex_library.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from testdata import py_image_library_using_six 16 | from testdata.test import py_image_library_using_addict 17 | 18 | def fn(what_comes_in): 19 | return "\n".join([ 20 | py_image_library_using_six.fn(what_comes_in + "through py_image_complex_library: "), 21 | py_image_library_using_addict.fn(what_comes_in + "through py_image_complex_library: "), 22 | ]) 23 | -------------------------------------------------------------------------------- /oci/oci.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Rules for manipulation OCI images.""" 15 | 16 | load( 17 | "//container:container.bzl", 18 | "container_push", 19 | ) 20 | 21 | def oci_push(*args, **kwargs): 22 | if "format" in kwargs: 23 | fail( 24 | "Cannot override 'format' attribute on oci_push", 25 | attr = "format", 26 | ) 27 | kwargs["format"] = "OCI" 28 | container_push(*args, **kwargs) 29 | -------------------------------------------------------------------------------- /testing/java_image/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_docker//java:image.bzl", "java_image") 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_image( 20 | name = "java_image", 21 | srcs = [":Runfiles.java"], 22 | data = [ 23 | ":foo", 24 | ], 25 | main_class = "examples.images.Runfiles", 26 | deps = [ 27 | "@bazel_tools//tools/java/runfiles", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /lang/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 15 | 16 | package(default_visibility = ["//visibility:public"]) 17 | 18 | licenses(["notice"]) # Apache 2.0 19 | 20 | bzl_library( 21 | name = "image", 22 | srcs = ["image.bzl"], 23 | deps = [ 24 | "//container", 25 | "//container:layer_tools", 26 | "//container:providers", 27 | "@bazel_skylib//lib:dicts", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution, 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult [GitHub Help] for more 22 | information on using pull requests. 23 | 24 | [GitHub Help]: https://help.github.com/articles/about-pull-requests/ 25 | -------------------------------------------------------------------------------- /testing/examples/run_instruction_arbitrary/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify the example manipulating arbitrary commands using 16 | # rules_docker and Dockerfile. 17 | 18 | timeout: 1200s 19 | options: 20 | machineType: "N1_HIGHCPU_32" 21 | 22 | steps: 23 | # Test the run_instruction_arbitrary example. 24 | - name: "l.gcr.io/google/bazel" 25 | args: ["test", "//run_instruction_arbitrary:all"] 26 | dir: "testing/examples" 27 | -------------------------------------------------------------------------------- /toolchains/docker/BUILD.tpl: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | This BUILD file is auto-generated from toolchains/docker/BUILD.tpl 16 | """ 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | load("@io_bazel_rules_docker//toolchains/docker:toolchain.bzl", "docker_toolchain") 20 | 21 | docker_toolchain( 22 | name = "toolchain", 23 | tool_path = "%{DOCKER_TOOL}", 24 | client_config = "%{DOCKER_CONFIG}", 25 | xz_path = "%{XZ_TOOL_PATH}", 26 | ) 27 | -------------------------------------------------------------------------------- /testing/e2e/launcher.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | # Copyright 2015 The Bazel Authors. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | source ./testing/e2e/util.sh 17 | 18 | # Tests that the launcher can launch images. 19 | 20 | # Must be invoked from the root of the repo. 21 | ROOT=$PWD 22 | 23 | function test_launcher_image() { 24 | cd "${ROOT}" 25 | clear_docker 26 | EXPECT_CONTAINS "$(bazel run "$@" testdata:launcher_image)" "Launched via launcher!" 27 | } 28 | 29 | # Call function above 30 | test_launcher_image 31 | -------------------------------------------------------------------------------- /tests/container/windowsservercore.1803.manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 2, 3 | "mediaType": "application/vnd.docker.distribution.manifest.v2+json", 4 | "config": { 5 | "mediaType": "application/vnd.docker.container.image.v1+json", 6 | "size": 784, 7 | "digest": "sha256:fc9cd8b52f1abe17698bbb770a259ad8d86af3ad9f4f9f29e11e68a4666679cc" 8 | }, 9 | "layers": [ 10 | { 11 | "mediaType": "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip", 12 | "size": 1659688273, 13 | "digest": "sha256:d9e8b01179bfc94a5bdb1810fbd76b999aa52016001ace2d3a4c4bc7065a9601", 14 | "urls": [ 15 | "https://go.microsoft.com/fwlink/?linkid=873595" 16 | ] 17 | }, 18 | { 19 | "mediaType": "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip", 20 | "size": 493521205, 21 | "digest": "sha256:e30fefc566f71c5dd5786e4783ff4ae3ad98804d5279c14dcf806c813fdf8f66", 22 | "urls": [ 23 | "https://go.microsoft.com/fwlink/?linkid=2005408" 24 | ] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /docker/toolchain_container/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 16 | 17 | licenses(["notice"]) # Apache 2.0 18 | 19 | package(default_visibility = ["//visibility:public"]) 20 | 21 | bzl_library( 22 | name = "toolchain_container", 23 | srcs = [ 24 | "debian_pkg_tar.bzl", 25 | "toolchain_container.bzl", 26 | ], 27 | deps = [ 28 | "//container", 29 | "//docker/package_managers", 30 | "@bazel_skylib//lib:dicts", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /tests/container/empty_layers.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | This module contains a macro to generate container layers with empty files. 16 | """ 17 | 18 | load("//container:container.bzl", "container_layer") 19 | 20 | def empty_layers(name, num_layers): 21 | """Generate the given number of empty layers prefixed with the given name 22 | """ 23 | for i in range(num_layers): 24 | container_layer( 25 | name = "{}_{}".format(name, i), 26 | empty_files = ["file_{}.txt".format(i)], 27 | ) 28 | -------------------------------------------------------------------------------- /tests/contrib/automatic_container_release/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | licenses(["notice"]) # Apache 2.0 16 | 17 | load( 18 | "//contrib/automatic_container_release:configs_test.bzl", 19 | "configs_test", 20 | ) 21 | 22 | configs_test( 23 | name = "configs_test", 24 | dependency_update_specs = ["deps_spec.yaml"], 25 | file_update_specs = ["file_updates.yaml"], 26 | ) 27 | 28 | configs_test( 29 | name = "configs_test_deps_spec_only", 30 | dependency_update_specs = ["deps_spec_no_fus_deps.yaml"], 31 | ) 32 | -------------------------------------------------------------------------------- /container/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """This package contains various functions used when building containers.""" 15 | 16 | 17 | def ExtractValue(value): 18 | """Return the contents of a file point to by value if it starts with an @. 19 | 20 | Args: 21 | value: The possible filename to extract or a string. 22 | 23 | Returns: 24 | The content of the file if value starts with an @, or the passed value. 25 | """ 26 | if value.startswith('@'): 27 | with open(value[1:], 'r') as f: 28 | value = f.read() 29 | return value 30 | -------------------------------------------------------------------------------- /skylib/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | licenses(["notice"]) # Apache 2.0 20 | 21 | bzl_library( 22 | name = "filetype", 23 | srcs = ["filetype.bzl"], 24 | ) 25 | 26 | bzl_library( 27 | name = "label", 28 | srcs = ["label.bzl"], 29 | ) 30 | 31 | bzl_library( 32 | name = "path", 33 | srcs = ["path.bzl"], 34 | ) 35 | 36 | bzl_library( 37 | name = "zip", 38 | srcs = ["zip.bzl"], 39 | ) 40 | -------------------------------------------------------------------------------- /testing/java_image/WORKSPACE: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | workspace(name = "java_image_example") 16 | 17 | local_repository( 18 | name = "io_bazel_rules_docker", 19 | path = "../../", 20 | ) 21 | 22 | # java_image rule dependencies. 23 | load( 24 | "@io_bazel_rules_docker//repositories:repositories.bzl", 25 | container_repositories = "repositories", 26 | ) 27 | 28 | container_repositories() 29 | 30 | load( 31 | "@io_bazel_rules_docker//java:image.bzl", 32 | _java_image_repos = "repositories", 33 | ) 34 | 35 | _java_image_repos() 36 | -------------------------------------------------------------------------------- /testdata/py3_image.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | import sys 15 | import os 16 | 17 | from testdata import py_image_library 18 | 19 | def main(): 20 | """ 21 | This method expects a valid file path as its third arg. 22 | """ 23 | print('First: %d' % py_image_library.fn(1)) 24 | print('Second: %d' % py_image_library.fn(2)) 25 | print('Third: %d' % py_image_library.fn(3)) 26 | print('Fourth: %d' % py_image_library.fn(4)) 27 | print(sys.argv) 28 | if len(sys.argv) > 1: 29 | print(os.stat(sys.argv[2])) 30 | 31 | 32 | if __name__ == '__main__': 33 | main() 34 | -------------------------------------------------------------------------------- /testdata/py_image.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | import sys 15 | import os 16 | 17 | from testdata import py_image_library 18 | 19 | def main(): 20 | """ 21 | This method expects a valid file path as its third arg. 22 | """ 23 | print('First: %d' % py_image_library.fn(1)) 24 | print('Second: %d' % py_image_library.fn(2)) 25 | print('Third: %d' % py_image_library.fn(3)) 26 | print('Fourth: %d' % py_image_library.fn(4)) 27 | print(sys.argv) 28 | if len(sys.argv) > 1: 29 | print(os.stat(sys.argv[2])) 30 | 31 | 32 | if __name__ == '__main__': 33 | main() 34 | -------------------------------------------------------------------------------- /testing/e2e/test_py_image.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, softpye 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify py_image 16 | 17 | timeout: 1200s 18 | 19 | steps: 20 | - name: "l.gcr.io/google/bazel" 21 | entrypoint: "bash" 22 | args: 23 | - -c 24 | - ./testing/e2e/py_image.sh test_py_image -c opt 25 | 26 | - name: "l.gcr.io/google/bazel" 27 | entrypoint: "bash" 28 | args: 29 | - -c 30 | - ./testing/e2e/py_image.sh test_py_image -c dbg 31 | 32 | - name: "l.gcr.io/google/bazel" 33 | entrypoint: "bash" 34 | args: 35 | - -c 36 | - ./testing/e2e/py_image.sh test_py_image_deps_as_layers 37 | -------------------------------------------------------------------------------- /contrib/with-tag.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Derivative of container_image that tags as well.""" 15 | 16 | load( 17 | "//container:container.bzl", 18 | "container_bundle", 19 | _container_image = "container_image", 20 | ) 21 | 22 | def container_image(name = None, tag = None, **kwargs): 23 | _container_image(name = name + "-internal", **kwargs) 24 | container_bundle(name = name, images = { 25 | tag: ":" + name + "-internal", 26 | }) 27 | 28 | docker_build = container_image 29 | 30 | docker_image = container_image 31 | 32 | oci_image = container_image 33 | -------------------------------------------------------------------------------- /docker/util/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | licenses(["notice"]) # Apache 2.0 20 | 21 | py_binary( 22 | name = "config_stripper", 23 | srcs = ["config_stripper.py"], 24 | ) 25 | 26 | py_binary( 27 | name = "to_json", 28 | srcs = ["to_json.py"], 29 | ) 30 | 31 | exports_files([ 32 | "commit.sh.tpl", 33 | "extract.sh.tpl", 34 | "image_util.sh", 35 | ]) 36 | 37 | bzl_library( 38 | name = "util", 39 | srcs = ["run.bzl"], 40 | ) 41 | -------------------------------------------------------------------------------- /tests/container/rust/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//contrib:test.bzl", "container_test") 16 | load("//rust:image.bzl", "rust_image") 17 | 18 | package(default_visibility = ["//visibility:public"]) 19 | 20 | rust_image( 21 | name = "rust_image", 22 | srcs = ["//testdata:main.rs"], 23 | args = [ 24 | "arg0", 25 | "arg1", 26 | "$(location :BUILD)", 27 | ], 28 | data = [":BUILD"], 29 | ) 30 | 31 | container_test( 32 | name = "rust_image_test", 33 | configs = ["//tests/container/rust/configs:rust_image.yaml"], 34 | image = ":rust_image", 35 | ) 36 | -------------------------------------------------------------------------------- /cc/cc.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ Generated file with dependencies for language rule.""" 15 | 16 | # !!!! THIS IS A GENERATED FILE TO NOT EDIT IT BY HAND !!!! 17 | # 18 | # To regenerate this file, run ./update_deps.sh from the root of the 19 | # git repository. 20 | 21 | DIGESTS = { 22 | # "gcr.io/distroless/cc:debug" circa 2019-08-08 13:40 -0400 23 | "debug": "sha256:1fc7e6e489e5ba6d283231c090f4b92016eb557c41a94366679cb4b428534f8b", 24 | # "gcr.io/distroless/cc:latest" circa 2019-08-08 13:40 -0400 25 | "latest": "sha256:86f16733f25964c40dcd34edf14339ddbb2287af2f7c9dfad88f0366723c00d7", 26 | } 27 | -------------------------------------------------------------------------------- /testdata/stamp_info.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """Provides the stamp info file containing the Bazel non-volatile keys 16 | """ 17 | 18 | def _impl(ctx): 19 | output = ctx.outputs.out 20 | ctx.actions.run_shell( 21 | outputs = [output], 22 | inputs = [ctx.info_file], 23 | command = "cp {src} {dst}".format( 24 | src = ctx.info_file.path, 25 | dst = output.path, 26 | ), 27 | ) 28 | 29 | stamp_info = rule( 30 | implementation = _impl, 31 | outputs = { 32 | # The stamp file. 33 | "out": "%{name}.txt", 34 | }, 35 | ) 36 | -------------------------------------------------------------------------------- /go/go.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ Generated file with dependencies for language rule.""" 15 | 16 | # !!!! THIS IS A GENERATED FILE TO NOT EDIT IT BY HAND !!!! 17 | # 18 | # To regenerate this file, run ./update_deps.sh from the root of the 19 | # git repository. 20 | 21 | DIGESTS = { 22 | # "gcr.io/distroless/base:debug" circa 2019-08-08 13:40 -0400 23 | "debug": "sha256:f989df6099c5efb498021c7f01b74f484b46d2f5e1cdb862e508569d87569f2b", 24 | # "gcr.io/distroless/base:latest" circa 2019-08-08 13:40 -0400 25 | "latest": "sha256:e37cf3289c1332c5123cbf419a1657c8dad0811f2f8572433b668e13747718f8", 26 | } 27 | -------------------------------------------------------------------------------- /testdata/Runfiles.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples.images; 16 | 17 | import java.io.IOException; 18 | import java.nio.charset.StandardCharsets; 19 | import java.nio.file.Files; 20 | import java.nio.file.Paths; 21 | 22 | public class Runfiles { 23 | public static void main(String[] args) throws IOException { 24 | String path = com.google.devtools.build.runfiles.Runfiles.create() 25 | .rlocation("io_bazel_rules_docker/testdata/foo"); 26 | byte[] encoded = Files.readAllBytes(Paths.get(path)); 27 | System.out.println(new String(encoded, StandardCharsets.UTF_8)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /docker/package_managers/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | licenses(["notice"]) # Apache 2.0 20 | 21 | exports_files([ 22 | "installer.sh.tpl", 23 | "run_download.sh.tpl", 24 | "run_install.sh.tpl", 25 | ]) 26 | 27 | bzl_library( 28 | name = "package_managers", 29 | srcs = [ 30 | "apt_key.bzl", 31 | "download_pkgs.bzl", 32 | "install_pkgs.bzl", 33 | ], 34 | deps = [ 35 | "//container", 36 | "//docker/util", 37 | ], 38 | ) 39 | -------------------------------------------------------------------------------- /java/java.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ Generated file with dependencies for language rule.""" 15 | 16 | # !!!! THIS IS A GENERATED FILE TO NOT EDIT IT BY HAND !!!! 17 | # 18 | # To regenerate this file, run ./update_deps.sh from the root of the 19 | # git repository. 20 | 21 | DIGESTS = { 22 | # "gcr.io/distroless/java:debug" circa 2019-08-08 13:40 -0400 23 | "debug": "sha256:97b1b77ff16fc268c07dbfaa11d3a0ec727447855ec18b56f8cd2601e353cfaf", 24 | # "gcr.io/distroless/java:latest" circa 2019-08-08 13:40 -0400 25 | "latest": "sha256:8c3d227accdf0e9e9d3635f57a6a4b58ac3f933b7e3820ba44e06368d688d7b6", 26 | } 27 | -------------------------------------------------------------------------------- /go/static.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ Generated file with dependencies for language rule.""" 15 | 16 | # !!!! THIS IS A GENERATED FILE TO NOT EDIT IT BY HAND !!!! 17 | # 18 | # To regenerate this file, run ./update_deps.sh from the root of the 19 | # git repository. 20 | 21 | DIGESTS = { 22 | # "gcr.io/distroless/static:debug" circa 2019-08-08 13:40 -0400 23 | "debug": "sha256:9b60270ec0991bc4f14bda475e8cae75594d8197d0ae58576ace84694aa75d7a", 24 | # "gcr.io/distroless/static:latest" circa 2019-08-08 13:40 -0400 25 | "latest": "sha256:9b60270ec0991bc4f14bda475e8cae75594d8197d0ae58576ace84694aa75d7a", 26 | } 27 | -------------------------------------------------------------------------------- /testing/java_image/Runfiles.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples.images; 16 | 17 | import java.io.IOException; 18 | import java.nio.charset.StandardCharsets; 19 | import java.nio.file.Files; 20 | import java.nio.file.Paths; 21 | 22 | public class Runfiles { 23 | public static void main(String[] args) throws IOException { 24 | String path = com.google.devtools.build.runfiles.Runfiles.create() 25 | .rlocation("io_bazel_rules_docker/testdata/foo"); 26 | byte[] encoded = Files.readAllBytes(Paths.get(path)); 27 | System.out.println(new String(encoded, StandardCharsets.UTF_8)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java/jetty.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ Generated file with dependencies for language rule.""" 15 | 16 | # !!!! THIS IS A GENERATED FILE TO NOT EDIT IT BY HAND !!!! 17 | # 18 | # To regenerate this file, run ./update_deps.sh from the root of the 19 | # git repository. 20 | 21 | DIGESTS = { 22 | # "gcr.io/distroless/java/jetty:debug" circa 2019-08-08 13:40 -0400 23 | "debug": "sha256:03341076ae3117ad3251ca13261f6c071bb87b2eaf30b7785d61d6cfb2c3acfd", 24 | # "gcr.io/distroless/java/jetty:latest" circa 2019-08-08 13:40 -0400 25 | "latest": "sha256:782d6de1576fe82ba9ef6c7879e3b4562f3e9754eefe0580303db520f79fa8f8", 26 | } 27 | -------------------------------------------------------------------------------- /python3/python3.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ Generated file with dependencies for language rule.""" 15 | 16 | # !!!! THIS IS A GENERATED FILE TO NOT EDIT IT BY HAND !!!! 17 | # 18 | # To regenerate this file, run ./update_deps.sh from the root of the 19 | # git repository. 20 | 21 | DIGESTS = { 22 | # "gcr.io/distroless/python3:debug" circa 2019-08-08 13:40 -0400 23 | "debug": "sha256:0b03db0bb196e411908e4ef1acb4e84d114fb3de18372920297529c4df734772", 24 | # "gcr.io/distroless/python3:latest" circa 2019-08-08 13:40 -0400 25 | "latest": "sha256:b83bd4dc7c34d1c3a1b8400474163fccfe5b9110d0d1cb12b48e1786473d5ba2", 26 | } 27 | -------------------------------------------------------------------------------- /tests/container/apple.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Rules to test issues related to pkg_tar's strip_prefix handling.""" 15 | 16 | def _create_banana_directory_impl(ctx): 17 | out = ctx.actions.declare_directory("banana") 18 | ctx.actions.run( 19 | executable = "bash", 20 | arguments = ["-c", "mkdir -p %s/pear && touch %s/pear/grape" % (out.path, out.path)], 21 | outputs = [out], 22 | ) 23 | return [ 24 | DefaultInfo( 25 | files = depset([out]), 26 | ), 27 | ] 28 | 29 | create_banana_directory = rule( 30 | implementation = _create_banana_directory_impl, 31 | ) 32 | -------------------------------------------------------------------------------- /container/push-tag.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2017 The Bazel Authors. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -eu 17 | 18 | function guess_runfiles() { 19 | if [ -d ${BASH_SOURCE[0]}.runfiles ]; then 20 | # Runfiles are adjacent to the current script. 21 | echo "$( cd ${BASH_SOURCE[0]}.runfiles && pwd )" 22 | else 23 | # The current script is within some other script's runfiles. 24 | mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 25 | echo $mydir | sed -e 's|\(.*\.runfiles\)/.*|\1|' 26 | fi 27 | } 28 | 29 | RUNFILES="${PYTHON_RUNFILES:-$(guess_runfiles)}" 30 | 31 | %{container_pusher} %{args} "$@" 32 | -------------------------------------------------------------------------------- /python/python.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ Generated file with dependencies for language rule.""" 15 | 16 | # !!!! THIS IS A GENERATED FILE TO NOT EDIT IT BY HAND !!!! 17 | # 18 | # To regenerate this file, run ./update_deps.sh from the root of the 19 | # git repository. 20 | 21 | DIGESTS = { 22 | # "gcr.io/distroless/python2.7:debug" circa 2019-08-08 13:40 -0400 23 | "debug": "sha256:4e6921952f9b117ddb3bbf7687674baa1dae6a821bc6043959504a6e0d14f3ba", 24 | # "gcr.io/distroless/python2.7:latest" circa 2019-08-08 13:40 -0400 25 | "latest": "sha256:35d2814bc8dcb3d6d02dd4d9d965995c977a0c879de7c0ccd522b2a169153d14", 26 | } 27 | -------------------------------------------------------------------------------- /nodejs/nodejs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ Generated file with dependencies for language rule.""" 15 | 16 | # !!!! THIS IS A GENERATED FILE TO NOT EDIT IT BY HAND !!!! 17 | # 18 | # To regenerate this file, run ./update_deps.sh from the root of the 19 | # git repository. 20 | 21 | DIGESTS = { 22 | # "gcr.io/google-appengine/debian9:debug" circa 2019-08-08 13:40 -0400 23 | "debug": "sha256:84bf592c8a1626f089d5540affef7d0764428303b5f2103b1b12947ac17ba2e6", 24 | # "gcr.io/google-appengine/debian9:latest" circa 2019-08-08 13:40 -0400 25 | "latest": "sha256:84bf592c8a1626f089d5540affef7d0764428303b5f2103b1b12947ac17ba2e6", 26 | } 27 | -------------------------------------------------------------------------------- /skylib/label.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Rules for dealing with labels and their string form.""" 15 | 16 | def string_to_label(label_list, string_list): 17 | """Return a mapping from label strings to the resolved label. 18 | 19 | Args: 20 | label_list: The list of labels 21 | string_list: The list of strings 22 | 23 | Returns: 24 | A mapping from label strings to the resolved label. 25 | """ 26 | label_string_dict = dict() 27 | for i in range(len(label_list)): 28 | string = string_list[i] 29 | label = label_list[i] 30 | label_string_dict[string] = label 31 | return label_string_dict 32 | -------------------------------------------------------------------------------- /testing/e2e/nodejs_image.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | # Copyright 2015 The Bazel Authors. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | source ./testing/e2e/util.sh 17 | 18 | # Tests for nodejs_image 19 | 20 | # Must be invoked from the root of the repo. 21 | ROOT=$PWD 22 | 23 | function test_nodejs_image() { 24 | cd "${ROOT}" 25 | clear_docker 26 | EXPECT_CONTAINS "$(bazel run tests/container/nodejs:nodejs_image)" "Hello World!" 27 | } 28 | 29 | # Call functions above with either 3 or 1 parameter 30 | # If 3 parameters: 1st parameter is name of function, 2nd and 3rd 31 | # passed as args 32 | # If 1 parameter: parameter is name of function 33 | # (simple approach to make migration easy for e2e.sh) 34 | $1 $2 $3 35 | -------------------------------------------------------------------------------- /testing/examples/README.md: -------------------------------------------------------------------------------- 1 | # Dockerfile vs rules_docker examples 2 | 3 | This Bazel project provides examples on how to build Docker images using 4 | [rules_docker](https://github.com/bazelbuild/rules_docker). This project is 5 | structured such that every directory contains one separate example. For ease of 6 | understanding, each example also comes with the equivalent Dockerfile. In 7 | addition, all examples include tests that run against the image built from 8 | a Dockerfile and against the image generated by rules_docker. 9 | 10 | ## Getting Started 11 | 12 | Simply browse each directory and compare side by side the Dockerfile with the 13 | BUILD file where the Bazel targets to build images are defined. 14 | 15 | In order to run the tests to verify the images' equivalence, you can run all 16 | the test targets (which also builds all the required images using rules_docker) 17 | by running the following from the root of this project: 18 | ``` 19 | $ bazel test //... 20 | ``` 21 | 22 | ## More Details 23 | 24 | For further comparison details between Dockerfile and container_image from 25 | rules_docker, please refer to the [Dockerfile reference](https://docs.docker.com/engine/reference/builder) 26 | and [container_image reference](https://github.com/bazelbuild/rules_docker#container_image-1) 27 | -------------------------------------------------------------------------------- /repositories/images.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Provides functions to pull the images required by rules_docker.""" 15 | 16 | load("//container:container.bzl", "container_pull") 17 | 18 | _REGISTRY = "l.gcr.io" 19 | 20 | def images(): 21 | """Pull containers used in rules_docker. 22 | 23 | Pull in all container images that custom rules depend on by default. 24 | """ 25 | 26 | excludes = native.existing_rules().keys() 27 | 28 | if "bazel_latest" not in excludes: 29 | container_pull( 30 | name = "bazel_latest", 31 | registry = _REGISTRY, 32 | repository = "google/bazel", 33 | tag = "latest", 34 | ) 35 | -------------------------------------------------------------------------------- /testing/e2e/test_go_image.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify go_image 16 | 17 | steps: 18 | - name: "l.gcr.io/google/bazel" 19 | entrypoint: "bash" 20 | args: 21 | - -c 22 | - ./testing/e2e/go_image.sh test_go_image -c opt 23 | 24 | - name: "l.gcr.io/google/bazel" 25 | entrypoint: "bash" 26 | args: 27 | - -c 28 | - ./testing/e2e/go_image.sh test_go_image -c dbg 29 | 30 | - name: "l.gcr.io/google/bazel" 31 | entrypoint: "bash" 32 | args: 33 | - -c 34 | - ./testing/e2e/go_image.sh test_go_image_busybox 35 | 36 | - name: "l.gcr.io/google/bazel" 37 | entrypoint: "bash" 38 | args: 39 | - -c 40 | - ./testing/e2e/go_image.sh test_go_image_with_tags 41 | -------------------------------------------------------------------------------- /tests/container/python3/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//contrib:test.bzl", "container_test") 16 | load("//python3:image.bzl", "py3_image") 17 | 18 | package(default_visibility = ["//visibility:public"]) 19 | 20 | py3_image( 21 | name = "py3_image", 22 | srcs = ["//testdata:py3_image.py"], 23 | args = [ 24 | "arg0", 25 | "arg1", 26 | "$(location :BUILD)", 27 | ], 28 | data = [":BUILD"], 29 | layers = [ 30 | "//tests/container/python:py_image_library", 31 | ], 32 | ) 33 | 34 | container_test( 35 | name = "py3_image_test", 36 | configs = ["//tests/container/python3/configs:py3_image.yaml"], 37 | image = ":py3_image", 38 | ) 39 | -------------------------------------------------------------------------------- /container/go/cmd/extract_config/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ### 15 | # Build file for extractConfig binary based on go-containerregistry backend. 16 | 17 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 18 | 19 | go_library( 20 | name = "go_default_library", 21 | srcs = ["extractConfig.go"], 22 | importpath = "github.com/bazelbuild/rules_docker/container/go/cmd/extract_config", 23 | visibility = ["//visibility:private"], 24 | deps = ["@com_github_google_go_containerregistry//pkg/v1/tarball:go_default_library"], 25 | ) 26 | 27 | go_binary( 28 | name = "extract_config", 29 | embed = [":go_default_library"], 30 | visibility = ["//visibility:public"], 31 | ) 32 | -------------------------------------------------------------------------------- /docker/security/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 16 | load("@pip_deps//:requirements.bzl", "requirement") 17 | load("@subpar//:subpar.bzl", "par_binary") 18 | 19 | package(default_visibility = ["//visibility:public"]) 20 | 21 | exports_files([ 22 | "security_check_whitelist.json", 23 | ]) 24 | 25 | par_binary( 26 | name = "security_check", 27 | srcs = ["security_check.py"], 28 | main = "security_check.py", 29 | python_version = "PY2", 30 | visibility = ["//visibility:public"], 31 | deps = [ 32 | requirement("PyYaml"), 33 | ], 34 | ) 35 | 36 | bzl_library( 37 | name = "security_check_lib", 38 | srcs = [ 39 | "security_check.bzl", 40 | ], 41 | ) 42 | -------------------------------------------------------------------------------- /testing/e2e/test_groovy_image.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify groovy_image 16 | 17 | timeout: 1200s 18 | 19 | steps: 20 | - name: "l.gcr.io/google/bazel" 21 | entrypoint: "bash" 22 | args: 23 | - -c 24 | - ./testing/e2e/groovy_image.sh test_groovy_image -c opt 25 | 26 | - name: "l.gcr.io/google/bazel" 27 | entrypoint: "bash" 28 | args: 29 | - -c 30 | - ./testing/e2e/groovy_image.sh test_groovy_image -c dbg 31 | 32 | - name: "l.gcr.io/google/bazel" 33 | entrypoint: "bash" 34 | args: 35 | - -c 36 | - ./testing/e2e/groovy_image.sh test_groovy_scala_image -c opt 37 | 38 | - name: "l.gcr.io/google/bazel" 39 | entrypoint: "bash" 40 | args: 41 | - -c 42 | - ./testing/e2e/groovy_image.sh test_groovy_scala_image -c dbg 43 | -------------------------------------------------------------------------------- /testing/e2e/test_scala_image.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify scala_image 16 | 17 | timeout: 1200s 18 | 19 | steps: 20 | - name: "l.gcr.io/google/bazel" 21 | entrypoint: "bash" 22 | args: 23 | - -c 24 | - ./testing/e2e/scala_image.sh test_scala_image -c opt 25 | 26 | - name: "l.gcr.io/google/bazel" 27 | entrypoint: "bash" 28 | args: 29 | - -c 30 | - ./testing/e2e/scala_image.sh test_scala_image -c dbg 31 | 32 | - name: "l.gcr.io/google/bazel" 33 | entrypoint: "bash" 34 | args: 35 | - -c 36 | - ./testing/e2e/scala_image.sh test_scala_sandwich_image -c opt 37 | 38 | - name: "l.gcr.io/google/bazel" 39 | entrypoint: "bash" 40 | args: 41 | - -c 42 | - ./testing/e2e/scala_image.sh test_scala_sandwich_image -c dbg 43 | -------------------------------------------------------------------------------- /testing/e2e/groovy_image.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | # Copyright 2015 The Bazel Authors. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | source ./testing/e2e/util.sh 17 | 18 | # Tests for groovy_image 19 | 20 | # Must be invoked from the root of the repo. 21 | ROOT=$PWD 22 | 23 | function test_groovy_image() { 24 | cd "${ROOT}" 25 | clear_docker 26 | EXPECT_CONTAINS "$(bazel run "$@" tests/container/groovy:groovy_image)" "Hello World" 27 | } 28 | 29 | function test_groovy_scala_image() { 30 | cd "${ROOT}" 31 | clear_docker 32 | EXPECT_CONTAINS "$(bazel run "$@" testdata:groovy_scala_image)" "Hello World" 33 | } 34 | 35 | # Call functions above with 3 parameters: 1st parameter is name of function, 36 | # 2nd and 3rd # passed as args 37 | # (simple approach to make migration easy for e2e.sh) 38 | $1 $2 $3 39 | -------------------------------------------------------------------------------- /testing/e2e/scala_image.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | # Copyright 2015 The Bazel Authors. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | source ./testing/e2e/util.sh 17 | 18 | # Tests for scala_image 19 | 20 | # Must be invoked from the root of the repo. 21 | ROOT=$PWD 22 | 23 | function test_scala_image() { 24 | cd "${ROOT}" 25 | clear_docker 26 | EXPECT_CONTAINS "$(bazel run "$@" tests/container/scala:scala_image)" "Hello World" 27 | } 28 | 29 | function test_scala_sandwich_image() { 30 | cd "${ROOT}" 31 | clear_docker 32 | EXPECT_CONTAINS "$(bazel run "$@" testdata:scala_sandwich_image)" "Hello World" 33 | } 34 | 35 | # Call functions above with 3 parameters: 1st parameter is name of function, 36 | # 2nd and 3rd # passed as args 37 | # (simple approach to make migration easy for e2e.sh) 38 | $1 $2 $3 39 | -------------------------------------------------------------------------------- /repositories/deps.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Once recursive workspace is implemented in Bazel, this file should cease 16 | # to exist. 17 | """ 18 | Provides functions to pull all external package dependencies of this 19 | repository. 20 | """ 21 | 22 | load(":go_repositories.bzl", "go_deps") 23 | load(":images.bzl", "images") 24 | load(":py_repositories.bzl", "py_deps") 25 | 26 | def deps(): 27 | """Pull in external dependencies needed by rules in this repo. 28 | 29 | Pull in all dependencies needed to run rules in this 30 | repository. This function assumes the repositories imported by the macro 31 | 'repositories' in //repositories:repositories.bzl have been imported 32 | already. 33 | """ 34 | go_deps() 35 | py_deps() 36 | images() 37 | -------------------------------------------------------------------------------- /container/testenv.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2015 The Bazel Authors. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Integration test for docker, test environment. 18 | 19 | [ -z "$TEST_SRCDIR" ] && { echo "TEST_SRCDIR not set!" >&2; exit 1; } 20 | 21 | # Load the unit-testing framework 22 | # source "${TEST_SRCDIR}/io_bazel/src/test/shell/unittest.bash" || \ 23 | # { echo "Failed to source unittest.bash" >&2; exit 1; } 24 | 25 | function fail() { 26 | echo "FAILURE: $1" 27 | exit 1 28 | } 29 | 30 | # Die if "$1" != "$2", print $3 as death reason 31 | check_eq () { 32 | echo Checking "$1" = "$2" 33 | [ "$1" = "$2" ] || fail "Check failed: '$1' == '$2' ${3:+ ($3)}" 34 | } 35 | 36 | readonly TEST_DATA_DIR="${TEST_SRCDIR}/io_bazel_rules_docker/testdata" 37 | 38 | readonly TEST_DATA_TARGET_BASE="testdata" 39 | -------------------------------------------------------------------------------- /repositories/pip_repositories.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Once recursive workspace is implemented in Bazel, this file should cease 16 | # to exist. 17 | """ 18 | Provides functions to pull all Python external package dependencies of this 19 | repository. 20 | """ 21 | 22 | load("@pip_deps//:requirements.bzl", "pip_install") 23 | 24 | def pip_deps(): 25 | """Pull in external pip packages needed by py binaries in this repo. 26 | 27 | Pull in all pip dependencies needed to build the Py binaries in this 28 | repository. This function assumes the repositories imported by the macros 29 | 'repositories' in //repositories:repositories.bzl and 'py_deps' in 30 | //repositories:py_repositories.bzl have been imported 31 | already. 32 | """ 33 | pip_install() 34 | -------------------------------------------------------------------------------- /tests/container/python/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//contrib:test.bzl", "container_test") 16 | load("//python:image.bzl", "py_image") 17 | 18 | package(default_visibility = ["//visibility:public"]) 19 | 20 | py_library( 21 | name = "py_image_library", 22 | srcs = ["//testdata:py_image_library.py"], 23 | ) 24 | 25 | py_image( 26 | name = "py_image", 27 | srcs = ["//testdata:py_image.py"], 28 | args = [ 29 | "arg0", 30 | "arg1", 31 | "$(location :BUILD)", 32 | ], 33 | data = [":BUILD"], 34 | layers = [ 35 | ":py_image_library", 36 | ], 37 | ) 38 | 39 | container_test( 40 | name = "py_image_test", 41 | configs = ["//tests/container/python/configs:py_image.yaml"], 42 | image = ":py_image", 43 | ) 44 | -------------------------------------------------------------------------------- /tests/container/windowsservercore.1803.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "architecture": "amd64", 3 | "config": { 4 | "Hostname": "", 5 | "Domainname": "", 6 | "User": "", 7 | "AttachStdin": false, 8 | "AttachStdout": false, 9 | "AttachStderr": false, 10 | "Tty": false, 11 | "OpenStdin": false, 12 | "StdinOnce": false, 13 | "Env": null, 14 | "Cmd": [ 15 | "c:\\windows\\system32\\cmd.exe" 16 | ], 17 | "Image": "", 18 | "Volumes": null, 19 | "WorkingDir": "", 20 | "Entrypoint": null, 21 | "OnBuild": null, 22 | "Labels": null 23 | }, 24 | "created": "2018-07-10T15:03:09.8411592-07:00", 25 | "history": [ 26 | { 27 | "created": "2018-04-12T09:20:54.053Z", 28 | "created_by": "Apply image 10.0.17134.1" 29 | }, 30 | { 31 | "created": "2018-07-07T22:48:41.6201766Z", 32 | "created_by": "Install update 10.0.17134.165" 33 | } 34 | ], 35 | "os": "windows", 36 | "os.version": "10.0.17134.165", 37 | "rootfs": { 38 | "type": "layers", 39 | "diff_ids": [ 40 | "sha256:70bba925263c1c193fa7bc7f79b1aa062707b09fe7774c7896b8aaf091b901a9", 41 | "sha256:aa10afa36c78a1a1775d9bb44d90cfe5cfe3f93fd6b48cba8a2586661a0e4da6" 42 | ] 43 | } 44 | } -------------------------------------------------------------------------------- /container/go/cmd/digester/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | # Copyright 2017 The Bazel Authors. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ### 17 | # Build file for digester binary based on go-containerregistry backend. 18 | 19 | go_library( 20 | name = "go_default_library", 21 | srcs = ["digester.go"], 22 | importpath = "github.com/bazelbuild/rules_docker/container/go/cmd/digester", 23 | visibility = ["//visibility:private"], 24 | deps = [ 25 | "//container/go/pkg/compat:go_default_library", 26 | "//container/go/pkg/oci:go_default_library", 27 | "//container/go/pkg/utils:go_default_library", 28 | ], 29 | ) 30 | 31 | go_binary( 32 | name = "digester", 33 | embed = [":go_default_library"], 34 | visibility = ["//visibility:public"], 35 | ) 36 | -------------------------------------------------------------------------------- /testdata/Servlet.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples.images; 16 | 17 | import examples.Library; 18 | 19 | import java.io.IOException; 20 | import java.io.PrintWriter; 21 | 22 | import javax.servlet.annotation.WebServlet; 23 | import javax.servlet.http.HttpServlet; 24 | import javax.servlet.http.HttpServletRequest; 25 | import javax.servlet.http.HttpServletResponse; 26 | 27 | // Based on the GAE Flexible Hello World sample. 28 | @WebServlet(name = "helloworld", value = "") 29 | @SuppressWarnings("serial") 30 | public class Servlet extends HttpServlet { 31 | 32 | @Override 33 | public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { 34 | PrintWriter out = resp.getWriter(); 35 | out.println(Library.SayHello()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /testing/examples/basic/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_docker//container:container.bzl", "container_image") 16 | load("@io_bazel_rules_docker//contrib:test.bzl", "container_test") 17 | 18 | container_image( 19 | name = "basic_alpine", 20 | base = "@alpine_linux_amd64//image", 21 | cmd = ["Hello World!"], 22 | entrypoint = ["echo"], 23 | ) 24 | 25 | # Tests 26 | 27 | container_test( 28 | name = "basic_alpine_bazel_test", 29 | configs = ["//basic/test_configs:basic_alpine.yaml"], 30 | image = ":basic_alpine", 31 | ) 32 | 33 | container_test( 34 | name = "basic_alpine_dockerfile_test", 35 | configs = ["//basic/test_configs:basic_alpine.yaml"], 36 | driver = "tar", 37 | image = "@basic_alpine_dockerfile//image:dockerfile_image", 38 | ) 39 | -------------------------------------------------------------------------------- /testing/e2e/test_docker_run_flags.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify docker run flags features 16 | 17 | steps: 18 | - name: "l.gcr.io/google/bazel" 19 | entrypoint: "bash" 20 | args: 21 | - -c 22 | - ./testing/e2e/docker_run_flags.sh test_docker_run_flags_use_default 23 | 24 | - name: "l.gcr.io/google/bazel" 25 | entrypoint: "bash" 26 | args: 27 | - -c 28 | - ./testing/e2e/docker_run_flags.sh test_docker_run_flags_override_default 29 | 30 | - name: "l.gcr.io/google/bazel" 31 | entrypoint: "bash" 32 | args: 33 | - -c 34 | - ./testing/e2e/docker_run_flags.sh test_docker_run_flags_inherit_from_base 35 | 36 | - name: "l.gcr.io/google/bazel" 37 | entrypoint: "bash" 38 | args: 39 | - -c 40 | - ./testing/e2e/docker_run_flags.sh test_docker_run_flags_overrides_base 41 | -------------------------------------------------------------------------------- /tests/container/build_tar_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Tests for container build_tar tool""" 15 | 16 | from container.build_tar import TarFile 17 | from contextlib import contextmanager 18 | import unittest 19 | 20 | 21 | class BuildTarTest(unittest.TestCase): 22 | 23 | def testPackageNameParserValidMetadata(self): 24 | metadata = """ 25 | Package: test 26 | Description: Dummy 27 | Version: 1.2.4 28 | """ 29 | self.assertEqual('test', TarFile.parse_pkg_name(metadata, "test.deb")) 30 | 31 | def testPackageNameParserInvalidMetadata(self): 32 | metadata = "Package Name: Invalid" 33 | self.assertEqual('test-invalid-pkg', 34 | TarFile.parse_pkg_name(metadata, "some/path/test-invalid-pkg.deb")) 35 | 36 | 37 | if __name__ == '__main__': 38 | unittest.main() 39 | -------------------------------------------------------------------------------- /container/go/cmd/loader/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ### 15 | # Build file for new puller binary based on go-containerregistry backend. 16 | 17 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 18 | 19 | go_library( 20 | name = "go_default_library", 21 | srcs = ["loader.go"], 22 | importpath = "github.com/bazelbuild/rules_docker/container/go/cmd/loader", 23 | visibility = ["//visibility:private"], 24 | deps = [ 25 | "//container/go/pkg/compat:go_default_library", 26 | "@com_github_google_go_containerregistry//pkg/v1/tarball:go_default_library", 27 | "@com_github_pkg_errors//:go_default_library", 28 | ], 29 | ) 30 | 31 | go_binary( 32 | name = "loader", 33 | embed = [":go_default_library"], 34 | visibility = ["//visibility:public"], 35 | ) 36 | -------------------------------------------------------------------------------- /tests/contrib/rename_image_test.sh: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | #!/bin/bash 16 | 17 | function extract_image_name () { 18 | # Extracts the image name (repo:tag) from the tarball without running it 19 | # Does not require docker to be installed 20 | 21 | image_tar=$1 22 | 23 | tar -xf "$image_tar" "manifest.json" 24 | i=1 25 | while [ true ] 26 | do 27 | if [ "$(cut -d '"' -f$i manifest.json)" = "RepoTags" ] 28 | then 29 | image_name=$(cut -d '"' -f$(expr $i + 2) manifest.json) 30 | break 31 | fi 32 | i=$(expr $i + 1) 33 | done 34 | echo $image_name 35 | } 36 | 37 | set -ex 38 | 39 | image_tar=$1 40 | new_image_name=$2 41 | 42 | if [ $(extract_image_name $image_tar) = $new_image_name ] 43 | then 44 | exit 0 45 | else 46 | exit 1 47 | fi 48 | -------------------------------------------------------------------------------- /tests/container/configs/verify_new_pusher.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify the new pusher new_container_push correctly pushed embedded 16 | # files and layers. 17 | schemaVersion: 2.0.0 18 | 19 | metadataTest: 20 | env: 21 | - key: "PATH" 22 | value: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tmp/a" 23 | - key: "a" 24 | value: "b" 25 | entrypoint: ['echo'] 26 | cmd: ['Hello World!'] 27 | 28 | fileExistenceTests: 29 | - name: 'file_in_layer_exists' 30 | path: '/baz' 31 | shouldExist: true 32 | 33 | - name: 'tar_in_layer_exists' 34 | path: '/three/three' 35 | shouldExist: true 36 | 37 | - name: 'file_foo_exists' 38 | path: '/foo' 39 | shouldExist: true 40 | 41 | - name: 'file_bar_exists' 42 | path: '/bar' 43 | shouldExist: true 44 | -------------------------------------------------------------------------------- /tests/container/java/configs/java_runfiles_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | env: 5 | - key: JAVA_RUNFILES 6 | value: "/app" 7 | entrypoint: [ 8 | '/usr/bin/java', 9 | '-cp', 10 | '/app/io_bazel_rules_docker/../bazel_tools/tools/java/runfiles/librunfiles.jar:/app/io_bazel_rules_docker/tests/container/java/java_runfiles_image.binary.jar:/app/io_bazel_rules_docker/tests/container/java/java_runfiles_image.binary:/app/io_bazel_rules_docker/testdata/foo', 11 | 'examples.images.Runfiles'] 12 | 13 | fileExistenceTests: 14 | - name: 'librunfiles.jar' 15 | path: '/app/bazel_tools/tools/java/runfiles/librunfiles.jar' 16 | shouldExist: true 17 | permissions: '-r-xr-xr-x' 18 | 19 | - name: 'classpath file' 20 | path: '/app/io_bazel_rules_docker/tests/container/java/java_runfiles_image.classpath' 21 | shouldExist: true 22 | permissions: '-r-xr-xr-x' 23 | 24 | - name: 'java_runfiles_image.binary' 25 | path: '/app/io_bazel_rules_docker/tests/container/java/java_runfiles_image.binary' 26 | shouldExist: true 27 | permissions: '-r-xr-xr-x' 28 | 29 | - name: 'java_runfiles_image.binary.jar' 30 | path: '/app/io_bazel_rules_docker/tests/container/java/java_runfiles_image.binary.jar' 31 | shouldExist: true 32 | permissions: '-r-xr-xr-x' 33 | 34 | - name: 'foo data file' 35 | path: '/app/io_bazel_rules_docker/testdata/foo' 36 | shouldExist: true 37 | permissions: '-r-xr-xr-x' 38 | -------------------------------------------------------------------------------- /testing/examples/java_app/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_docker//contrib:test.bzl", "container_test") 16 | load("@io_bazel_rules_docker//java:image.bzl", "java_image") 17 | 18 | java_image( 19 | name = "java_app_bazel", 20 | srcs = [ 21 | "image_data/Greeting.java", 22 | "image_data/ProjectRunner.java", 23 | ], 24 | main_class = "ProjectRunner", 25 | ) 26 | 27 | # Tests 28 | 29 | container_test( 30 | name = "java_app_bazel_test", 31 | configs = ["//java_app/test_configs:java_app_bazel.yaml"], 32 | image = ":java_app_bazel", 33 | ) 34 | 35 | container_test( 36 | name = "java_app_dockerfile_test", 37 | configs = ["//java_app/test_configs:java_app_dockerfile.yaml"], 38 | driver = "tar", 39 | image = "@java_app_dockerfile//image:dockerfile_image", 40 | ) 41 | -------------------------------------------------------------------------------- /testdata/launcher_main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // This file is used to test the launcher attr of container_image 16 | package main 17 | 18 | import ( 19 | "flag" 20 | "fmt" 21 | "os" 22 | "syscall" 23 | ) 24 | 25 | func main() { 26 | var extraEnv stringSlice 27 | flag.Var(&extraEnv, "env", "Append to the environment of the launched binary. May be specified multiple times. (eg --env=VAR_NAME=value)") 28 | flag.Parse() 29 | envv := append(os.Environ(), extraEnv...) 30 | argv := flag.Args() 31 | err := syscall.Exec(argv[0], argv, envv) 32 | if err != nil { 33 | panic(err) 34 | } 35 | } 36 | 37 | type stringSlice []string 38 | 39 | func (i *stringSlice) String() string { 40 | return fmt.Sprintf("%s", *i) 41 | } 42 | 43 | func (i *stringSlice) Set(v string) error { 44 | *i = append(*i, v) 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /container/go/pkg/utils/utils.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Bazel Authors. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | ////////////////////////////////////////////////////////////////////// 15 | package utils 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | // ArrayStringFlags are defined for string flags that may have multiple values. 22 | type ArrayStringFlags []string 23 | 24 | // Returns the concatenated string representation of the array of flags. 25 | func (f *ArrayStringFlags) String() string { 26 | return fmt.Sprintf("%v", *f) 27 | } 28 | 29 | // Get returns an empty interface that may be type-asserted to the underlying 30 | // value of type bool, string, etc. 31 | func (f *ArrayStringFlags) Get() interface{} { 32 | return "" 33 | } 34 | 35 | // Set appends value the array of flags. 36 | func (f *ArrayStringFlags) Set(value string) error { 37 | *f = append(*f, value) 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /contrib/kaniko_run_and_extract.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2017 The Bazel Authors. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -ex 18 | 19 | # This is a generated file that runs Kaniko inside a docker container, waits for 20 | # it to finish running and copies the generated image tarball out of it. 21 | 22 | # Copy the build context into the container. 23 | data=$(%{docker_path} create -v %{kaniko_workspace} %{image_path}) 24 | %{docker_path} cp %{build_context_dir}/. ${data}:%{kaniko_workspace} 25 | 26 | # Run the Kaniko executor container to build the image and extract as a tarball. 27 | id=$(%{docker_path} run -d --volumes-from ${data} %{image_path} \ 28 | --context=%{kaniko_workspace} --tarPath=%{extract_file} %{kaniko_flags}) 29 | 30 | %{docker_path} wait $id 31 | %{docker_path} logs $id 32 | %{docker_path} cp $id:%{extract_file} %{output} 33 | %{docker_path} rm $id ${data} 34 | -------------------------------------------------------------------------------- /tests/container/cc/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//cc:image.bzl", "cc_image") 16 | load("//contrib:test.bzl", "container_test") 17 | 18 | package(default_visibility = ["//visibility:public"]) 19 | 20 | cc_library( 21 | name = "cc_image_library", 22 | srcs = ["//testdata:cc_image_library.cc"], 23 | hdrs = ["//testdata:cc_image_library.h"], 24 | ) 25 | 26 | cc_image( 27 | name = "cc_image", 28 | srcs = ["//testdata:cc_image.cc"], 29 | args = [ 30 | "arg0", 31 | "arg1", 32 | "$(location :BUILD)", 33 | ], 34 | data = [":BUILD"], 35 | # This creates an empty layer, due to linking. 36 | layers = [":cc_image_library"], 37 | ) 38 | 39 | container_test( 40 | name = "cc_image_test", 41 | configs = ["//tests/container/cc/configs:cc_image.yaml"], 42 | image = ":cc_image", 43 | ) 44 | -------------------------------------------------------------------------------- /tests/docker/toolchain_container/tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | schemaVersion: "2.0.0" 16 | 17 | commandTests: 18 | - name: 'check-bazel' 19 | command: 'bazel' 20 | args: ['version'] 21 | expectedOutput: ['Build label: *'] 22 | # 'check-ar' is used to test binutils. 23 | - name: 'check-ar' 24 | command: 'ar' 25 | args: ['--version'] 26 | expectedOutput: ['GNU ar .*'] 27 | - name: 'check-unzip' 28 | command: 'unzip' 29 | expectedOutput: ['.*Usage: unzip .*'] 30 | - name: 'check-zip' 31 | command: 'zip' 32 | args: ['--version'] 33 | expectedOutput: ['.*This is Zip.*'] 34 | - name: 'check-git' 35 | command: 'git' 36 | args: ['--version'] 37 | expectedOutput: ['git version .*'] 38 | - name: 'check-wget' 39 | command: 'wget' 40 | args: ['--version'] 41 | expectedOutput: ['GNU Wget.* built on linux-gnu.*'] 42 | 43 | -------------------------------------------------------------------------------- /testdata/test/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_docker//python:image.bzl", "py_image") 16 | load("@pip_deps//:requirements.bzl", "all_requirements", "requirement") 17 | 18 | package(default_visibility = ["//testdata:__subpackages__"]) 19 | 20 | filegroup( 21 | name = "srcs", 22 | srcs = glob(["**"]), 23 | ) 24 | 25 | filegroup( 26 | name = "test-data", 27 | srcs = ["test"], 28 | ) 29 | 30 | py_library( 31 | name = "py_image_library_using_addict", 32 | srcs = ["py_image_library_using_addict.py"], 33 | deps = [requirement("addict")], 34 | ) 35 | 36 | # For end to end testing of py_image dependencies specified as "layers" 37 | py_image( 38 | name = "py_image_using_layers", 39 | srcs = ["py_image_using_layers.py"], 40 | layers = all_requirements, 41 | main = "py_image_using_layers.py", 42 | ) 43 | -------------------------------------------------------------------------------- /testing/e2e/test_cc_image.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Tests that verify cc_image 16 | 17 | steps: 18 | - name: "l.gcr.io/google/bazel" 19 | entrypoint: "bash" 20 | args: 21 | - -c 22 | - ./testing/e2e/cc_image.sh test_cc_image -c opt 23 | 24 | - name: "l.gcr.io/google/bazel" 25 | entrypoint: "bash" 26 | args: 27 | - -c 28 | - ./testing/e2e/cc_image.sh test_cc_image -c dbg 29 | 30 | - name: "l.gcr.io/google/bazel" 31 | entrypoint: "bash" 32 | args: 33 | - -c 34 | - ./testing/e2e/cc_image.sh test_cc_binary_as_image -c opt 35 | 36 | - name: "l.gcr.io/google/bazel" 37 | entrypoint: "bash" 38 | args: 39 | - -c 40 | - ./testing/e2e/cc_image.sh test_cc_binary_as_image -c dbg 41 | 42 | - name: "l.gcr.io/google/bazel" 43 | entrypoint: "bash" 44 | args: 45 | - -c 46 | - ./testing/e2e/cc_image.sh test_cc_image_wrapper 47 | -------------------------------------------------------------------------------- /tests/contrib/automatic_container_release/deps_spec_no_fus_deps.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | revisionsFilePath: "layers/ubuntu1604/bazel/revisions.bzl" 16 | timestampFilePath: "layers/ubuntu1604/bazel/autogenerated_dus_timestamp.txt" 17 | 18 | # GCS deps where none of the dependencies are FUS deps. This spec is meant to 19 | # be used to validate a configs_test rule invocation where there are no 20 | # file_updates.yaml to validate. 21 | gcsDeps: 22 | 23 | # Bazel release installer. 24 | - name: "BAZEL_INSTALLER" 25 | bucket: "bazel" 26 | versionRegex: "\\d+(\\.\\d+)*" 27 | fileRegex: "^\\d+(\\.\\d+)*/release/bazel-\\d+(\\.\\d+)*-installer-linux-x86_64\\.sh\\.sha256$" 28 | excludes: "/rc" 29 | readShaFromFile: true 30 | startIndex: 0 31 | releasePolicies: 32 | - tag: "default" 33 | # Release immediately for new bazel releases. 34 | schedule: "* * * * * *" 35 | -------------------------------------------------------------------------------- /update_deps.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2017 The Bazel Authors. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -eu 17 | set -o pipefail 18 | 19 | bazel run tools:update_deps -- --repository=gcr.io/distroless/base --output=$PWD/go/go.bzl 20 | bazel run tools:update_deps -- --repository=gcr.io/distroless/static --output=$PWD/go/static.bzl 21 | bazel run tools:update_deps -- --repository=gcr.io/distroless/cc --output=$PWD/cc/cc.bzl 22 | bazel run tools:update_deps -- --repository=gcr.io/distroless/python2.7 --output=$PWD/python/python.bzl 23 | bazel run tools:update_deps -- --repository=gcr.io/distroless/python3 --output=$PWD/python3/python3.bzl 24 | bazel run tools:update_deps -- --repository=gcr.io/distroless/java --output=$PWD/java/java.bzl 25 | bazel run tools:update_deps -- --repository=gcr.io/distroless/java/jetty --output=$PWD/java/jetty.bzl 26 | bazel run tools:update_deps -- --repository=gcr.io/google-appengine/debian9 --output=$PWD/nodejs/nodejs.bzl 27 | -------------------------------------------------------------------------------- /testdata/pause_piecemeal_gz/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//container:container.bzl", "container_import") 16 | load("//testdata/pause_piecemeal:layers.bzl", "PAUSE_LAYERS") 17 | 18 | package(default_visibility = ["//visibility:public"]) 19 | 20 | licenses(["notice"]) # Apache 2.0 21 | 22 | [genrule( 23 | name = "extract_%s_gz" % id, 24 | srcs = ["//testdata:pause.tar"], 25 | outs = ["%s.tar.gz" % id], 26 | cmd = ("tar xOf $(location //testdata:pause.tar) %s/layer.tar " + 27 | "| gzip -n > $(location :%s.tar.gz)") % (id, id), 28 | ) for id in PAUSE_LAYERS] 29 | 30 | # this needs to be in a seperate package than the rest of the testdata because 31 | # it generates identically named artifacts as pause_piecemeal. 32 | container_import( 33 | name = "image", 34 | config = "//testdata/pause_piecemeal:pause_config.json", 35 | layers = ["%s.tar.gz" % x for x in PAUSE_LAYERS], 36 | ) 37 | --------------------------------------------------------------------------------