Skip to content

Commit

Permalink
Support cross compilation (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkubala authored May 14, 2018
1 parent 06e6a77 commit 7788477
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 15 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,26 @@ in an image, as well as verify metadata and contents of the filesystem.
Tests can be run either through a standalone binary, or through a Docker image.

## Installation
Download the latest binary release [here](https://storage.googleapis.com/container-structure-test/latest/container-structure-test),
or pull the image at `gcr.io/gcp-runtimes/container-structure-test`.
**At this time, only a Linux binary is published. However, an OS X binary can be built using bazel:**

### OS X
```shell
bazel build //:container_structure_test
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-darwin-amd64 && chmod +x container-structure-test-darwin-amd64 && sudo mv container-structure-test-darwin-amd64 /usr/local/bin/container-structure-test
```

### Linux
```shell
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 && chmod +x container-structure-test-linux-amd64 && sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test
```

If you want to avoid using sudo:

```shell
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 && chmod +x container-structure-test-linux-amd64 && mkdir -p $HOME/bin && export PATH=$PATH:$HOME/bin && mv container-structure-test-linux-amd64 $HOME/bin/container-structure-test
```

Additionally, a container image for running tests through Google Cloud Builder can be found
at `gcr.io/gcp-runtimes/container-structure-test:latest`.

## Setup
To use container structure tests to validate your containers, you need the following:
- The container structure test binary or docker image
Expand Down
29 changes: 25 additions & 4 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,33 @@ steps:
args: ['run', '//:structure_test_image']
# Tag the built image
- name: 'gcr.io/cloud-builders/docker'
args: ['tag', 'bazel:structure_test_image', 'gcr.io/gcp-runtimes/container-structure-test:$COMMIT_SHA']
# Build the binary
args: [
'tag', 'bazel:structure_test_image',
'gcr.io/gcp-runtimes/container-structure-test:$COMMIT_SHA'
]

# Build the linux binary
- name: 'gcr.io/cloud-builders/bazel'
args: ['build', '//:container_structure_test']
# Upload the binary to GCS
# Upload the linux binary to GCS build tag bucket
- name: 'gcr.io/cloud-builders/gsutil'
args: [
'cp', 'bazel-bin/linux_amd64_pure_stripped/container_structure_test',
'gs://container-structure-test/builds/$COMMIT_SHA/container-structure-test-linux-amd64'
]

# Build the OS X binary
- name: 'gcr.io/cloud-builders/bazel'
args: [
'build',
'--platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64',
'//:container_structure_test'
]
# Upload the OS X binary to GCS build tag bucket
- name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', 'bazel-bin/linux_amd64_pure_stripped/container_structure_test', 'gs://container-structure-test/builds/$COMMIT_SHA/container-structure-test']
args: [
'cp', 'bazel-bin/darwin_amd64_pure_stripped/container_structure_test',
'gs://container-structure-test/builds/$COMMIT_SHA/container-structure-test-darwin-amd64'
]

images: ['gcr.io/gcp-runtimes/container-structure-test:$COMMIT_SHA']
47 changes: 40 additions & 7 deletions release_cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,52 @@ steps:
args: ['run', '//:structure_test_image']
# Tag the built image
- name: 'gcr.io/cloud-builders/docker'
args: ['tag', 'bazel:structure_test_image', 'gcr.io/gcp-runtimes/container-structure-test:$TAG_NAME']
args: [
'tag', 'bazel:structure_test_image',
'gcr.io/gcp-runtimes/container-structure-test:$TAG_NAME'
]
# Tag the new image as latest
- name: 'gcr.io/cloud-builders/docker'
args: ['tag', 'bazel:structure_test_image', 'gcr.io/gcp-runtimes/container-structure-test:latest']
# Build the binary
args: [
'tag', 'bazel:structure_test_image',
'gcr.io/gcp-runtimes/container-structure-test:latest'
]

# Build the linux binary
- name: 'gcr.io/cloud-builders/bazel'
args: ['build', '//:container_structure_test']
# Upload the linux binary to GCS
# Upload the linux binary to GCS release tag bucket
- name: 'gcr.io/cloud-builders/gsutil'
args: [
'cp', 'bazel-bin/linux_amd64_pure_stripped/container_structure_test',
'gs://container-structure-test/$TAG_NAME/container-structure-test-linux-amd64'
]
# Upload the linux binary to GCS latest bucket
- name: 'gcr.io/cloud-builders/gsutil'
args: [
'cp', 'bazel-bin/linux_amd64_pure_stripped/container_structure_test',
'gs://container-structure-test/latest/container-structure-test-linux-amd64'
]

# Build the OS X binary
- name: 'gcr.io/cloud-builders/bazel'
args: [
'build',
'--platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64',
'//:container_structure_test'
]
# Upload the OS X binary to GCS release tag bucket
- name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', 'bazel-bin/linux_amd64_pure_stripped/container_structure_test', 'gs://container-structure-test/$TAG_NAME/container-structure-test']
# Upload the linux binary to GCS
args: [
'cp', 'bazel-bin/darwin_amd64_pure_stripped/container_structure_test',
'gs://container-structure-test/$TAG_NAME/container-structure-test-darwin-amd64'
]
# Upload the OS X binary to GCS latest bucket
- name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', 'bazel-bin/linux_amd64_pure_stripped/container_structure_test', 'gs://container-structure-test/latest/container-structure-test']
args: [
'cp', 'bazel-bin/darwin_amd64_pure_stripped/container_structure_test',
'gs://container-structure-test/latest/container-structure-test-darwin-amd64'
]

images: [
'gcr.io/gcp-runtimes/container-structure-test:$TAG_NAME',
Expand Down

0 comments on commit 7788477

Please sign in to comment.