Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Portable docker images cleanup script (#1445)
Browse files Browse the repository at this point in the history
Support running the cleanup script on both mac and linux.
gnudate on mac is `gdate`, while it is `date` on linux.

Also separate the cleanup script so deployments can be run piecemeal
  • Loading branch information
gdbelvin authored Feb 5, 2020
1 parent 50329f2 commit ab27b74
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ jobs:
- curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash && sudo mv kustomize /usr/local/bin/
- openssl aes-256-cbc -K $encrypted_555d9b2948d2_key -iv $encrypted_555d9b2948d2_iv
-in client_secrets.json.enc -d | gcloud auth activate-service-account --key-file /dev/stdin
script: ./scripts/deploy.sh
script:
- ./scripts/deploy.sh
- ./scripts/cleanup_images.sh

before_install:
- |
Expand Down
21 changes: 21 additions & 0 deletions scripts/cleanup_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

export PROJECT_NAME_CI=key-transparency
export CLOUDSDK_COMPUTE_ZONE=us-central1-a
export CLUSTER_NAME_CI=ci-cluster

gnudate() {
if hash gdate 2>/dev/null; then
gdate "$@"
else
date "$@"
fi
}

echo "Cleaning old docker images..."
BEFORE_DATE=$(gnudate --date="30 days ago" +%Y-%m-%d)
./scripts/gcrgc.sh gcr.io/key-transparency/init $BEFORE_DATE
./scripts/gcrgc.sh gcr.io/key-transparency/prometheus $BEFORE_DATE
./scripts/gcrgc.sh gcr.io/key-transparency/keytransparency-server $BEFORE_DATE
./scripts/gcrgc.sh gcr.io/key-transparency/keytransparency-sequencer $BEFORE_DATE
./scripts/gcrgc.sh gcr.io/key-transparency/keytransparency-monitor $BEFORE_DATE
8 changes: 0 additions & 8 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ docker-compose build --parallel
echo "Pushing docker images..."
docker-compose push

echo "Cleaning old docker images..."
BEFORE_DATE=$(date --date="30 days ago" +%Y-%m-%d)
./scripts/gcrgc.sh gcr.io/key-transparency/init $BEFORE_DATE
./scripts/gcrgc.sh gcr.io/key-transparency/prometheus $BEFORE_DATE
./scripts/gcrgc.sh gcr.io/key-transparency/keytransparency-server $BEFORE_DATE
./scripts/gcrgc.sh gcr.io/key-transparency/keytransparency-sequencer $BEFORE_DATE
./scripts/gcrgc.sh gcr.io/key-transparency/keytransparency-monitor $BEFORE_DATE

echo "Updating jobs..."
cd deploy/kubernetes/base
kustomize edit set image gcr.io/${PROJECT_NAME_CI}/prometheus:${TRAVIS_COMMIT}
Expand Down

0 comments on commit ab27b74

Please sign in to comment.