blob: 9027c1d02d34c93f9e3c1fe90892990d9096250a [file]
#
# 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: Create hadoop build image
inputs:
branch:
description: Git branch to use.
required: true
os:
description: Runner OS name
required: true
build_image_url:
description: URL of build (infra) image.
required: true
outputs:
uid:
description: User ID this action ran as.
value: ${{ steps.variables.outputs.uid }}
runs:
using: composite
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Build and push ${{ inputs.os }} base build image for ${{ inputs.branch }}
id: docker_build_base
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: ./dev-support/docker/
file: ./dev-support/docker/Dockerfile_${{ inputs.os }}
push: true
tags: ${{ inputs.build_image_url }}-base
cache-from: type=registry,ref=ghcr.io/apache/hadoop/gha-build-${{ inputs.os }}-image-cache:${{ inputs.branch }}
- name: User-specific Dockerfile
shell: bash
run: |
USER_ID=$(id -u "${USER}")
GROUP_ID=$(id -g "${USER}")
cat > /tmp/Dockerfile.gha <<UserSpecificDocker
FROM ${{ inputs.build_image_url }}-base
RUN rm -f /var/log/faillog /var/log/lastlog
RUN groupadd --non-unique -g ${GROUP_ID} ${USER}
RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER}
RUN echo "${USER} ALL=NOPASSWD: ALL" > "/etc/sudoers.d/hadoop-build-${USER_ID}"
UserSpecificDocker
- name: Build and push ${{ inputs.os }} build image for ${{ inputs.branch }}
id: docker_build_gha
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: ./dev-support/docker/
file: /tmp/Dockerfile.gha
push: true
tags: ${{ inputs.build_image_url }}
- name: Set up Outputs
id: variables
shell: bash
run: |
echo "uid=$(id -u "${USER}")" >> $GITHUB_OUTPUT