diff --git a/.github/workflows/build_container_from_ref.yml b/.github/workflows/build_container_from_ref.yml new file mode 100644 index 00000000..0c78cff9 --- /dev/null +++ b/.github/workflows/build_container_from_ref.yml @@ -0,0 +1,56 @@ +name: "Build container from arbitrary repo / ref" +on: + workflow_dispatch: + inputs: + repository: + description: 'The receptor repository to build from.' + required: true + default: 'ansible/awx-ee' + ref: + description: 'The ref to build. Can be a branch or any other valid ref.' + required: true + default: 'devel' + receptor_image: + description: 'The receptor image to use for the build' + required: true + default: 'quay.io/ansible/receptor:devel' + tag: + description: 'The tag for the container.' + required: true +jobs: + build: + name: build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + repository: ${{ github.event.inputs.repository }} + ref: ${{ github.event.inputs.ref }} + + - uses: actions/setup-python@v2 + with: + python-version: "3.8" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + + - name: Login To ghcr.io + uses: docker/login-action@v2 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: ghcr.io + + - name: Build and push image + env: + DOCKER_BUILDKIT: 1 + TAG: ghcr.io/${{ github.repository }}:${{ github.event.inputs.tag }} + RECEPTOR_IMAGE: ${{ github.event.inputs.receptor_image }} + run: | + TAG=$(echo $TAG | tr '[A-Z]' '[a-z]') + tox -e docker -- --tag=$TAG --build-arg RECEPTOR_IMAGE=${RECEPTOR_IMAGE} + docker push $TAG diff --git a/Containerfile b/Containerfile index 5eb325bc..682ce554 100644 --- a/Containerfile +++ b/Containerfile @@ -28,8 +28,9 @@ COPY --from=galaxy /usr/share/ansible /usr/share/ansible COPY --from=builder /output/ /output/ RUN /output/install-from-bindep && rm -rf /output/wheels +ARG RECEPTOR_IMAGE=quay.io/ansible/receptor:devel RUN alternatives --set python /usr/bin/python3 -COPY --from=quay.io/ansible/receptor:devel /usr/bin/receptor /usr/bin/receptor +COPY --from=$RECEPTOR_IMAGE /usr/bin/receptor /usr/bin/receptor RUN mkdir -p /var/run/receptor ADD run.sh /run.sh CMD /run.sh diff --git a/execution-environment.yml b/execution-environment.yml index 4cf687c7..c9714095 100644 --- a/execution-environment.yml +++ b/execution-environment.yml @@ -8,8 +8,9 @@ dependencies: python: _build/requirements.txt additional_build_steps: append: + - ARG RECEPTOR_IMAGE=quay.io/ansible/receptor:devel - RUN alternatives --set python /usr/bin/python3 - - COPY --from=quay.io/ansible/receptor:devel /usr/bin/receptor /usr/bin/receptor + - COPY --from=$RECEPTOR_IMAGE /usr/bin/receptor /usr/bin/receptor - RUN mkdir -p /var/run/receptor - ADD run.sh /run.sh - CMD /run.sh