├── .bazelci └── presubmit.yml ├── .bazelignore ├── .bazelrc ├── .bazelversion ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── add_binaries_to_release.yml │ └── release.yml ├── .gitignore ├── .pre-commit-config.yaml ├── AUTHORS ├── BUILD ├── CONTRIBUTING.md ├── CONTRIBUTORS ├── LICENSE ├── README.md ├── WORKSPACE ├── cc ├── BUILD ├── cc.bzl └── image.bzl ├── cloudbuild.yaml ├── container ├── BUILD ├── archive.py ├── build_tar.py ├── bundle.bzl ├── container.bzl ├── container.docs.bzl ├── flatten.bzl ├── go │ ├── cloudbuild.yaml │ ├── cmd │ │ ├── create_image_config │ │ │ ├── BUILD │ │ │ └── create_image_config.go │ │ ├── digester │ │ │ ├── BUILD │ │ │ └── digester.go │ │ ├── extract_config │ │ │ ├── BUILD │ │ │ └── extract_config.go │ │ ├── flattener │ │ │ ├── BUILD │ │ │ └── flattener.go │ │ ├── join_layers │ │ │ ├── BUILD │ │ │ └── join_layers.go │ │ ├── loader │ │ │ ├── BUILD │ │ │ └── loader.go │ │ ├── puller │ │ │ ├── BUILD │ │ │ └── puller.go │ │ ├── pusher │ │ │ ├── BUILD │ │ │ └── pusher.go │ │ ├── sha256 │ │ │ ├── BUILD │ │ │ └── sha256.go │ │ ├── update_deps │ │ │ ├── BUILD │ │ │ └── update_deps.go │ │ └── zipper │ │ │ ├── BUILD │ │ │ └── zipper.go │ └── pkg │ │ ├── compat │ │ ├── BUILD │ │ ├── config.go │ │ ├── config_test.go │ │ ├── image.go │ │ ├── reader.go │ │ ├── write.go │ │ └── write_test.go │ │ ├── oci │ │ ├── BUILD │ │ ├── image.go │ │ ├── reader.go │ │ ├── reader_test.go │ │ ├── testdata │ │ │ ├── test_index1 │ │ │ │ ├── blobs │ │ │ │ │ └── sha256 │ │ │ │ │ │ ├── 26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 │ │ │ │ │ │ ├── 2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca │ │ │ │ │ │ ├── 3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af │ │ │ │ │ │ ├── 4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46 │ │ │ │ │ │ └── 93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569 │ │ │ │ ├── index.json │ │ │ │ └── oci-layout │ │ │ ├── test_index2 │ │ │ │ ├── blobs │ │ │ │ │ └── sha256 │ │ │ │ │ │ ├── 26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 │ │ │ │ │ │ ├── 2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca │ │ │ │ │ │ ├── 3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af │ │ │ │ │ │ ├── 4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46 │ │ │ │ │ │ └── 93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569 │ │ │ │ └── oci-layout │ │ │ ├── test_index3 │ │ │ │ ├── blobs │ │ │ │ │ └── sha256 │ │ │ │ │ │ ├── 26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 │ │ │ │ │ │ ├── 2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca │ │ │ │ │ │ ├── 3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af │ │ │ │ │ │ └── 93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569 │ │ │ │ ├── index.json │ │ │ │ └── oci-layout │ │ │ ├── test_index4 │ │ │ │ ├── blobs │ │ │ │ │ └── sha256 │ │ │ │ │ │ ├── 26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 │ │ │ │ │ │ ├── 2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca │ │ │ │ │ │ ├── 3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af │ │ │ │ │ │ └── 4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46 │ │ │ │ ├── index.json │ │ │ │ └── oci-layout │ │ │ ├── test_index5 │ │ │ │ ├── blobs │ │ │ │ │ └── sha256 │ │ │ │ │ │ ├── 2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca │ │ │ │ │ │ ├── 3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af │ │ │ │ │ │ ├── 4817a495758a70edcaa9ed6723cd927f21c44e2061313b03aaf5d5ae2c1bff46 │ │ │ │ │ │ └── 93cd8b73a9da05da6e1a9739e3610cbb0f19439d693931d3bf011d1d92b9e569 │ │ │ │ ├── index.json │ │ │ │ └── oci-layout │ │ │ └── test_write1 │ │ │ │ └── small_linux.tar │ │ ├── write.go │ │ └── write_test.go │ │ └── utils │ │ ├── BUILD │ │ └── utils.go ├── image.bzl ├── import.bzl ├── incremental_load.sh.tpl ├── layer.bzl ├── layer_tools.bzl ├── load.bzl ├── providers.bzl ├── pull.bzl ├── push-tag.bat.tpl ├── push-tag.sh.tpl ├── push.bzl └── testenv.sh ├── contrib ├── BUILD ├── automatic_container_release │ ├── BUILD │ ├── configs_test.bzl │ ├── metadata_merge.bzl │ ├── packages_metadata.bzl │ └── run_checker.sh.tpl ├── cmp_images.sh.tpl ├── compare_ids_test.bzl ├── compare_ids_test.py ├── dockerfile_build.bzl ├── extract_image_id.py ├── extract_last_layer.py ├── go │ ├── cmd │ │ ├── metadata_merge │ │ │ ├── BUILD │ │ │ └── metadata_merge.go │ │ └── packages_metadata │ │ │ ├── BUILD │ │ │ └── packages_metadata.go │ └── pkg │ │ └── metadata │ │ ├── BUILD │ │ └── packages.go ├── group.bzl ├── passwd.bzl ├── push-all.bzl ├── push-all.sh.tpl ├── rename_image.bzl ├── repro_test.bzl ├── structure-test.sh.tpl ├── test.bzl ├── with-defaults.bzl └── with-tag.bzl ├── d ├── BUILD └── image.bzl ├── docker ├── BUILD ├── docker.bzl ├── package_managers │ ├── BUILD │ ├── README.md │ ├── apt_key.bzl │ ├── download_pkgs.bzl │ ├── install_pkgs.bzl │ ├── installer.sh.tpl │ ├── run_download.sh.tpl │ └── run_install.sh.tpl ├── security │ ├── BUILD │ ├── cmd │ │ └── json_to_yaml │ │ │ ├── BUILD │ │ │ └── json_to_yaml.go │ ├── security_check.bzl │ ├── security_check.py │ └── security_check_whitelist.json ├── toolchain_container │ ├── BUILD │ ├── README.md │ ├── debian_pkg_tar.bzl │ └── toolchain_container.bzl └── util │ ├── BUILD │ ├── README.md │ ├── commit.sh.tpl │ ├── commit_layer.sh.tpl │ ├── config_stripper.py │ ├── config_stripper_test.py │ ├── extract.sh.tpl │ ├── image_util.sh.tpl │ ├── run.bzl │ ├── testdata │ ├── BUILD │ └── image_with_symlinked_layer.tar │ └── to_json.py ├── docs ├── BUILD └── container.md ├── go ├── BUILD ├── go.bzl ├── image.bzl └── static.bzl ├── groovy ├── BUILD └── image.bzl ├── intermediate-form.md ├── java ├── BUILD ├── image.bzl ├── java.bzl └── jetty.bzl ├── kotlin ├── BUILD └── image.bzl ├── lang ├── BUILD └── image.bzl ├── nodejs ├── BUILD ├── image.bzl └── nodejs.bzl ├── platforms └── BUILD ├── python ├── BUILD ├── image.bzl └── python.bzl ├── python3 ├── BUILD ├── image.bzl └── python3.bzl ├── renovate.json ├── repositories ├── BUILD ├── deps.bzl ├── go_repositories.bzl ├── images.bzl ├── py_repositories.bzl ├── repositories.bzl └── requirements-pip.txt ├── run-bazel-in-docker.sh ├── rust ├── BUILD └── image.bzl ├── scala ├── BUILD └── image.bzl ├── skylib ├── BUILD ├── docker.bzl ├── filetype.bzl ├── hash.bzl ├── label.bzl ├── path.bzl └── zip.bzl ├── stamp ├── BUILD.bazel └── stamp.bzl ├── testdata ├── ArgEcho.java ├── BUILD ├── Binary.groovy ├── Binary.java ├── Binary.kt ├── Binary.scala ├── Library.groovy ├── Library.java ├── Library.kt ├── Library.scala ├── Runfiles.java ├── Servlet.java ├── bar ├── baz ├── cc_image.cc ├── cc_image_library.cc ├── cc_image_library.h ├── cc_image_wrapper.sh ├── dockerfile_build │ ├── BUILD │ ├── Data_file.txt │ ├── Dockerfile │ ├── More_data.txt │ └── file_to_copy.txt ├── extras_gen.py ├── flag_main.go ├── foo ├── gen_deb.py ├── launcher_main.go ├── main.d ├── main.go ├── main.rs ├── nodejs_image.js ├── nodejs_image_lib.ts ├── one.tar ├── package.json ├── pause.tar ├── pause_piecemeal │ ├── BUILD │ └── layers.bzl ├── pause_piecemeal_gz │ └── BUILD ├── py3_image.py ├── py_image.py ├── py_image_complex.py ├── py_image_complex_library.py ├── py_image_library.py ├── py_image_library_using_six.py ├── stamp_info.bzl ├── test │ ├── BUILD │ ├── py_image_library_using_addict.py │ ├── py_image_using_layers.py │ └── test ├── three.tar ├── tsconfig.json ├── two.tar ├── utils.bzl └── yarn.lock ├── testing ├── README.md ├── custom_toolchain_auth │ ├── .gitignore │ ├── BUILD │ └── WORKSPACE ├── custom_toolchain_flags │ ├── BUILD │ ├── WORKSPACE │ └── cloudbuild.yaml ├── default_toolchain │ ├── .gitignore │ ├── BUILD │ ├── WORKSPACE │ └── local_tool.bzl ├── docker-config │ ├── config.json │ ├── config.yml │ └── htpasswd ├── download_pkgs_at_root │ ├── BUILD │ ├── WORKSPACE │ ├── cloudbuild.yaml │ └── download_pkgs_at_root_run_test.sh ├── e2e.sh ├── e2e │ ├── bazel_run_docker.sh │ ├── cc_image.sh │ ├── docker_run_flags.sh │ ├── flag.sh │ ├── go_image.sh │ ├── groovy_image.sh │ ├── java_image.sh │ ├── kt_jvm_image.sh │ ├── launcher.sh │ ├── nodejs_image.sh │ ├── puller.sh │ ├── pusher.sh │ ├── py_image.sh │ ├── scala_image.sh │ ├── test_bazel_run_docker.yaml │ ├── test_cc_image.yaml │ ├── test_docker_run_flags.yaml │ ├── test_flag.yaml │ ├── test_go_image.yaml │ ├── test_groovy_image.yaml │ ├── test_java_image.yaml │ ├── test_kt_jvm_image.yaml │ ├── test_launcher.yaml │ ├── test_nodejs_image.yaml │ ├── test_puller.yaml │ ├── test_pusher.yaml │ ├── test_py_image.yaml │ ├── test_scala_image.yaml │ ├── test_top_level.yaml │ ├── top_level.sh │ └── util.sh ├── examples │ ├── BUILD │ ├── README.md │ ├── WORKSPACE │ ├── basic │ │ ├── BUILD │ │ ├── Dockerfile │ │ ├── cloudbuild.yaml │ │ └── test_configs │ │ │ ├── BUILD │ │ │ └── basic_alpine.yaml │ ├── extended │ │ ├── BUILD │ │ ├── Dockerfile │ │ ├── cloudbuild.yaml │ │ ├── image_data │ │ │ ├── BUILD │ │ │ ├── Data_file.txt │ │ │ ├── More_data.txt │ │ │ ├── file_to_copy.txt │ │ │ └── tarfile.tar │ │ └── test_configs │ │ │ ├── BUILD │ │ │ └── extended_alpine.yaml │ ├── java_app │ │ ├── BUILD │ │ ├── Dockerfile │ │ ├── cloudbuild.yaml │ │ ├── image_data │ │ │ ├── Greeting.java │ │ │ └── ProjectRunner.java │ │ └── test_configs │ │ │ ├── BUILD │ │ │ ├── java_app_bazel.yaml │ │ │ └── java_app_dockerfile.yaml │ ├── run_instruction_apt_pkgs │ │ ├── BUILD │ │ ├── Dockerfile │ │ ├── cloudbuild.yaml │ │ └── test_configs │ │ │ ├── BUILD │ │ │ └── java_python.yaml │ └── run_instruction_arbitrary │ │ ├── BUILD │ │ ├── Dockerfile │ │ ├── cloudbuild.yaml │ │ └── test_configs │ │ ├── BUILD │ │ └── bazel_gcloud.yaml ├── java_image │ ├── BUILD │ ├── Gzip.java │ ├── Runfiles.java │ ├── WORKSPACE │ ├── cloudbuild.yaml │ └── foo └── new_pusher_tests │ ├── BUILD │ └── WORKSPACE ├── tests ├── BUILD ├── container │ ├── BUILD │ ├── apple.bzl │ ├── architecture_test.sh │ ├── build_tar_test.py │ ├── cc │ │ ├── BUILD │ │ └── configs │ │ │ ├── BUILD │ │ │ └── cc_image.yaml │ ├── cloudbuild.yaml │ ├── configs │ │ ├── BUILD │ │ ├── alpine_amd64.yaml │ │ ├── alpine_arm.yaml │ │ ├── alpine_ppc64le.yaml │ │ ├── deb_image_with_dpkgs.yaml │ │ ├── null_cmd_and_entrypoint.yaml │ │ ├── set_cmd.yaml │ │ ├── set_cmd_and_entrypoint.yaml │ │ ├── set_entrypoint.yaml │ │ ├── set_env_csv.yaml │ │ ├── set_env_equals.yaml │ │ ├── set_env_make_vars.yaml │ │ ├── special_characters.yaml │ │ ├── stripped_directory_name.yaml │ │ ├── test.yaml │ │ ├── transitions_off.yaml.tpl │ │ ├── transitions_on.yaml │ │ ├── verify_new_pusher.yaml │ │ └── windows_image.yaml │ ├── empty_layers.bzl │ ├── go │ │ ├── BUILD │ │ └── configs │ │ │ ├── BUILD │ │ │ ├── go_image.yaml │ │ │ └── go_static_image.yaml │ ├── groovy │ │ ├── BUILD │ │ └── configs │ │ │ ├── BUILD │ │ │ ├── groovy_classpath_as_file_image.yaml │ │ │ └── groovy_image.yaml │ ├── image_test.py │ ├── java │ │ ├── BUILD │ │ └── configs │ │ │ ├── BUILD │ │ │ ├── java_classpath_as_file_image.yaml │ │ │ ├── java_image.yaml │ │ │ ├── java_image_complex_external_deps.yaml │ │ │ ├── java_partial_entrypoint.yaml │ │ │ ├── java_runfiles_as_lib_image.yaml │ │ │ ├── java_runfiles_image.yaml │ │ │ └── simple_java_entrypoint.yaml │ ├── kotlin │ │ ├── BUILD │ │ └── configs │ │ │ ├── BUILD │ │ │ ├── kt_jvm_classpath_as_file_image.yaml │ │ │ └── kt_jvm_image.yaml │ ├── nodejs │ │ ├── BUILD │ │ ├── configs │ │ │ ├── BUILD │ │ │ ├── nodejs_image.yaml │ │ │ ├── nodejs_image_custom_binary.yaml │ │ │ ├── nodejs_image_custom_binary_with_args.yaml │ │ │ ├── nodejs_image_empty_list_args.yaml │ │ │ ├── nodejs_image_list_with_empty_string_args.yaml │ │ │ ├── nodejs_image_no_args.yaml │ │ │ ├── nodejs_image_none_args.yaml │ │ │ ├── nodejs_image_with_launcher.yaml │ │ │ └── nodejs_image_with_launcher_args.yaml │ │ └── launcher.sh │ ├── pull_info_validation_test.bzl │ ├── python │ │ ├── BUILD │ │ └── configs │ │ │ ├── BUILD │ │ │ └── py_image.yaml │ ├── python3 │ │ ├── BUILD │ │ └── configs │ │ │ ├── BUILD │ │ │ └── py3_image.yaml │ ├── rust │ │ ├── BUILD │ │ └── configs │ │ │ ├── BUILD │ │ │ └── rust_image.yaml │ ├── scala │ │ ├── BUILD │ │ └── configs │ │ │ ├── BUILD │ │ │ ├── scala_classpath_as_file_image.yaml │ │ │ └── scala_image.yaml │ ├── testdata │ │ ├── BUILD │ │ └── files │ │ │ ├── aaaa │ │ │ └── aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa │ ├── transitions.bzl │ ├── windowsservercore.1803.config.json │ └── windowsservercore.1803.manifest.json ├── contrib │ ├── BUILD │ ├── automatic_container_release │ │ ├── BUILD │ │ ├── deps_spec.yaml │ │ ├── deps_spec_no_fus_deps.yaml │ │ ├── file_updates.yaml │ │ ├── metadata_merge_file1.yaml │ │ ├── metadata_merge_file2.yaml │ │ ├── metadata_merge_file3.yaml │ │ ├── metadata_merge_file4.yaml │ │ └── packages_metadata.csv │ ├── cloudbuild.yaml │ ├── compare_ids_fail_test.bzl │ ├── compare_ids_fail_test.sh.tpl │ ├── configs │ │ ├── BUILD │ │ └── dockerfile_image.yaml │ ├── mv_project_root.sh │ ├── rename_image_test.sh │ └── repro_imgs.yaml └── docker │ ├── BUILD │ ├── cloudbuild.yaml │ ├── launchpad_openjdk_gpg.pub │ ├── package_managers │ ├── BUILD │ ├── download_pkgs_run_test.sh │ ├── download_pkgs_with_additional_repos_run_test.sh │ ├── gpg_test.yaml │ ├── test_complex_packages.sh │ └── test_complex_packages.yaml │ ├── security │ ├── BUILD │ └── cloudbuild.yaml │ ├── toolchain_container │ ├── BUILD │ └── tests.yaml │ └── util │ ├── BUILD │ ├── container_commit.yaml │ └── container_commit_layer.yaml ├── toolchains ├── BUILD └── docker │ ├── BUILD │ ├── BUILD.tpl │ ├── pull.bzl.tpl │ ├── readme.md │ └── toolchain.bzl ├── transitions └── BUILD └── update_deps.sh /.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 | testing/custom_toolchain_flags 7 | -------------------------------------------------------------------------------- /.bazelversion: -------------------------------------------------------------------------------- 1 | 8.2.0 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @gravypod @linzhp @pcj @smukherj1 @uhthomas 2 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## PR Checklist 2 | 3 | Please check if your PR fulfills the following requirements: 4 | 5 | - [ ] Tests for the changes have been added (for bug fixes / features) 6 | - [ ] Docs have been added / updated (for bug fixes / features) 7 | 8 | 9 | ## PR Type 10 | 11 | What kind of change does this PR introduce? 12 | 13 | 14 | 15 | - [ ] Bugfix 16 | - [ ] Feature 17 | - [ ] Code style update (formatting, local variables) 18 | - [ ] Refactoring (no functional changes, no api changes) 19 | - [ ] Build related changes 20 | - [ ] CI related changes 21 | - [ ] Documentation content changes 22 | - [ ] Other... Please describe: 23 | 24 | 25 | ## What is the current behavior? 26 | 27 | 28 | Issue Number: N/A 29 | 30 | 31 | ## What is the new behavior? 32 | 33 | 34 | ## Does this PR introduce a breaking change? 35 | 36 | - [ ] Yes 37 | - [ ] No 38 | 39 | 40 | 41 | 42 | 43 | ## Other information 44 | 45 | -------------------------------------------------------------------------------- /.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 | !go.mod 19 | *.smod 20 | 21 | # Python 2 bytecode files 22 | *.pyc 23 | 24 | # Compiled Static libraries 25 | *.lai 26 | *.la 27 | *.a 28 | *.lib 29 | 30 | # Executables 31 | *.exe 32 | *.out 33 | *.app 34 | 35 | # Emacs garbage 36 | *~ 37 | 38 | # Vim garbage 39 | *.swp 40 | 41 | # Bazel directories 42 | bazel-* 43 | bazel-bin 44 | bazel-genfiles 45 | bazel-out 46 | bazel-testlogs 47 | 48 | # Bazel IDE dlugin Directories 49 | .ijwb 50 | 51 | # Eclipse and PyDev 52 | .project 53 | .pydevproject 54 | 55 | # Npm packages 56 | node_modules 57 | 58 | # JetBrains garbage 59 | .idea/ 60 | 61 | # MODULE.bazel stuff, for now 62 | MODULE.bazel.lock 63 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # See CONTRIBUTING.md for instructions. 2 | # See https://pre-commit.com for more information 3 | # See https://pre-commit.com/hooks.html for more hooks 4 | repos: 5 | - repo: https://github.com/keith/pre-commit-buildifier 6 | rev: 4.0.1.1 7 | hooks: 8 | - id: buildifier 9 | args: &args 10 | # Keep this argument in sync with .bazelci/presubmit.yml 11 | - --warnings=-function-docstring-args,-print,-provider-params,-unnamed-macro 12 | - id: buildifier-lint 13 | args: *args 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | David Schile 13 | Matthew Moore 14 | Nathan Herring 15 | Nicolas Lopez 16 | Oleksandr Mogilevskyi 17 | Suvanjan Mukherjee 18 | Xin Gao 19 | -------------------------------------------------------------------------------- /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("@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 = "image_bzl", 23 | srcs = ["image.bzl"], 24 | visibility = ["//visibility:private"], 25 | ) 26 | 27 | bzl_library( 28 | name = "cc_bzl", 29 | srcs = ["cc.bzl"], 30 | visibility = ["//visibility:private"], 31 | ) 32 | -------------------------------------------------------------------------------- /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 2022-11-08 11:59 +0900 23 | "debug": "sha256:6865ad48467c89c3c3524d4c426f52ad12d9ab7dec31fad31fae69da40eb6445", 24 | # "gcr.io/distroless/cc:latest" circa 2022-11-08 11:59 +0900 25 | "latest": "sha256:41036fc7ed8df0f6addc18484cef0c94a85867508967789f947e11ffd5ff0cc8", 26 | } 27 | -------------------------------------------------------------------------------- /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 | steps: 16 | # Test the case where the test target is located at the root of the 17 | # workspace, which makes the Bazel package empty. 18 | - name: "l.gcr.io/google/bazel" 19 | args: 20 | - "test" 21 | - "--test_output=errors" 22 | - "--verbose_failures" 23 | - "//:structure_test_at_workspace_root" 24 | -------------------------------------------------------------------------------- /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 = ["extract_config.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/legacy/tarball:go_default_library", 12 | "@com_github_google_go_containerregistry//pkg/name:go_default_library", 13 | "@com_github_google_go_containerregistry//pkg/v1:go_default_library", 14 | "@com_github_google_go_containerregistry//pkg/v1/tarball:go_default_library", 15 | "@com_github_pkg_errors//:go_default_library", 16 | ], 17 | ) 18 | 19 | go_binary( 20 | name = "join_layers", 21 | embed = [":go_default_library"], 22 | visibility = ["//visibility:public"], 23 | ) 24 | -------------------------------------------------------------------------------- /container/go/cmd/sha256/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | # Build file for sha256 binary. 4 | 5 | go_library( 6 | name = "go_default_library", 7 | srcs = ["sha256.go"], 8 | importpath = "github.com/bazelbuild/rules_docker/container/go/cmd/sha256", 9 | visibility = ["//visibility:private"], 10 | ) 11 | 12 | go_binary( 13 | name = "sha256", 14 | embed = [":go_default_library"], 15 | visibility = ["//visibility:public"], 16 | ) 17 | -------------------------------------------------------------------------------- /container/go/cmd/zipper/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 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 zipper binary. 16 | 17 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 18 | 19 | go_binary( 20 | name = "zipper", 21 | embed = [":go_default_library"], 22 | visibility = ["//visibility:public"], 23 | ) 24 | 25 | go_library( 26 | name = "go_default_library", 27 | srcs = ["zipper.go"], 28 | importpath = "github.com/bazelbuild/rules_docker", 29 | visibility = ["//visibility:private"], 30 | ) 31 | -------------------------------------------------------------------------------- /container/go/pkg/compat/write_test.go: -------------------------------------------------------------------------------- 1 | package compat 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/google/go-containerregistry/pkg/v1/empty" 8 | "github.com/google/go-containerregistry/pkg/v1/mutate" 9 | "github.com/google/go-containerregistry/pkg/v1/random" 10 | "github.com/google/go-containerregistry/pkg/v1/types" 11 | ) 12 | 13 | func TestWriteImage(t *testing.T) { 14 | cl, err := random.Layer(256, types.DockerLayer) 15 | if err != nil { 16 | t.Fatalf("Unable to generate a random compressed layer: %v", err) 17 | } 18 | ul, err := random.Layer(256, types.DockerUncompressedLayer) 19 | if err != nil { 20 | t.Fatalf("Unable to generate a random uncompressed layer: %v", err) 21 | } 22 | img, err := mutate.AppendLayers(empty.Image, cl, ul) 23 | if err != nil { 24 | t.Fatalf("Unable to generate a test image with a compressed & uncompressed layer: %v", err) 25 | } 26 | if err := WriteImage(img, os.Getenv("TEST_TMPDIR")); err != nil { 27 | t.Errorf("Unable to write test image: %v", err) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index1/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index1/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index1/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index1/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index1/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index1/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af -------------------------------------------------------------------------------- /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_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_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_index1/oci-layout: -------------------------------------------------------------------------------- 1 | { 2 | "imageLayoutVersion": "1.0.0" 3 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index2/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index2/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index2/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index2/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index2/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index2/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af -------------------------------------------------------------------------------- /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_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_index2/oci-layout: -------------------------------------------------------------------------------- 1 | { 2 | "imageLayoutVersion": "1.0.0" 3 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index3/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index3/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index3/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index3/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index3/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index3/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af -------------------------------------------------------------------------------- /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_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_index3/oci-layout: -------------------------------------------------------------------------------- 1 | { 2 | "imageLayoutVersion": "1.0.0" 3 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index4/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index4/blobs/sha256/26c668c40574f4fefe17ddfbc3a8744a5b83b8c00a03dff790cbe6a397f66d79 -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index4/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index4/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index4/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index4/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af -------------------------------------------------------------------------------- /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_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_index4/oci-layout: -------------------------------------------------------------------------------- 1 | { 2 | "imageLayoutVersion": "1.0.0" 3 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index5/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index5/blobs/sha256/2cbd3e7a7cca7df9201e626abe080efe75e0588dda3c0188b1caf3a011f300ca -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index5/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/container/go/pkg/oci/testdata/test_index5/blobs/sha256/3d4d5ef7eb586de880424d1613e36bc25a1617239ff81d8cf961c6481e6193af -------------------------------------------------------------------------------- /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} -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /container/go/pkg/oci/testdata/test_index5/oci-layout: -------------------------------------------------------------------------------- 1 | { 2 | "imageLayoutVersion": "1.0.0" 3 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /container/push-tag.bat.tpl: -------------------------------------------------------------------------------- 1 | @REM !\usr\bin\env bash 2 | @REM Copyright 2017 The Bazel Authors. All rights reserved. 3 | @REM 4 | @REM Licensed under the Apache License, Version 2.0 (the "License"); 5 | @REM you may not use this file except in compliance with the License. 6 | @REM You may obtain a copy of the License at 7 | @REM 8 | @REM http:\\www.apache.org\licenses\LICENSE-2.0 9 | @REM 10 | @REM Unless required by applicable law or agreed to in writing, software 11 | @REM distributed under the License is distributed on an "AS IS" BASIS, 12 | @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @REM See the License for the specific language governing permissions and 14 | @REM limitations under the License. 15 | 16 | SET RUNFILES=.. 17 | 18 | %{container_pusher} %{args} "$@" 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 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(["run_checker.sh.tpl"]) 22 | 23 | bzl_library( 24 | name = "configs_test", 25 | srcs = ["configs_test.bzl"], 26 | deps = ["//skylib:docker"], 27 | ) 28 | 29 | bzl_library( 30 | name = "packages_metadata", 31 | srcs = [ 32 | "metadata_merge.bzl", 33 | "packages_metadata.bzl", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /contrib/go/cmd/metadata_merge/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("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 15 | 16 | go_library( 17 | name = "go_default_library", 18 | srcs = ["metadata_merge.go"], 19 | importpath = "github.com/bazelbuild/rules_docker/contrib/go/cmd/metadata_merge", 20 | visibility = ["//visibility:private"], 21 | deps = [ 22 | "//contrib/go/pkg/metadata:go_default_library", 23 | "@in_gopkg_yaml_v2//:go_default_library", 24 | ], 25 | ) 26 | 27 | go_binary( 28 | name = "metadata_merge", 29 | embed = [":go_default_library"], 30 | visibility = ["//visibility:public"], 31 | ) 32 | -------------------------------------------------------------------------------- /contrib/go/cmd/packages_metadata/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("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 15 | 16 | go_library( 17 | name = "go_default_library", 18 | srcs = ["packages_metadata.go"], 19 | importpath = "github.com/bazelbuild/rules_docker/contrib/go/cmd/packages_metadata", 20 | visibility = ["//visibility:private"], 21 | deps = [ 22 | "//contrib/go/pkg/metadata:go_default_library", 23 | "@com_github_pkg_errors//:go_default_library", 24 | "@in_gopkg_yaml_v2//:go_default_library", 25 | ], 26 | ) 27 | 28 | go_binary( 29 | name = "packages_metadata", 30 | embed = [":go_default_library"], 31 | visibility = ["//visibility:public"], 32 | ) 33 | -------------------------------------------------------------------------------- /contrib/go/pkg/metadata/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("@io_bazel_rules_go//go:def.bzl", "go_library") 15 | 16 | go_library( 17 | name = "go_default_library", 18 | srcs = ["packages.go"], 19 | importpath = "github.com/bazelbuild/rules_docker/contrib/go/pkg/metadata", 20 | visibility = ["//visibility:public"], 21 | ) 22 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 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 = "image_bzl", 23 | srcs = ["image.bzl"], 24 | visibility = ["//visibility:private"], 25 | ) 26 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | "//skylib:docker", 38 | ], 39 | ) 40 | -------------------------------------------------------------------------------- /docker/package_managers/installer.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env 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/pkginstall 4 | # along with the installables.tar. 5 | set -e 6 | pushd /tmp/pkginstall 7 | %{install_commands} 8 | popd 9 | umount -l /tmp/pkginstall 10 | rm -rf /tmp/* 11 | -------------------------------------------------------------------------------- /docker/package_managers/run_download.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | function guess_runfiles() { 5 | if [ -d ${BASH_SOURCE[0]}.runfiles ]; then 6 | # Runfiles are adjacent to the current script. 7 | echo "$( cd ${BASH_SOURCE[0]}.runfiles && pwd )" 8 | else 9 | # The current script is within some other script's runfiles. 10 | mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 11 | echo $mydir | sed -e 's|\(.*\.runfiles\)/.*|\1|' 12 | fi 13 | } 14 | 15 | RUNFILES="${PYTHON_RUNFILES:-$(guess_runfiles)}" 16 | 17 | # Resolve the docker tool path 18 | DOCKER="%{docker_tool_path}" 19 | DOCKER_FLAGS="%{docker_flags}" 20 | 21 | if [[ -z "$DOCKER" ]]; then 22 | echo >&2 "error: docker not found; do you need to manually configure the docker toolchain?" 23 | exit 1 24 | fi 25 | 26 | # Load the image and remember its name 27 | image_id=$(%{image_id_extractor_path} %{image_tar}) 28 | "$DOCKER" $DOCKER_FLAGS load -i %{image_tar} 29 | 30 | # Run the builder image. 31 | cid=$("$DOCKER" $DOCKER_FLAGS run -w="/" -d --privileged $image_id sh -c $'%{download_commands}') 32 | "$DOCKER" $DOCKER_FLAGS attach $cid 33 | "$DOCKER" $DOCKER_FLAGS cp $cid:%{installables}_packages.tar %{output} 34 | "$DOCKER" $DOCKER_FLAGS cp $cid:%{installables}_metadata.csv %{output_metadata} 35 | # Cleanup 36 | "$DOCKER" $DOCKER_FLAGS rm $cid 37 | -------------------------------------------------------------------------------- /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("@subpar//:subpar.bzl", "par_binary") 17 | 18 | package(default_visibility = ["//visibility:public"]) 19 | 20 | exports_files([ 21 | "security_check_whitelist.json", 22 | ]) 23 | 24 | par_binary( 25 | name = "security_check", 26 | srcs = ["security_check.py"], 27 | main = "security_check.py", 28 | python_version = "PY3", 29 | visibility = ["//visibility:public"], 30 | ) 31 | 32 | bzl_library( 33 | name = "security_check_lib", 34 | srcs = [ 35 | "security_check.bzl", 36 | ], 37 | ) 38 | -------------------------------------------------------------------------------- /docker/security/cmd/json_to_yaml/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("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 15 | 16 | go_library( 17 | name = "go_default_library", 18 | srcs = ["json_to_yaml.go"], 19 | importpath = "github.com/bazelbuild/rules_docker/docker/security/cmd/json_to_yaml", 20 | visibility = ["//visibility:private"], 21 | deps = ["@com_github_ghodss_yaml//:go_default_library"], 22 | ) 23 | 24 | go_binary( 25 | name = "json_to_yaml", 26 | embed = [":go_default_library"], 27 | visibility = ["//visibility:public"], 28 | ) 29 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docker/util/commit.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 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 | DOCKER_FLAGS="%{docker_flags}" 12 | 13 | if [[ -z "$DOCKER" ]]; then 14 | echo >&2 "error: docker not found; do you need to manually configure the docker toolchain?" 15 | exit 1 16 | fi 17 | 18 | logfile=$(output_logfile) 19 | 20 | if ! ( 21 | # Load the image and remember its name 22 | image_id=$(%{image_id_extractor_path} %{image_tar}) 23 | "$DOCKER" $DOCKER_FLAGS load -i %{image_tar} 24 | 25 | readonly id=$("$DOCKER" $DOCKER_FLAGS create %{docker_run_flags} $image_id %{commands}) 26 | retcode=0 27 | if "$DOCKER" $DOCKER_FLAGS start -a "${id}"; then 28 | reset_cmd $image_id $id %{output_image} 29 | "$DOCKER" $DOCKER_FLAGS save %{output_image} -o %{output_tar} 30 | else 31 | retcode=$? 32 | fi 33 | 34 | "$DOCKER" $DOCKER_FLAGS rm $id 35 | exit "$retcode" 36 | ) > "$logfile" 2>&1; then 37 | cat $logfile 38 | exit 1 39 | fi 40 | -------------------------------------------------------------------------------- /docker/util/extract.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | 5 | # Resolve the docker tool path 6 | DOCKER="%{docker_tool_path}" 7 | DOCKER_FLAGS="%{docker_flags}" 8 | 9 | if [[ -z "$DOCKER" ]]; then 10 | echo >&2 "error: docker not found; do you need to manually configure the docker toolchain?" 11 | exit 1 12 | fi 13 | 14 | # Redirect output to a log so we can be silent on success 15 | logfile=$(mktemp) 16 | trap "rm $logfile" EXIT 17 | 18 | if ! ( 19 | # Load the image and remember its name 20 | image_id=$(%{image_id_extractor_path} %{image_tar}) 21 | "$DOCKER" $DOCKER_FLAGS load -i %{image_tar} 22 | 23 | id=$("$DOCKER" $DOCKER_FLAGS run -d %{docker_run_flags} $image_id %{commands}) 24 | 25 | retcode=$("$DOCKER" $DOCKER_FLAGS wait $id) 26 | 27 | # Print any error that occurred in the container. 28 | if [ $retcode != 0 ]; then 29 | "$DOCKER" $DOCKER_FLAGS logs $id && false 30 | exit $retcode 31 | fi 32 | 33 | "$DOCKER" $DOCKER_FLAGS cp $id:%{extract_file} %{output} 34 | "$DOCKER" $DOCKER_FLAGS rm $id 35 | ) > "$logfile" 2>&1; then 36 | cat "$logfile" 37 | exit 1 38 | fi 39 | -------------------------------------------------------------------------------- /docker/util/image_util.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | reset_cmd() { 4 | local original_image_name=$1 5 | local container_id=$2 6 | local output_image_name=$3 7 | 8 | # Resolve the docker tool path 9 | DOCKER="%{docker_tool_path}" 10 | DOCKER_FLAGS="%{docker_flags}" 11 | local old_cmd 12 | # docker inspect input cannot be piped into docker commit directly, we need to JSON format it. 13 | old_cmd=$("$DOCKER" $DOCKER_FLAGS inspect -f "{{range .Config.Cmd}}{{.}} {{end}}" "${original_image_name}") 14 | fmt_cmd=$(echo "$old_cmd" | ${TO_JSON_TOOL}) 15 | # If CMD wasn't set, set it to a sane default. 16 | if [ "$fmt_cmd" == "" ] || [ "$fmt_cmd" == "[]" ]; 17 | then 18 | fmt_cmd='["/bin/sh", "-c"]' 19 | fi 20 | 21 | "$DOCKER" $DOCKER_FLAGS commit -c "CMD $fmt_cmd" "${container_id}" "${output_image_name}" 22 | } 23 | 24 | function output_logfile { 25 | readonly filename=$(mktemp) 26 | 27 | function cleanup { 28 | test -f "$filename" 29 | cat "$filename" 30 | rm "$filename" 31 | } 32 | trap cleanup EXIT 33 | 34 | echo $filename 35 | } 36 | -------------------------------------------------------------------------------- /docker/util/testdata/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 | exports_files([ 18 | "image_with_symlinked_layer.tar", 19 | ]) 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 | -------------------------------------------------------------------------------- /docs/BUILD: -------------------------------------------------------------------------------- 1 | load("@bazel_skylib//rules:diff_test.bzl", "diff_test") 2 | load("@bazel_skylib//rules:write_file.bzl", "write_file") 3 | load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") 4 | 5 | # Workaround https://github.com/bazelbuild/stardoc/issues/25 6 | write_file( 7 | name = "gen_header", 8 | out = "header.vm", 9 | content = [ 10 | "", 11 | "", 12 | "${moduleDocstring}", 13 | ], 14 | ) 15 | 16 | stardoc( 17 | name = "container_doc", 18 | out = "container.md_", 19 | header_template = ":header.vm", 20 | input = "//container:container.docs.bzl", 21 | deps = ["//container:container.docs"], 22 | ) 23 | 24 | # If these fail, run `bazel run //docs:update` 25 | diff_test( 26 | name = "check_container", 27 | failure_message = "Please run bazel run //docs:update", 28 | file1 = "container.md", 29 | file2 = ":container_doc", 30 | ) 31 | 32 | write_file( 33 | name = "gen_update", 34 | out = "gen_update.sh", 35 | content = [ 36 | "#!/usr/bin/env bash", 37 | "cd $BUILD_WORKSPACE_DIRECTORY", 38 | "cp -fv bazel-bin/docs/container.md_ docs/container.md", 39 | ], 40 | ) 41 | 42 | sh_binary( 43 | name = "update", 44 | srcs = [":gen_update"], 45 | data = [":container_doc"], 46 | ) 47 | -------------------------------------------------------------------------------- /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 | 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 = "go_bzl", 23 | srcs = ["go.bzl"], 24 | visibility = ["//visibility:private"], 25 | ) 26 | 27 | bzl_library( 28 | name = "image_bzl", 29 | srcs = ["image.bzl"], 30 | visibility = ["//visibility:private"], 31 | ) 32 | 33 | bzl_library( 34 | name = "static_bzl", 35 | srcs = ["static.bzl"], 36 | visibility = ["//visibility:private"], 37 | ) 38 | -------------------------------------------------------------------------------- /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 2022-11-08 11:58 +0900 23 | "debug": "sha256:65668d2b78d25df3d8ccf5a778d017fcaba513b52078c700083eaeef212b9979", 24 | # "gcr.io/distroless/base:latest" circa 2022-11-08 11:58 +0900 25 | "latest": "sha256:b9b124f955961599e72630654107a0cf04e08e6fa777fa250b8f840728abd770", 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 2022-11-08 11:59 +0900 23 | "debug": "sha256:56655dceb80c142846d72bf164b02a15c2e8a4d7537900fde710a408eb66fad2", 24 | # "gcr.io/distroless/static:latest" circa 2022-11-08 11:59 +0900 25 | "latest": "sha256:ebd8cc37d22551dce0957ba8e58f03b22a8448bbf844c8c9ded4feef883b36bc", 26 | } 27 | -------------------------------------------------------------------------------- /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 | 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 = "image_bzl", 23 | srcs = ["image.bzl"], 24 | visibility = ["//visibility:private"], 25 | ) 26 | -------------------------------------------------------------------------------- /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 | 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 = "jetty_bzl", 23 | srcs = ["jetty.bzl"], 24 | visibility = ["//visibility:private"], 25 | ) 26 | 27 | bzl_library( 28 | name = "java_bzl", 29 | srcs = ["java.bzl"], 30 | visibility = ["//visibility:private"], 31 | ) 32 | 33 | bzl_library( 34 | name = "image_bzl", 35 | srcs = ["image.bzl"], 36 | visibility = ["//visibility:private"], 37 | ) 38 | 39 | # needed for stardoc 40 | bzl_library( 41 | name = "java", 42 | srcs = glob(["*.bzl"]), 43 | ) 44 | -------------------------------------------------------------------------------- /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 2022-11-08 11:59 +0900 23 | "debug": "sha256:80f87dcce03ba2591d777471818ab77f6fb580faa86628d2f885f7700af7941b", 24 | # "gcr.io/distroless/java:latest" circa 2022-11-08 11:59 +0900 25 | "latest": "sha256:629d4fdc17eec821242d45497abcb88cc0442c47fd5748baa79d88dde7da3e2d", 26 | } 27 | -------------------------------------------------------------------------------- /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 2022-11-08 11:59 +0900 23 | "debug": "sha256:c9ac5a5bf6f3187095277b8141517d3c3c5bd307e9f72ef40713d9f622d348f3", 24 | # "gcr.io/distroless/java/jetty:latest" circa 2022-11-08 11:59 +0900 25 | "latest": "sha256:8eb486e24d352ae46ef2a069a7e4bdb43800728c53463d097061540d2166667e", 26 | } 27 | -------------------------------------------------------------------------------- /kotlin/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 2022-11-08 11:59 +0900 23 | "debug": "sha256:0b18331f4d42ffd2ee8e5fbb9dbdd31dad39e7bef062414888ae971e9c13436b", 24 | # "gcr.io/google-appengine/debian9:latest" circa 2022-11-08 11:59 +0900 25 | "latest": "sha256:0b18331f4d42ffd2ee8e5fbb9dbdd31dad39e7bef062414888ae971e9c13436b", 26 | } 27 | -------------------------------------------------------------------------------- /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 2022-11-08 11:59 +0900 23 | "debug": "sha256:85f45e3b5ab66da2eb04c10d29519deb21bf14bcfa8fa6769817db4f031ad3c9", 24 | # "gcr.io/distroless/python2.7:latest" circa 2022-11-08 11:59 +0900 25 | "latest": "sha256:83b8dc7881f3e3c85740bfffd32b7ce64527757e74c68d6a31102a7d1b2a977b", 26 | } 27 | -------------------------------------------------------------------------------- /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("@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 = "image_bzl", 23 | srcs = ["image.bzl"], 24 | visibility = ["//visibility:private"], 25 | ) 26 | 27 | bzl_library( 28 | name = "python3_bzl", 29 | srcs = ["python3.bzl"], 30 | visibility = ["//visibility:private"], 31 | ) 32 | -------------------------------------------------------------------------------- /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 2022-11-08 11:59 +0900 23 | "debug": "sha256:84b5e6a7e091754b31b34e65307c2f60a4ab1c1ceb583db55da9bbe1f272498a", 24 | # "gcr.io/distroless/python3:latest" circa 2022-11-08 11:59 +0900 25 | "latest": "sha256:2bcee59e0ecbadf01e1b5df29ad27598c7775b822b7f2bfae4a271e2ee139ed4", 26 | } 27 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "schedule": "at 7am on Monday" 6 | } 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.4 6 | 7 | -------------------------------------------------------------------------------- /run-bazel-in-docker.sh: -------------------------------------------------------------------------------- 1 | # Runs bazel in a docker container, with this repository's workspace mounted in its file system. 2 | # This is useful because rules_docker assumes the host environment is linux, and tests will fail on other environments. 3 | # Running bazel in docker is slower, but allows for the build and tests to execute on non-linux environments. 4 | 5 | mkdir -p /tmp/build_output/ 6 | # -e USER="$(id -u)" \ 7 | # -u="$(id -u)" \ 8 | docker run \ 9 | -v "$PWD":/workspace \ 10 | -v /tmp/build_output:/tmp/build_output \ 11 | -v /var/run/docker.sock:/var/run/docker.sock \ 12 | -w /workspace \ 13 | l.gcr.io/google/bazel:latest \ 14 | --output_user_root=/tmp/build_output \ 15 | "$@" -------------------------------------------------------------------------------- /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("@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 = "image_bzl", 23 | srcs = ["image.bzl"], 24 | visibility = ["//visibility:private"], 25 | ) 26 | -------------------------------------------------------------------------------- /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 | 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 = "image_bzl", 23 | srcs = ["image.bzl"], 24 | visibility = ["//visibility:private"], 25 | ) 26 | -------------------------------------------------------------------------------- /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 = "docker", 23 | srcs = ["docker.bzl"], 24 | ) 25 | 26 | bzl_library( 27 | name = "filetype", 28 | srcs = ["filetype.bzl"], 29 | ) 30 | 31 | bzl_library( 32 | name = "label", 33 | srcs = ["label.bzl"], 34 | ) 35 | 36 | bzl_library( 37 | name = "path", 38 | srcs = ["path.bzl"], 39 | ) 40 | 41 | bzl_library( 42 | name = "zip", 43 | srcs = ["zip.bzl"], 44 | ) 45 | 46 | bzl_library( 47 | name = "hash", 48 | srcs = ["hash.bzl"], 49 | ) 50 | -------------------------------------------------------------------------------- /skylib/docker.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 | """Common functions for docker library""" 15 | 16 | def docker_path(toolchain_info): 17 | """Resolve the user-supplied docker path, if any. 18 | 19 | Args: 20 | toolchain_info: The DockerToolchainInfo 21 | 22 | Returns: 23 | Path to docker 24 | """ 25 | if toolchain_info.tool_target: 26 | return toolchain_info.tool_target.files_to_run.executable.path 27 | else: 28 | return toolchain_info.tool_path 29 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /stamp/BUILD.bazel: -------------------------------------------------------------------------------- 1 | "Helpers to determine when to stamp build outputs" 2 | 3 | load(":stamp.bzl", "stamp_setting") 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | # Detect if the build is running under --stamp 8 | config_setting( 9 | name = "stamp", 10 | values = {"stamp": "true"}, 11 | ) 12 | 13 | # Enable stamping based on the --stamp flag 14 | stamp_setting( 15 | name = "use_stamp_flag", 16 | stamp = select({ 17 | "@io_bazel_rules_docker//stamp:stamp": True, 18 | "//conditions:default": False, 19 | }), 20 | ) 21 | 22 | stamp_setting( 23 | name = "always", 24 | stamp = True, 25 | ) 26 | 27 | stamp_setting( 28 | name = "never", 29 | stamp = False, 30 | ) 31 | -------------------------------------------------------------------------------- /stamp/stamp.bzl: -------------------------------------------------------------------------------- 1 | "Helper for determining when to stamp build outputs" 2 | 3 | load("@io_bazel_rules_docker//container:providers.bzl", "StampSettingInfo") 4 | 5 | def _impl(ctx): 6 | return [StampSettingInfo(value = ctx.attr.stamp)] 7 | 8 | # Modelled after go_context_data in rules_go 9 | # Works around github.com/bazelbuild/bazel/issues/1054 10 | stamp_setting = rule( 11 | implementation = _impl, 12 | attrs = { 13 | "stamp": attr.bool(mandatory = True), 14 | }, 15 | doc = """Determines whether build outputs should be stamped with version control info. 16 | 17 | Stamping causes outputs to be non-deterministic, resulting in cache misses.""", 18 | ) 19 | -------------------------------------------------------------------------------- /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.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /testdata/Binary.kt: -------------------------------------------------------------------------------- 1 | // Copyright 2020 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 | 21 | @JvmStatic 22 | fun main(args: Array) { 23 | println(Library.sayHello()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /testdata/Library.kt: -------------------------------------------------------------------------------- 1 | // Copyright 2020 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 | object Library { 18 | fun sayHello(): String { 19 | return listOf("Hello", "World").joinToString(" ") 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /testdata/bar: -------------------------------------------------------------------------------- 1 | blah -------------------------------------------------------------------------------- /testdata/baz: -------------------------------------------------------------------------------- 1 | blah 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/cc_image_wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | "$1" || { echo "FAIL!"; exit 1; } 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /testdata/dockerfile_build/Data_file.txt: -------------------------------------------------------------------------------- 1 | Some data... 2 | -------------------------------------------------------------------------------- /testdata/dockerfile_build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ALPINE_version 2 | ARG SOME_VAR=default_value 3 | 4 | FROM alpine:${ALPINE_version} AS base 5 | ENTRYPOINT ["echo"] 6 | CMD ["Hello World!"] 7 | 8 | ENV envVar My environment variable 9 | ENV xyz=321 10 | ENV SOME_VAR=${SOME_VAR} 11 | 12 | ADD Data_file.txt / 13 | ADD More_data.txt /usr/ 14 | COPY file_to_copy.txt / 15 | LABEL version="7.7" \ 16 | desc="Description for version 7.7" 17 | EXPOSE 8080/tcp 18 | EXPOSE 9876/udp 19 | VOLUME /myVol1 /usr/myVol2 20 | 21 | RUN apk add gcc python2 22 | 23 | FROM base AS test 24 | 25 | RUN echo "Hello from test stage" > /target_test.txt 26 | 27 | FROM base 28 | 29 | RUN echo "A file that should not exist" > /target_test_base.txt -------------------------------------------------------------------------------- /testdata/dockerfile_build/More_data.txt: -------------------------------------------------------------------------------- 1 | Additional data -------------------------------------------------------------------------------- /testdata/dockerfile_build/file_to_copy.txt: -------------------------------------------------------------------------------- 1 | Another file to copy -------------------------------------------------------------------------------- /testdata/flag_main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 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 | "flag" 20 | "fmt" 21 | ) 22 | 23 | func main() { 24 | arg := flag.String("arg", "", "Command line argument to print") 25 | flag.Parse() 26 | fmt.Println(*arg) 27 | } 28 | -------------------------------------------------------------------------------- /testdata/foo: -------------------------------------------------------------------------------- 1 | asdf -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /testdata/nodejs_image.js: -------------------------------------------------------------------------------- 1 | const lib = require('./nodejs_image_lib'); 2 | 3 | console.log(lib.message()); 4 | console.log(process.argv.slice(2)) 5 | -------------------------------------------------------------------------------- /testdata/nodejs_image_lib.ts: -------------------------------------------------------------------------------- 1 | import * as jsesc from 'jsesc'; 2 | 3 | export function message() { 4 | return jsesc('Hello World!') 5 | } 6 | -------------------------------------------------------------------------------- /testdata/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@bazel/typescript": "3.5.0", 4 | "@types/jsesc": "2.5.1", 5 | "@types/node": "12.12.47", 6 | "jsesc": "3.0.2", 7 | "typescript": "4.2.4" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /testdata/pause.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/testdata/pause.tar -------------------------------------------------------------------------------- /testdata/pause_piecemeal/layers.bzl: -------------------------------------------------------------------------------- 1 | """Defines shas for layers used in tests.""" 2 | 3 | PAUSE_LAYERS = [ 4 | "9285c41a2f85a67c85185be04743004e806fd1e16777f2230166281f4e49cb4c", 5 | "da7bd81140ca921a067c604a3ba3f54d4e0d51ba5276cd9f32ad6a28e588f470", 6 | ] 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /testdata/test/test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/testdata/test/test -------------------------------------------------------------------------------- /testdata/tsconfig.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/testdata/tsconfig.json -------------------------------------------------------------------------------- /testing/README.md: -------------------------------------------------------------------------------- 1 | E2E tests 2 | --------- 3 | 4 | To run all e2e tests, use the command 5 | ``` 6 | $ ./e2e.sh 7 | ``` 8 | 9 | To run a single test, use the command 10 | ``` 11 | $ ./e2e.sh 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /testing/custom_toolchain_auth/.gitignore: -------------------------------------------------------------------------------- 1 | bazel-* 2 | 3 | # Automatically generated by e2e test driver 4 | def.bzl 5 | 6 | -------------------------------------------------------------------------------- /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/custom_toolchain_flags/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/custom_toolchain_flags" -------------------------------------------------------------------------------- /testing/default_toolchain/.gitignore: -------------------------------------------------------------------------------- 1 | bazel-* 2 | 3 | # Automatically generated by e2e test driver 4 | def.bzl 5 | 6 | -------------------------------------------------------------------------------- /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/docker-config/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "auths": { 3 | "localhost:5000": { 4 | "auth": "Zm9vOmZvbw==" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /testing/docker-config/htpasswd: -------------------------------------------------------------------------------- 1 | foo:$2y$05$a2SPoa9qOEpw41WkKOapo.6Lr4HIC0TfowpoYsS6FRtp5pqORB.vW 2 | 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /testing/download_pkgs_at_root/download_pkgs_at_root_run_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env 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 | -------------------------------------------------------------------------------- /testing/e2e/flag.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | # Copyright 2021 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 flags are passed correctly. 19 | 20 | # Must be invoked from the root of the repo. 21 | ROOT=$PWD 22 | 23 | function test_flag() { 24 | cd "${ROOT}" 25 | clear_docker 26 | EXPECT_CONTAINS "$(bazel run testdata:flag_image -- -arg='Hello World!')" "Hello World!" 27 | } 28 | 29 | # Call function above 30 | test_flag 31 | -------------------------------------------------------------------------------- /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/kt_jvm_image.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | # Copyright 2020 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 kt_jvm_image 19 | 20 | # Must be invoked from the root of the repo. 21 | ROOT=$PWD 22 | 23 | function test_kt_jvm_image() { 24 | cd "${ROOT}" 25 | clear_docker 26 | EXPECT_CONTAINS "$(bazel run "$@" tests/container/kotlin:kt_jvm_image)" "Hello World" 27 | } 28 | 29 | # Call functions above with 3 parameters: 1st parameter is name of function, 30 | # 2nd and 3rd # passed as args 31 | # (simple approach to make migration easy for e2e.sh) 32 | $1 $2 $3 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /testing/e2e/test_flag.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 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 flag passing 16 | 17 | steps: 18 | - name: "l.gcr.io/google/bazel" 19 | entrypoint: "bash" 20 | args: 21 | - -c 22 | - ./testing/e2e/flag.sh 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_kt_jvm_image.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 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 kt_jvm_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/kt_jvm_image.sh test_kt_jvm_image -c opt 25 | 26 | - name: "l.gcr.io/google/bazel" 27 | entrypoint: "bash" 28 | args: 29 | - -c 30 | - ./testing/e2e/kt_jvm_image.sh test_kt_jvm_image -c dbg 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /testing/e2e/test_puller.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 for the container puller. 16 | 17 | steps: 18 | - name: "l.gcr.io/google/bazel" 19 | entrypoint: "bash" 20 | args: 21 | - -c 22 | - ./testing/e2e/puller.sh -------------------------------------------------------------------------------- /testing/e2e/test_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 for the container pusher. 16 | 17 | steps: 18 | - name: "l.gcr.io/google/bazel" 19 | entrypoint: "bash" 20 | args: 21 | - -c 22 | - ./testing/e2e/pusher.sh 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /testing/examples/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/testing/examples/BUILD -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /testing/examples/basic/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.8 2 | ENTRYPOINT ["echo"] 3 | CMD ["Hello World!"] 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /testing/examples/basic/test_configs/basic_alpine.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: ['echo'] 5 | cmd: ['Hello World!'] 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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/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 | 18 | RUN wget https://bootstrap.pypa.io/pip/3.5/get-pip.py && python3 get-pip.py \ 19 | && python3 -m pip install --upgrade setuptools wheel 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 31 | # Used to test setting gzip as target. 32 | java_binary( 33 | name = "gzip", 34 | srcs = ["Gzip.java"], 35 | main_class = "tools.gzip.Gzip", 36 | visibility = ["//visibility:public"], 37 | deps = [], 38 | ) 39 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /testing/java_image/foo: -------------------------------------------------------------------------------- 1 | asdf -------------------------------------------------------------------------------- /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 | tags = ["manual"], # buildkite-incompatible 22 | ) 23 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /tests/container/architecture_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BASEDIR=$(dirname "$0") 4 | 5 | # Expose content of config file, just for logging 6 | cat ${BASEDIR}/${2}.0.config; echo 7 | 8 | # Check if architecture passed in arg ${1} matches the config file 9 | if grep -q \"architecture\":\"${1}\" ${BASEDIR}/${2}.0.config; then 10 | echo "Architecture ${1} in arg matches the config file" 11 | else 12 | echo "Architecture ${1} in arg does not match the config file" 13 | exit 1 14 | fi 15 | -------------------------------------------------------------------------------- /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/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 | env: 11 | - key: CC_IMAGE_TEST_KEY 12 | value: cc_image_test_value 13 | 14 | fileExistenceTests: 15 | - name: 'cc_image.binary' 16 | path: './app/tests/container/cc/cc_image.binary.runfiles/io_bazel_rules_docker/tests/container/cc/cc_image.binary' 17 | shouldExist: true 18 | permissions: '-r-xr-xr-x' 19 | 20 | - name: 'BUILD' 21 | path: './app/tests/container/cc/cc_image.binary.runfiles/io_bazel_rules_docker/tests/container/cc/BUILD' 22 | shouldExist: true 23 | permissions: '-r-xr-xr-x' 24 | 25 | - name: 'external' 26 | path: '/app/tests/container/cc/cc_image.binary.runfiles/io_bazel_rules_docker/external' 27 | shouldExist: true 28 | permissions: 'Lrwxrwxrwx' 29 | -------------------------------------------------------------------------------- /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"]) + glob(["*.yaml.tpl"])) 16 | -------------------------------------------------------------------------------- /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_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_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/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.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: ["foo"] 5 | -------------------------------------------------------------------------------- /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_entrypoint.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: ["bar"] 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/container/configs/set_env_equals.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | env: 5 | - key: JAVA_OPTS 6 | value: -Dloader.main=com.sample.app.SampleApp 7 | - key: CUDA_PKG_VERSION 8 | value: -10-0=10.0.130-1 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/container/configs/transitions_off.yaml.tpl: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | fileContentTests: 4 | - name: "validate architecture" 5 | path: "/Files/got_arch.txt" 6 | expectedContents: ["%WANT_ARCH%"] 7 | - name: "validate os" 8 | path: "/Files/got_os.txt" 9 | expectedContents: ["%WANT_OS%"] 10 | -------------------------------------------------------------------------------- /tests/container/configs/transitions_on.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | fileContentTests: 4 | - name: "validate architecture" 5 | path: "/Files/got_arch.txt" 6 | expectedContents: ["arm64"] 7 | - name: "validate os" 8 | path: "/Files/got_os.txt" 9 | expectedContents: ["windows"] 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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /tests/container/go/configs/go_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: [ 5 | 'arg0', 6 | 'arg1', 7 | 'tests/container/go/BUILD', 8 | ] 9 | entrypoint: ['/app/tests/container/go/go_image.binary'] 10 | env: 11 | - key: GO_IMAGE_TEST_KEY 12 | value: go_image_test_value 13 | 14 | # File info taken from https://github.com/GoogleContainerTools/distroless/tree/master/base 15 | 16 | fileExistenceTests: 17 | - name: "openssl" 18 | path: "/usr/bin/openssl" 19 | shouldExist: true 20 | 21 | -------------------------------------------------------------------------------- /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/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/groovy/configs/groovy_classpath_as_file_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/groovy_classpath_as_file_image.classpath', 8 | '-Dbuild.location=tests/container/groovy/BUILD', 9 | 'examples.images.Binary', 10 | 'arg0', 11 | 'arg1', 12 | 'tests/container/groovy/BUILD', 13 | ] 14 | -------------------------------------------------------------------------------- /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 | env: 15 | - key: "GROOVY_IMAGE_TEST_KEY" 16 | value: "groovy_image_test_value" 17 | -------------------------------------------------------------------------------- /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/java/configs/java_classpath_as_file_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/java_classpath_as_file_image.classpath', 11 | '-Dbuild.location=tests/container/java/BUILD', 12 | 'examples.images.Binary', 13 | 'arg0', 14 | 'arg1', 15 | 'tests/container/java/BUILD'] 16 | -------------------------------------------------------------------------------- /tests/container/java/configs/java_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/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', 8 | '-Dbuild.location=tests/container/java/BUILD', 9 | 'examples.images.Binary', 10 | 'arg0', 11 | 'arg1', 12 | 'tests/container/java/BUILD'] 13 | env: 14 | - key: JAVA_RUNFILES 15 | value: "/app" 16 | - key: JAVA_IMAGE_TEST_KEY 17 | value: java_image_test_value 18 | -------------------------------------------------------------------------------- /tests/container/java/configs/java_image_complex_external_deps.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | entrypoint: [ 5 | '/usr/bin/java', 6 | '-cp', 7 | '/app/io_bazel_rules_docker/../com_google_guava_guava/guava-18.0.jar:/app/io_bazel_rules_docker/tests/container/java/libjava_image_library.jar:/app/io_bazel_rules_docker/tests/container/java/java_image_complex_external_deps.binary.jar:/app/io_bazel_rules_docker/tests/container/java/java_image_complex_external_deps.binary', 8 | 'examples.images.Binary' 9 | ] 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/container/kotlin/configs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 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/kotlin/configs/kt_jvm_classpath_as_file_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/kotlin/kt_jvm_classpath_as_file_image.classpath', 8 | '-Dbuild.location=tests/container/kotlin/BUILD', 9 | 'examples.images.Binary', 10 | 'arg0', 11 | 'arg1', 12 | 'tests/container/kotlin/BUILD', 13 | ] 14 | -------------------------------------------------------------------------------- /tests/container/kotlin/configs/kt_jvm_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/kotlin/kt_jvm_image.binary-lib.jar:/app/io_bazel_rules_docker/../com_github_jetbrains_kotlin/lib/kotlin-stdlib.jar:/app/io_bazel_rules_docker/tests/container/kotlin/kt_jvm_image.binary-lib.jdeps:/app/io_bazel_rules_docker/tests/container/kotlin/kt_jvm_image.binary.jar:/app/io_bazel_rules_docker/tests/container/kotlin/kt_jvm_image.binary.jdeps:/app/io_bazel_rules_docker/tests/container/kotlin/BUILD:/app/io_bazel_rules_docker/tests/container/kotlin/kt_jvm_image.binary', 8 | '-Dbuild.location=tests/container/kotlin/BUILD', 9 | 'examples.images.Binary', 10 | 'arg0', 11 | 'arg1', 12 | 'tests/container/kotlin/BUILD', 13 | ] 14 | env: 15 | - key: KT_JVM_IMAGE_TEST_KEY 16 | value: kt_jvm_image_test_value 17 | -------------------------------------------------------------------------------- /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/nodejs/configs/nodejs_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: ["arg0", "arg1"] 5 | entrypoint: ['/app/tests/container/nodejs/nodejs_image.binary'] 6 | env: 7 | - key: DEBIAN_FRONTEND 8 | value: "noninteractive" 9 | - key: NODEJS_IMAGE_TEST_KEY 10 | value: nodejs_image_test_value 11 | - key: PATH 12 | value: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 13 | - key: PORT 14 | value: "8080" 15 | workdir: "/app/tests/container/nodejs/nodejs_image.binary.runfiles/io_bazel_rules_docker" 16 | -------------------------------------------------------------------------------- /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_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_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 | -------------------------------------------------------------------------------- /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_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 | -------------------------------------------------------------------------------- /tests/container/nodejs/configs/nodejs_image_with_launcher.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: ['/launcher.sh', '/app/tests/container/nodejs/nodejs_image_with_launcher.binary'] 13 | workdir: "/app/tests/container/nodejs/nodejs_image_with_launcher.binary.runfiles/io_bazel_rules_docker" 14 | -------------------------------------------------------------------------------- /tests/container/nodejs/configs/nodejs_image_with_launcher_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: ['/launcher.sh', 'foo', 'bar', '/app/tests/container/nodejs/nodejs_image_with_launcher_args.binary'] 13 | workdir: "/app/tests/container/nodejs/nodejs_image_with_launcher_args.binary.runfiles/io_bazel_rules_docker" 14 | -------------------------------------------------------------------------------- /tests/container/nodejs/launcher.sh: -------------------------------------------------------------------------------- 1 | # Do something before running CMD 2 | echo "Do something before running CMD" 3 | 4 | # Run whatever entrypoint / cmd args are passed next 5 | "$@" -------------------------------------------------------------------------------- /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/python/configs/py_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: [ 5 | 'arg0', 6 | 'arg1', 7 | 'tests/container/python/BUILD', 8 | ] 9 | entrypoint: [ 10 | '/usr/bin/python', 11 | '/app/tests/container/python/py_image.binary', 12 | ] 13 | env: 14 | - key: "PY_IMAGE_TEST_KEY" 15 | value: "py_image_test_value" 16 | -------------------------------------------------------------------------------- /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 | env = {"PY3_IMAGE_TEST_KEY": "py3_image_test_value"}, 30 | layers = [ 31 | "//tests/container/python:py_image_library", 32 | ], 33 | ) 34 | 35 | container_test( 36 | name = "py3_image_test", 37 | configs = ["//tests/container/python3/configs:py3_image.yaml"], 38 | image = ":py3_image", 39 | ) 40 | -------------------------------------------------------------------------------- /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/python3/configs/py3_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: [ 5 | 'arg0', 6 | 'arg1', 7 | 'tests/container/python3/BUILD', 8 | ] 9 | entrypoint: [ 10 | '/usr/bin/python', 11 | '/app/tests/container/python3/py3_image.binary', 12 | ] 13 | env: 14 | - key: "PY3_IMAGE_TEST_KEY" 15 | value: "py3_image_test_value" 16 | -------------------------------------------------------------------------------- /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 | env = {"RUST_IMAGE_TEST_KEY": "rust_image_test_value"}, 30 | ) 31 | 32 | container_test( 33 | name = "rust_image_test", 34 | configs = ["//tests/container/rust/configs:rust_image.yaml"], 35 | image = ":rust_image", 36 | ) 37 | -------------------------------------------------------------------------------- /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/rust/configs/rust_image.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | metadataTest: 4 | cmd: [ 5 | 'arg0', 6 | 'arg1', 7 | 'tests/container/rust/BUILD', 8 | ] 9 | entrypoint: ['/app/tests/container/rust/rust_image_binary'] 10 | env: 11 | - key: RUST_IMAGE_TEST_KEY 12 | value: rust_image_test_value 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/container/scala/configs/scala_classpath_as_file_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_classpath_as_file_image.classpath', 8 | '-Dbuild.location=tests/container/scala/BUILD', 9 | 'examples.images.Binary', 10 | 'arg0', 11 | 'arg1', 12 | 'tests/container/scala/BUILD', 13 | ] 14 | -------------------------------------------------------------------------------- /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.12.14.jar:/app/io_bazel_rules_docker/../io_bazel_rules_scala_scala_reflect/scala-reflect-2.12.14.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 | env: 15 | - key: SCALA_IMAGE_TEST_KEY 16 | value: scala_image_test_value 17 | -------------------------------------------------------------------------------- /tests/container/testdata/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_pkg//pkg:tar.bzl", "pkg_tar") 2 | 3 | package(default_visibility = ["//tests:__subpackages__"]) 4 | 5 | LONG_NAMES = glob(["files/**"]) 6 | 7 | pkg_tar( 8 | name = "expected", 9 | srcs = LONG_NAMES, 10 | strip_prefix = ".", 11 | ) 12 | 13 | filegroup( 14 | name = "source", 15 | srcs = LONG_NAMES, 16 | ) 17 | -------------------------------------------------------------------------------- /tests/container/testdata/files/aaaa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/tests/container/testdata/files/aaaa -------------------------------------------------------------------------------- /tests/container/testdata/files/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/rules_docker/5e997fa0c6079388afa0bd6205ebe2d3382faef4/tests/container/testdata/files/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /tests/contrib/automatic_container_release/metadata_merge_file1.yaml: -------------------------------------------------------------------------------- 1 | tags: 2 | - foo 3 | 4 | -------------------------------------------------------------------------------- /tests/contrib/automatic_container_release/metadata_merge_file2.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - name: foo 3 | version: 1 4 | -------------------------------------------------------------------------------- /tests/contrib/automatic_container_release/metadata_merge_file3.yaml: -------------------------------------------------------------------------------- 1 | tags: 2 | - bar 3 | -------------------------------------------------------------------------------- /tests/contrib/automatic_container_release/metadata_merge_file4.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - name: baz 3 | version: 2 4 | -------------------------------------------------------------------------------- /tests/contrib/automatic_container_release/packages_metadata.csv: -------------------------------------------------------------------------------- 1 | Name,Version 2 | aaa,1 3 | ccc,2 4 | bbb,3 5 | -------------------------------------------------------------------------------- /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/contrib/mv_project_root.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env 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 | -------------------------------------------------------------------------------- /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 | 19 | # This file fetched from 20 | # wget "http://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0xEB9B1D8886F44E2A" 21 | # because it was being served with unstable contents, causing our CI 22 | # to fail 50% of the time. 23 | filegroup( 24 | name = "launchpad_openjdk_gpg", 25 | srcs = ["launchpad_openjdk_gpg.pub"], 26 | visibility = ["//tests/docker:__subpackages__"], 27 | ) 28 | -------------------------------------------------------------------------------- /tests/docker/launchpad_openjdk_gpg.pub: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Comment: Hostname: 3 | Version: Hockeypuck ~unreleased 4 | 5 | xo0ES8OmlQEEALy8ttT3KgmjoqCkeU7S04/j615RDivV0CHv+5mdJFQY10wo6v6k 6 | rmXxK757eIoRDN1B3ztl8vjqLHxi8oA+f4inZcrrIZYjW0MghO+IcKEbKCrPUPjD 7 | fQBSIvZD5ZaiibMNwZJ6TidS2r6nSAH+aoMRgXYycQPGkAHDcaPKY54zABEBAAHN 8 | JExhdW5jaHBhZCBPcGVuSkRLIGJ1aWxkcyAoYWxsIGFyY2hzKcK2BBMBAgAgBQJL 9 | w6aVAhsDBgsJCAcDAgQVAggDBBYCAwECHgECF4AACgkQ65sdiIb0TiraSgQAr+WD 10 | +qGcW5yrkS2QBMq+g+Ew2tLqeDLw8Y2xZ4BhnRzB3WljBfwj7wt/KOugjJWaEWuY 11 | GiuLBf6vy+At5VtXs0FSk6oIZR0XZvUVamFPXeTkZqUiw4oTNlBTeOhAxrevRWzn 12 | mLuRAIWlr0dARJyLCK5MMVVhesouoG8WpOrniXs= 13 | =JbYw 14 | -----END PGP PUBLIC KEY BLOCK----- 15 | -------------------------------------------------------------------------------- /tests/docker/package_managers/download_pkgs_run_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env 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/docker/package_managers/download_pkgs_with_additional_repos_run_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/docker/util/container_commit.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: '2.0.0' 2 | metadataTest: 3 | cmd: ["/bin/sh", "-c", "/bin/bash"] 4 | -------------------------------------------------------------------------------- /tests/docker/util/container_commit_layer.yaml: -------------------------------------------------------------------------------- 1 | schemaVersion: 2.0.0 2 | 3 | fileExistenceTests: 4 | - name: 'foo.txt' 5 | path: '/' 6 | shouldExist: true 7 | -------------------------------------------------------------------------------- /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 | client_config = "%{DOCKER_CONFIG}", 24 | %{BUILD_TAR_ATTR} 25 | %{GZIP_ATTR} 26 | %{TOOL_ATTR} 27 | docker_flags = ["%{DOCKER_FLAGS}"], 28 | %{XZ_ATTR} 29 | ) 30 | -------------------------------------------------------------------------------- /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 | cred_helpers=%{cred_helpers}, 11 | **kwargs 12 | ) 13 | -------------------------------------------------------------------------------- /transitions/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2022 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//rules:common_settings.bzl", "bool_flag") 16 | 17 | package( 18 | default_visibility = ["//visibility:public"], 19 | ) 20 | 21 | bool_flag( 22 | name = "enable", 23 | build_setting_default = False, 24 | ) 25 | 26 | config_setting( 27 | name = "enabled", 28 | flag_values = {"@io_bazel_rules_docker//transitions:enable": "true"}, 29 | ) 30 | 31 | config_setting( 32 | name = "disabled", 33 | flag_values = {"@io_bazel_rules_docker//transitions:enable": "false"}, 34 | ) 35 | --------------------------------------------------------------------------------