Skip to content

Print docker version #196

Print docker version

Print docker version #196

# 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.
name: Container trafficserver-alpine
env:
DOCKER_BUILDKIT: '1'
COMPOSE_DOCKER_CLI_BUILD: '1'
CONTAINER: ghcr.io/${{ github.repository }}/ci/trafficserver-alpine
on:
workflow_dispatch: # run manually
push:
paths:
- .env
- .github/containers/trafficserver-alpine/**
- .github/workflows/container-trafficserver-alpine.yml
pull_request:
paths:
- .env
- .github/containers/trafficserver-alpine/**
- .github/workflows/container-trafficserver-alpine.yml
types: [ opened, reopened, ready_for_review, synchronize ]
jobs:
build-amd64:
env:
PLATFORM: AMD64
if: ${{ github.repository_owner == 'apache' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Check if ATS_VERSION was changed within the last 4 commits
run: |2
set -o errexit -o nounset -o xtrace
ats_line="$(git grep -hn ^ATS_VERSION= .env | cut -d: -f1)"
if [[ -z "$ats_line" ]]; then
echo "No line containing ATS_VERSION in .env was found"
exit 1
fi
if [[ "$(git log HEAD~4..HEAD -L${ats_line},${ats_line}:.env)" != '' ||
"$(git log HEAD~4..HEAD .github/containers/trafficserver-alpine .github/workflows/container-trafficserver-alpine.yml)" != '' ||
${{ github.event_name }} == 'workflow_dispatch' ]]; then
echo SHOULD_RUN=1 >> ${{ github.env }}
fi
- name: Load environment
if: ${{ env.SHOULD_RUN == '1' }}
run: cp .env '${{ github.env }}'
- name: Set image name
run: echo 'IMAGE_NAME=${{ env.CONTAINER }}:${{ env.ATS_VERSION }}-${{ env.PLATFORM }}' >> '${{ github.env }}'
- name: Docker version
run: docker --version
- name: Build ${{ env.IMAGE_NAME }}
if: ${{ env.SHOULD_RUN == '1' }}
working-directory: .github/containers/trafficserver-alpine
run: docker buildx build --build-arg ATS_VERSION=${{ env.ATS_VERSION }} --tag ${{ env.IMAGE_NAME }} --platform linux/${{ env.PLATFORM }} --load .
- name: docker login ghcr.io
if: ${{ env.SHOULD_RUN == '1' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push ${{ env.IMAGE_NAME }}
if: ${{ env.should_run == '1' && github.event_name != 'pull_request' }}
run: docker push ${{ env.image_name }}
build-arm64:
env:
PLATFORM: ARM64
if: ${{ github.repository_owner == 'apache' || github.event_name == 'workflow_dispatch' }}
runs-on: ["self-hosted", "asf-arm"]
steps:
- name: Checkout repo
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Check if ATS_VERSION was changed within the last 4 commits
run: |2
set -o errexit -o nounset -o xtrace
ats_line="$(git grep -hn ^ATS_VERSION= .env | cut -d: -f1)"
if [[ -z "$ats_line" ]]; then
echo "No line containing ATS_VERSION in .env was found"
exit 1
fi
if [[ "$(git log HEAD~4..HEAD -L${ats_line},${ats_line}:.env)" != '' ||
"$(git log HEAD~4..HEAD .github/containers/trafficserver-alpine .github/workflows/container-trafficserver-alpine.yml)" != '' ||
${{ github.event_name }} == 'workflow_dispatch' ]]; then
echo SHOULD_RUN=1 >> ${{ github.env }}
fi
- name: Load environment
if: ${{ env.SHOULD_RUN == '1' }}
run: cp .env '${{ github.env }}'
- name: Set image name
run: echo 'IMAGE_NAME=${{ env.CONTAINER }}:${{ env.ATS_VERSION }}-${{ env.PLATFORM }}' >> '${{ github.env }}'
- name: Docker version
run: docker --version
- name: Build ${{ env.IMAGE_NAME }}
if: ${{ env.SHOULD_RUN == '1' }}
working-directory: .github/containers/trafficserver-alpine
run: docker buildx build --build-arg ATS_VERSION=${{ env.ATS_VERSION }} --tag ${{ env.IMAGE_NAME }} --platform linux/${{ env.PLATFORM }} --load .
- name: docker login ghcr.io
if: ${{ env.SHOULD_RUN == '1' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push ${{ env.IMAGE_NAME }}
if: ${{ env.should_run == '1' && github.event_name != 'pull_request' }}
run: docker push ${{ env.image_name }}
combine-platforms:
if: ${{ (github.repository_owner == 'apache' && github.event_name != 'pull_request') || github.event_name == 'workflow_dispatch' }}
needs:
- build-amd64
- build-arm64
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Load environment
run: cp .env '${{ github.env }}'
- name: Set image name
run: |2
echo 'IMAGE_NAME=${{ env.CONTAINER }}' >> '${{ github.env }}' &&
echo 'FULL_IMAGE_NAME=${{ env.CONTAINER }}:${{ env.ATS_VERSION }}' >> '${{ github.env }}'
- name: Create ${{ env.FULL_IMAGE_NAME }} manifest
run: |2
set -o errexit -o xtrace
docker manifest create \
${{ env.FULL_IMAGE_NAME }} \
--amend ${{ env.FULL_IMAGE_NAME }}-amd64 \
--amend ${{ env.FULL_IMAGE_NAME }}-arm64
docker manifest create \
${{ env.IMAGE_NAME }}:latest \
--amend ${{ env.FULL_IMAGE_NAME }}-amd64 \
--amend ${{ env.FULL_IMAGE_NAME }}-arm64
- name: docker login ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push ${{ env.FULL_IMAGE_NAME }}
run: |2
set -o errexit -o xtrace
docker manifest push --purge ${{ env.FULL_IMAGE_NAME }}
docker manifest push --purge ${{ env.IMAGE_NAME }}:latest