Skip to content

Instantly share code, notes, and snippets.

@pentium10
Last active March 3, 2022 13:08
Show Gist options
  • Save pentium10/79d08f5acd9f9ca1fd841287dafd6e18 to your computer and use it in GitHub Desktop.
Save pentium10/79d08f5acd9f9ca1fd841287dafd6e18 to your computer and use it in GitHub Desktop.
substitutions:
_IMAGE_NAME: "gcr.io/${PROJECT_ID}/myimage"
options:
dynamic_substitutions: true
steps:
# Step 0 - Build the container image
- name: "gcr.io/cloud-builders/docker"
args: ["build", "-f", "Dockerfile", "-t", "${_IMAGE_NAME}", "."]
# Step 1 - Minify the container with docker-slim
- name: "gcr.io/cloud-builders/docker"
entrypoint: "bash"
args:
- "-c"
- |
curl -L -o ds.tar.gz https://downloads.dockerslim.com/releases/1.37.4/dist_linux.tar.gz;
tar -xvf ds.tar.gz;
mv dist_linux/docker-slim /usr/local/bin/;
mv dist_linux/docker-slim-sensor /usr/local/bin/;
docker-slim build --sensor-ipc-mode proxy --sensor-ipc-endpoint $(docker network inspect bridge -f '{{range .IPAM.Config}}{{.Gateway}}{{end}}' | cut -f1) ${_IMAGE_NAME};
# Step 2 - Push the SLIM container to registry
- name: "gcr.io/cloud-builders/docker"
args: ["push", "${_IMAGE_NAME}.slim"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment