Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: secure hermetic-build docker image #3196

Draft
wants to merge 42 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5f5e0bd
chore: secure hermetic-build docker image
diegomarquezp Sep 12, 2024
15a19c5
fix python preparation
diegomarquezp Sep 12, 2024
ff0fc1a
apine image
diegomarquezp Sep 12, 2024
9a25dda
update reqs
diegomarquezp Sep 12, 2024
66d7f45
do not use BSD flags for `rm`
diegomarquezp Sep 12, 2024
d12877c
fixes to docker image
diegomarquezp Sep 16, 2024
4885459
fix reference to global site-packages
diegomarquezp Sep 16, 2024
b97c209
fix permissions
diegomarquezp Sep 17, 2024
3f94f0b
use SHAs directy
diegomarquezp Sep 17, 2024
08fe2cd
reduce image size
diegomarquezp Sep 17, 2024
539922a
use cloud build action
diegomarquezp Sep 17, 2024
1a34741
Update .cloudbuild/library_generation/library_generation.Dockerfile
diegomarquezp Sep 17, 2024
43f1ac0
update DEVELOPMENT.md
diegomarquezp Sep 17, 2024
1dc3629
use buildkit
diegomarquezp Sep 17, 2024
90dafe3
Merge remote-tracking branch 'origin/secure-hermetic-build-docker-ima…
diegomarquezp Sep 17, 2024
3f3deec
Merge branch 'main' into secure-hermetic-build-docker-image
diegomarquezp Sep 17, 2024
b730a4b
do not build image in integration test
diegomarquezp Sep 17, 2024
db2e8e7
remove wrong dependency
diegomarquezp Sep 17, 2024
fb98222
Merge remote-tracking branch 'origin/secure-hermetic-build-docker-ima…
diegomarquezp Sep 17, 2024
32fffb7
comment unwanted airlock repo
diegomarquezp Sep 17, 2024
51544a3
Update library_generation/DEVELOPMENT.md
diegomarquezp Sep 17, 2024
e9a5df4
remove redundant skipTests
diegomarquezp Sep 17, 2024
8f0ac9b
Merge remote-tracking branch 'origin/secure-hermetic-build-docker-ima…
diegomarquezp Sep 17, 2024
2c35db2
add links to confirm availablity of missing python packages
diegomarquezp Sep 17, 2024
d09124f
save point: owl-bot cli standalone and python repo using airlock
diegomarquezp Sep 17, 2024
34835a5
remove standalone executable for owlbot
diegomarquezp Sep 17, 2024
a3490e2
remove airlock registry for python
diegomarquezp Sep 17, 2024
efeff60
fix list of glibc shared objects
diegomarquezp Sep 17, 2024
ae0f349
add instructions for setting up airlock docker registry
diegomarquezp Sep 18, 2024
9177111
fix python setup
diegomarquezp Sep 18, 2024
8797e30
Revert "remove airlock registry for python"
diegomarquezp Sep 18, 2024
aa0fe85
fix integration test yaml
diegomarquezp Sep 18, 2024
bce332d
add hermetic-library-generation cloud build job
diegomarquezp Sep 18, 2024
d0a6da1
use CLOUD_LOGGING_ONLY to allow SA runner
diegomarquezp Sep 18, 2024
11a81d3
fix volumes
diegomarquezp Sep 18, 2024
565afda
retrigger build
diegomarquezp Sep 18, 2024
dd275ac
retrigger build
diegomarquezp Sep 18, 2024
2e5067d
retrigger build
diegomarquezp Sep 19, 2024
32ac053
retrigger build
diegomarquezp Sep 19, 2024
054bf42
retrigger build
diegomarquezp Sep 19, 2024
87a2e09
add python volumes
diegomarquezp Sep 19, 2024
42f331e
use cloud-sdk image for steps
diegomarquezp Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

timeout: 7200s # 2 hours
substitutions:
_IMAGE_NAME: "gcr.io/cloud-devrel-public-resources/java-library-generation"
_GAPIC_GENERATOR_JAVA_VERSION: '2.45.1-SNAPSHOT' # {x-version-update:gapic-generator-java:current}
_VERSIONED_IMAGE_ID: "${_IMAGE_NAME}:${_GAPIC_GENERATOR_JAVA_VERSION}"
steps:
# Skip the
- id: skip-if-coming-from-fork
name: bash
allowFailure: true # in case we `exit 1`, assume it's not a failure
script: |
if [[ "${_HEAD_REPO_URL}" != "https://www.github.com/googleapis/sdk-platform-java" ]]; then
echo "this PR comes from a fork. Aborting."
exit 1
fi
- id: library-generation-build
name: gcr.io/cloud-builders/docker
waitFor: ["skip-if-coming-from-fork"]
args: [
"build",
"-t", "${_VERSIONED_IMAGE_ID}",
"--file", ".cloudbuild/library_generation/library_generation.Dockerfile", "."]
env:
- 'DOCKER_BUILDKIT=1'
volumes:
- name: docker-local
path: /var/lib/docker/overlay2
- id: maven-build
name: gcr.io/cloud-builders/mvn
waitFor: ["skip-if-coming-from-fork"]
args: [
"mvn",
"install", "-B", "-ntp", "-T2C"
"-DskipTests", "-Dmaven.test.skip", "-Dcheckstyle.skip", "-Dclirr.skip",
"-Dmaven.javadoc.skip"
]
volumes:
- name: maven-local
path: /home/.m2
- id: script-run
name: gcr.io/google.com/cloudsdktool/cloud-sdk # contains docker and git
waitFor: ["maven-build", "library-generation-build"]
script: |
set -x
[ -z "$(git config user.email)" ] && git config --global user.email "[email protected]"
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
bash .github/scripts/hermetic_library_generation.sh \
--target_branch "${_BASE_BRANCH}" \
--current_branch "${_HEAD_BRANCH}" \
--image_tag "${_VERSIONED_IMAGE_ID}"
volumes:
- name: maven-local
path: /home/.m2
- name: docker-local
path: /var/lib/docker/overlay2
options:
# Builds ran by service accounts we need to either a) specify a logs bucket,
# b) use REGIONAL_USER_OWNER_BUCKET, or c) use CLOUD_LOGGING_ONLY. We go for c)
logging: CLOUD_LOGGING_ONLY
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This is a tentative Cloud Build workflow to replace the existing integration
# tests setup in GitHub Actions
timeout: 7200s # 2 hours
substitutions:
_IMAGE_NAME: "test-image"
steps:
# Library generation build
- id: library-generation-image-build
name: gcr.io/cloud-builders/docker
waitFor: ["-"]
args: [
"build",
"-t", "${_IMAGE_NAME}",
"--file", ".cloudbuild/library_generation/library_generation.Dockerfile", "."]
env:
- 'DOCKER_BUILDKIT=1'
volumes:
- name: docker-local
path: /var/lib/docker/overlay2
# Dependency installation
- id: library-generation-python-libs
name: gcr.io/google.com/cloudsdktool/cloud-sdk
waitFor: ["-"]
args: [ "python", "-m", "pip", "install", "--require-hashes", "-r",
"--target", "/usr/lib/python3.9",
"library_generation/requirements.txt" ]
volumes:
- name: python-local
path: /usr/lib/python3.9
# Python scripts compilation
- id: library-generation-python-compile
name: gcr.io/google.com/cloudsdktool/cloud-sdk
waitFor: ["-"]
args: [ "python", "-m", "pip", "install",
"--target", "/usr/lib/python3.9",
"library_generation" ]
volumes:
- name: python-local
path: /usr/lib/python3.9
# Python integration tests execution
- id: run-integration-tests
name: gcr.io/google.com/cloudsdktool/cloud-sdk
waitFor: [
"library-generation-python-compile",
"library-generation-python-libs",
"library-generation-image-build"
]
args: [ "python3", "-m", "unittest",
"library_generation/test/integration_tests.py" ]
volumes:
- name: docker-local
path: /var/lib/docker/overlay2
- name: python-local
path: /usr/lib/python3.9
options:
# Builds ran by service accounts we need to either a) specify a logs bucket,
# b) use REGIONAL_USER_OWNER_BUCKET, or c) use CLOUD_LOGGING_ONLY. We go for c)
logging: CLOUD_LOGGING_ONLY
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ steps:
"-t", "${_VERSIONED_IMAGE_ID}",
"--file", ".cloudbuild/library_generation/library_generation.Dockerfile", "."]
id: library-generation-build
env:
- 'DOCKER_BUILDKIT=1'
waitFor: ["-"]

images:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[global]
index-url = https://us-python.pkg.dev/artifact-foundry-prod/ah-3p-staging-python/simple/
# TODO: use the following index URL when `lxml` and `versions` are available in the `trusted` airlock registry
# We can confirm their availability in https://airlock.corp.goog/search?query=&type=Python
# index-url = https://us-python.pkg.dev/artifact-foundry-prod/python-3p-trusted/simple/
11 changes: 11 additions & 0 deletions .cloudbuild/library_generation/image-configuration/airlock-pypirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[distutils]
index-servers = ah-3p-staging-python
# TODO: use this index instead when `lxml` and `versions` are available in the `trusted` airlock registry
# We can confirm their availability in https://airlock.corp.goog/search?query=&type=Python
# index-servers = python-3p-trusted
JoeWang1127 marked this conversation as resolved.
Show resolved Hide resolved

[ah-3p-staging-python]
repository: https://us-python.pkg.dev/artifact-foundry-prod/ah-3p-staging-python/
# TODO: use this repository instead when `lxml` and `versions` are available in the `trusted` airlock registry
# We can confirm their availability in https://airlock.corp.goog/search?query=&type=Python
# repository: https://us-python.pkg.dev/artifact-foundry-prod/python-3p-trusted/
Loading