You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by oc...@apache.org on 2021/05/06 21:02:51 UTC

[trafficcontrol] branch 5.1.x updated: Cache Alpine image to avoid Docker Hub pull rate limit (#5500) (#5821)

This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 5.1.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/5.1.x by this push:
     new b80e231  Cache Alpine image to avoid Docker Hub pull rate limit (#5500) (#5821)
b80e231 is described below

commit b80e23199c55ac42031db166b9bde00cbd3c92a6
Author: Zach Hoffman <zr...@apache.org>
AuthorDate: Thu May 6 21:02:31 2021 +0000

    Cache Alpine image to avoid Docker Hub pull rate limit (#5500) (#5821)
    
    * Upgrade Alpine images to 3.13
    
    * Untag Alpine package versions while we're in here
    
    * Cache Alpine Docker image to avoid Docker Hub pull rate limit
    
    (cherry picked from commit ff4ba461b2ed11ffb753ea8ae6d6b524a391f9c8)
---
 .github/actions/go-fmt/Dockerfile                  |  3 +-
 .github/actions/go-test/Dockerfile                 |  3 +-
 .github/actions/save-alpine-tar/README.md          | 48 ++++++++++++++++
 .github/actions/save-alpine-tar/entrypoint.sh      | 66 ++++++++++++++++++++++
 .github/actions/todb-init/Dockerfile               |  3 +-
 .github/actions/todb-tests/Dockerfile              |  3 +-
 .github/actions/tr-tests/Dockerfile                |  8 ++-
 .github/workflows/ciab.yaml                        | 11 ++++
 .github/workflows/go.fmt.yml                       | 17 ++++++
 .github/workflows/go.unit.tests.yaml               | 13 +++++
 .github/workflows/tp.e2e.tests.yml                 | 13 +++++
 .github/workflows/tr.unit.tests.yaml               | 13 +++++
 .github/workflows/traffic-ops.yml                  | 19 +++++++
 .github/workflows/traffic.ops.database.yml         | 13 +++++
 infrastructure/cdn-in-a-box/origin/Dockerfile      |  2 +-
 infrastructure/cdn-in-a-box/readiness/Dockerfile   |  2 +-
 .../traffic_ops_integration_test/Dockerfile        |  4 +-
 tools/golang/Dockerfile                            |  2 +-
 traffic_router/tests/Dockerfile-test-alpine        |  2 +-
 19 files changed, 232 insertions(+), 13 deletions(-)

diff --git a/.github/actions/go-fmt/Dockerfile b/.github/actions/go-fmt/Dockerfile
index e3f8a00..144380a 100644
--- a/.github/actions/go-fmt/Dockerfile
+++ b/.github/actions/go-fmt/Dockerfile
@@ -15,7 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-FROM alpine:3.12
+# alpine:3.13
+FROM alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
 
 RUN architecture=$(uname -m) && \
     mkdir lib64 && \
diff --git a/.github/actions/go-test/Dockerfile b/.github/actions/go-test/Dockerfile
index 5cf5c21..f19ba80 100644
--- a/.github/actions/go-test/Dockerfile
+++ b/.github/actions/go-test/Dockerfile
@@ -15,7 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-FROM alpine:3.12
+# alpine:3.13
+FROM alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
 
 RUN architecture=$(uname -m) && \
     mkdir lib64 && \
diff --git a/.github/actions/save-alpine-tar/README.md b/.github/actions/save-alpine-tar/README.md
new file mode 100644
index 0000000..7c5c12d
--- /dev/null
+++ b/.github/actions/save-alpine-tar/README.md
@@ -0,0 +1,48 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you 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.
+-->
+# save-alpine-tar action
+
+This action lets save an already-downloaded Alpine image to a tar archive.
+
+## Arguments
+
+* `load-or-save` (required) `'load'` or `'save'`, depending on whether you want to load a Docker image from a tar archive or save an existing Docker image to a new tar archive.
+* `digest` (required): A Docker image digest. Find this by running
+  ```shell
+  docker image ls --digests
+  ```
+  Example: `sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930`
+
+## Outputs
+### `exit-code`
+
+* Exit code is 0 unless either
+  - An invalid value for `load-or-save` was given, or
+  - An invalid Docker image digest for the `digest` input was given
+
+## Example usage
+Load an Alpine Docker image:
+  ```yaml
+  - run: .github/actions/save-alpine-tar/entrypoint.sh load sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
+  ```
+
+Save an Alpine Docker image:
+  ```yaml
+  - run: .github/actions/save-alpine-tar/entrypoint.sh save sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
+  ```
diff --git a/.github/actions/save-alpine-tar/entrypoint.sh b/.github/actions/save-alpine-tar/entrypoint.sh
new file mode 100755
index 0000000..e4160e2
--- /dev/null
+++ b/.github/actions/save-alpine-tar/entrypoint.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+set -o errexit -o nounset
+trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR
+
+load() {
+	if [[ -e "$archive_filename" ]]; then
+		docker image load -i "$archive_filename"
+	else
+		echo "No tarred image found named ${archive_filename}"
+	fi
+}
+
+save() {
+	if [[ -e "$archive_filename" ]]; then
+		echo "Docker image archive ${archive_filename} already exists. Skipping save..."
+		return
+	fi
+	mkdir -p docker-images
+	docker image save "alpine@${alpine_digest}" -o "$archive_filename"
+	echo "Saved tarred image ${archive_filename}"
+}
+
+if [[ $# -ge 1 ]]; then
+	action="$1"
+	shift
+else
+	echo 'Argument `load-or-save` is required but was not found.'
+	exit 1
+fi
+if [[ $# -ge 1 ]]; then
+	alpine_digest="$1"
+	shift
+else
+	echo 'Input `digest` is required but was not found.'
+	exit 1
+fi
+archive_filename="docker-images/alpine@${alpine_digest}.tar.gz"
+
+if [[ "$action" != load && "$action" != save ]]; then
+	export action
+	<<-'MESSAGE' envsubst
+	Invalid value `${action}` was found for input load-or-save. Valid values:
+	* load
+	* save
+MESSAGE
+	exit 1
+fi
+
+"$action"
diff --git a/.github/actions/todb-init/Dockerfile b/.github/actions/todb-init/Dockerfile
index a5929f2..6146921 100644
--- a/.github/actions/todb-init/Dockerfile
+++ b/.github/actions/todb-init/Dockerfile
@@ -15,7 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-FROM alpine:3.12
+# alpine:3.13
+FROM alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
 
 RUN architecture=$(uname -m) && \
     mkdir lib64 && \
diff --git a/.github/actions/todb-tests/Dockerfile b/.github/actions/todb-tests/Dockerfile
index 132a4ae..91f49c4 100644
--- a/.github/actions/todb-tests/Dockerfile
+++ b/.github/actions/todb-tests/Dockerfile
@@ -15,7 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-FROM alpine:3.12
+# alpine:3.13
+FROM alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
 
 RUN apk add --no-cache bash
 
diff --git a/.github/actions/tr-tests/Dockerfile b/.github/actions/tr-tests/Dockerfile
index 6df2173..245ed00 100644
--- a/.github/actions/tr-tests/Dockerfile
+++ b/.github/actions/tr-tests/Dockerfile
@@ -11,11 +11,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-FROM alpine:3.12.0
+
+# alpine:3.13
+FROM alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
 
 RUN apk add --no-cache \
-		openjdk8=8.252.09-r0 \
-		maven=3.6.3-r0 \
+		openjdk8 \
+		maven \
 		tomcat-native
 
 ENTRYPOINT	cd traffic_router && \
diff --git a/.github/workflows/ciab.yaml b/.github/workflows/ciab.yaml
index 3462865..a245a1b 100644
--- a/.github/workflows/ciab.yaml
+++ b/.github/workflows/ciab.yaml
@@ -19,6 +19,8 @@ name: CDN-in-a-Box CI
 
 env:
   RHEL_VERSION: 8
+  # alpine:3.13
+  ALPINE_VERSION: sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
 
 on:
   push:
@@ -211,6 +213,13 @@ jobs:
     steps:
       - name: Checkout
         uses: actions/checkout@master
+      - name: Cache Alpine Docker image
+        uses: actions/cache@v2
+        with:
+          path: ${{ github.workspace }}/docker-images
+          key: docker-images/alpine@${{ env.ALPINE_VERSION }}.tar.gz
+      - name: Import cached Alpine Docker image
+        run: .github/actions/save-alpine-tar/entrypoint.sh load ${{ env.ALPINE_VERSION }}
       - name: Download RPMs
         uses: actions/download-artifact@v2
         with:
@@ -234,3 +243,5 @@ jobs:
           name: ciab-logs
           path: infrastructure/cdn-in-a-box/logs/*.log
         if: ${{ failure() }}
+      - name: Save Alpine Docker image
+        run: .github/actions/save-alpine-tar/entrypoint.sh save ${{ env.ALPINE_VERSION }}
diff --git a/.github/workflows/go.fmt.yml b/.github/workflows/go.fmt.yml
index ac91e4b..c04d0cc 100644
--- a/.github/workflows/go.fmt.yml
+++ b/.github/workflows/go.fmt.yml
@@ -17,14 +17,22 @@
 
 name: Go Format
 
+env:
+  # alpine:3.13
+  ALPINE_VERSION: sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
+
 on:
   push:
     paths:
+      - .github/actions/go-fmt
+      - .github/workflows/go.fmt.yml
       - GO_VERSION
       - "**.go"
   create:
   pull_request:
     paths:
+      - .github/actions/go-fmt
+      - .github/workflows/go.fmt.yml
       - GO_VERSION
       - "**.go"
     types: [opened, reopened, read_for_review, synchronize]
@@ -37,5 +45,14 @@ jobs:
     steps:
     - name: Checkout
       uses: actions/checkout@master
+    - name: Cache Alpine Docker image
+      uses: actions/cache@v2
+      with:
+        path: ${{ github.workspace }}/docker-images
+        key: docker-images/alpine@${{ env.ALPINE_VERSION }}.tar.gz
+    - name: Import cached Alpine Docker image
+      run: .github/actions/save-alpine-tar/entrypoint.sh load ${{ env.ALPINE_VERSION }}
     - name: Run Go fmt
       uses: ./.github/actions/go-fmt
+    - name: Save Alpine Docker image
+      run: .github/actions/save-alpine-tar/entrypoint.sh save ${{ env.ALPINE_VERSION }}
diff --git a/.github/workflows/go.unit.tests.yaml b/.github/workflows/go.unit.tests.yaml
index 740eb87..01b2963 100644
--- a/.github/workflows/go.unit.tests.yaml
+++ b/.github/workflows/go.unit.tests.yaml
@@ -17,6 +17,10 @@
 
 name: Go Unit Tests
 
+env:
+  # alpine:3.13
+  ALPINE_VERSION: sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
+
 on:
   push:
     paths:
@@ -47,7 +51,16 @@ jobs:
     steps:
     - name: Checkout
       uses: actions/checkout@master
+    - name: Cache Alpine Docker image
+      uses: actions/cache@v2
+      with:
+        path: ${{ github.workspace }}/docker-images
+        key: docker-images/alpine@${{ env.ALPINE_VERSION }}.tar.gz
+    - name: Import cached Alpine Docker image
+      run: .github/actions/save-alpine-tar/entrypoint.sh load ${{ env.ALPINE_VERSION }}
     - name: Run unit tests
       uses: ./.github/actions/go-test
       with:
         dir: ./grove/... ./lib/... ./traffic_monitor/... ./traffic_ops/traffic_ops_golang/... ./traffic_ops_ort/atstccfg/... ./traffic_stats/... ./traffic_ops/app/bin/...
+    - name: Save Alpine Docker image
+      run: .github/actions/save-alpine-tar/entrypoint.sh save ${{ env.ALPINE_VERSION }}
diff --git a/.github/workflows/tp.e2e.tests.yml b/.github/workflows/tp.e2e.tests.yml
index 8a8c692..195cbaf 100644
--- a/.github/workflows/tp.e2e.tests.yml
+++ b/.github/workflows/tp.e2e.tests.yml
@@ -17,6 +17,10 @@
 
 name: TP E2E Tests
 
+env:
+  # alpine:3.13
+  ALPINE_VERSION: sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
+
 on:
   push:
     paths:
@@ -86,6 +90,13 @@ jobs:
     steps:
       - name: Checkout
         uses: actions/checkout@master
+      - name: Cache Alpine Docker image
+        uses: actions/cache@v2
+        with:
+          path: ${{ github.workspace }}/docker-images
+          key: docker-images/alpine@${{ env.ALPINE_VERSION }}.tar.gz
+      - name: Import cached Alpine Docker image
+        run: .github/actions/save-alpine-tar/entrypoint.sh load ${{ env.ALPINE_VERSION }}
       - name: Initialize Traffic Ops Database
         id: todb
         uses: ./.github/actions/todb-init
@@ -93,4 +104,6 @@ jobs:
         uses: ./.github/actions/tp-e2e-tests
         with:
           smtp_address: 172.17.0.1
+      - name: Save Alpine Docker image
+        run: .github/actions/save-alpine-tar/entrypoint.sh save ${{ env.ALPINE_VERSION }}
 
diff --git a/.github/workflows/tr.unit.tests.yaml b/.github/workflows/tr.unit.tests.yaml
index b82474b..0d4a55b 100644
--- a/.github/workflows/tr.unit.tests.yaml
+++ b/.github/workflows/tr.unit.tests.yaml
@@ -17,6 +17,10 @@
 
 name: Traffic Router Unit Tests
 
+env:
+  # alpine:3.13
+  ALPINE_VERSION: sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
+
 on:
   push:
     paths:
@@ -38,6 +42,13 @@ jobs:
     steps:
       - name: Checkout
         uses: actions/checkout@master
+      - name: Cache Alpine Docker image
+        uses: actions/cache@v2
+        with:
+          path: ${{ github.workspace }}/docker-images
+          key: docker-images/alpine@${{ env.ALPINE_VERSION }}.tar.gz
+      - name: Import cached Alpine Docker image
+        run: .github/actions/save-alpine-tar/entrypoint.sh load ${{ env.ALPINE_VERSION }}
       - name: Cache local Maven repository
         uses: actions/cache@v2
         with:
@@ -66,3 +77,5 @@ jobs:
           numFailures: 999 # The maximum number of test failures to annotate
           cwd: ${{ github.workspace }}/traffic_router
         if: always()
+      - name: Save Alpine Docker image
+        run: .github/actions/save-alpine-tar/entrypoint.sh save ${{ env.ALPINE_VERSION }}
diff --git a/.github/workflows/traffic-ops.yml b/.github/workflows/traffic-ops.yml
index 4eb4939..e3eaa10 100644
--- a/.github/workflows/traffic-ops.yml
+++ b/.github/workflows/traffic-ops.yml
@@ -17,6 +17,10 @@
 
 name: Traffic Ops Go client/API integration tests
 
+env:
+  # alpine:3.13
+  ALPINE_VERSION: sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
+
 on:
   push:
     paths:
@@ -75,6 +79,13 @@ jobs:
     steps:
     - name: Checkout
       uses: actions/checkout@master
+    - name: Cache Alpine Docker image
+      uses: actions/cache@v2
+      with:
+        path: ${{ github.workspace }}/docker-images
+        key: docker-images/alpine@${{ env.ALPINE_VERSION }}.tar.gz
+    - name: Import cached Alpine Docker image
+      run: .github/actions/save-alpine-tar/entrypoint.sh load ${{ env.ALPINE_VERSION }}
     - name: Initialize Traffic Ops Database
       id: todb
       uses: ./.github/actions/todb-init
@@ -94,3 +105,11 @@ jobs:
       with:
         version: 3
         smtp_address: 172.17.0.1
+    - name: Run API v4 tests
+      if: ${{ steps.todb.outcome == 'success' && always() }}
+      uses: ./.github/actions/to-integration-tests
+      with:
+        version: 4
+        smtp_address: 172.17.0.1
+    - name: Save Alpine Docker image
+      run: .github/actions/save-alpine-tar/entrypoint.sh save ${{ env.ALPINE_VERSION }}
diff --git a/.github/workflows/traffic.ops.database.yml b/.github/workflows/traffic.ops.database.yml
index 7b1a85a..a356666 100644
--- a/.github/workflows/traffic.ops.database.yml
+++ b/.github/workflows/traffic.ops.database.yml
@@ -17,6 +17,10 @@
 
 name: Traffic Ops Database Tests
 
+env:
+  # alpine:3.13
+  ALPINE_VERSION: sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
+
 on:
   create:
   push:
@@ -34,5 +38,14 @@ jobs:
     steps:
       - name: Checkout
         uses: actions/checkout@master
+      - name: Cache Alpine Docker image
+        uses: actions/cache@v2
+        with:
+          path: ${{ github.workspace }}/docker-images
+          key: docker-images/alpine@${{ env.ALPINE_VERSION }}.tar.gz
+      - name: Import cached Alpine Docker image
+        run: .github/actions/save-alpine-tar/entrypoint.sh load ${{ env.ALPINE_VERSION }}
       - name: Rut Traffic Ops Database Tests
         uses: ./.github/actions/todb-tests
+      - name: Save Alpine Docker image
+        run: .github/actions/save-alpine-tar/entrypoint.sh save ${{ env.ALPINE_VERSION }}
diff --git a/infrastructure/cdn-in-a-box/origin/Dockerfile b/infrastructure/cdn-in-a-box/origin/Dockerfile
index d2114fd..77fd470 100644
--- a/infrastructure/cdn-in-a-box/origin/Dockerfile
+++ b/infrastructure/cdn-in-a-box/origin/Dockerfile
@@ -20,7 +20,7 @@
 # Apache Traffic Control
 ############################################################
 
-FROM alpine:latest
+FROM alpine:3.13
 
 RUN apk add --no-cache \
     net-tools \
diff --git a/infrastructure/cdn-in-a-box/readiness/Dockerfile b/infrastructure/cdn-in-a-box/readiness/Dockerfile
index 4e2bdd1..7deb9a8 100644
--- a/infrastructure/cdn-in-a-box/readiness/Dockerfile
+++ b/infrastructure/cdn-in-a-box/readiness/Dockerfile
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-FROM alpine:3.11
+FROM alpine:3.13
 
 RUN apk add --no-cache --update \
   curl \
diff --git a/infrastructure/cdn-in-a-box/traffic_ops_integration_test/Dockerfile b/infrastructure/cdn-in-a-box/traffic_ops_integration_test/Dockerfile
index 7558e94..6311af4 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops_integration_test/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops_integration_test/Dockerfile
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-FROM alpine:3.11 AS integration-builder
+FROM alpine:3.13 AS integration-builder
 
 COPY GO_VERSION /
 RUN set -o errexit; \
@@ -58,7 +58,7 @@ RUN CGO_ENABLED=0 go test -c ./v1* -ldflags="-w -s" -o traffic_ops_v1_integratio
 RUN CGO_ENABLED=0 go test -c ./v2* -ldflags="-w -s" -o traffic_ops_v2_integration_test
 RUN CGO_ENABLED=0 go test -c ./v3* -ldflags="-w -s" -o traffic_ops_v3_integration_test
 
-FROM alpine:3.11
+FROM alpine:3.13
 
 RUN apk add --no-cache --update \
   curl \
diff --git a/tools/golang/Dockerfile b/tools/golang/Dockerfile
index eec36a7..f958967 100644
--- a/tools/golang/Dockerfile
+++ b/tools/golang/Dockerfile
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-FROM alpine:3.11 AS base
+FROM alpine:3.13 AS base
 
 COPY GO_VERSION /
 RUN set -o errexit; \
diff --git a/traffic_router/tests/Dockerfile-test-alpine b/traffic_router/tests/Dockerfile-test-alpine
index fc5e00b..445121f 100644
--- a/traffic_router/tests/Dockerfile-test-alpine
+++ b/traffic_router/tests/Dockerfile-test-alpine
@@ -11,7 +11,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-FROM alpine:3.12.0
+FROM alpine:3.13
 ARG DIR=github.com/apache/trafficcontrol
 
 VOLUME ["/junit"]