======= BOOTSTRAP DOCKERFILE =======>
#
# Copyright (c) 2018-2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
#   Red Hat, Inc. - initial API and implementation
#   IBM Corporation - implementation
#

# Builder: check meta.yamls and create index.json
# https://registry.access.redhat.com/ubi8/python-38
FROM registry.access.redhat.com/ubi8/python-38:1-121 as builder
#FROM registry-proxy.engineering.redhat.com/ubi8/python-38:1 as builder
USER 0

ARG BOOTSTRAP=true
ENV BOOTSTRAP=${BOOTSTRAP}
# if not defined or string is null, allow all registries/tags in list_referenced_images
# otherwise restrict to only those space-separated registries/tags; if others found, build will fail
# useful for failing build if quay images in an RC, or wrong devspaces image tag (3.2 in 3.1 build)
ARG ALLOWED_REGISTRIES=""
ENV ALLOWED_REGISTRIES=${ALLOWED_REGISTRIES}
ARG ALLOWED_TAGS=""
ENV ALLOWED_TAGS=${ALLOWED_TAGS}

COPY ./build/dockerfiles/content_sets_rhel8.repo /etc/yum.repos.d/
COPY ./build/dockerfiles/rhel.install.sh /tmp
RUN /tmp/rhel.install.sh && rm -f /tmp/rhel.install.sh

COPY ./build/scripts ./versions.json /build/
COPY ./build/scripts/clone_and_zip.sh /build/build/scripts/
COPY ./VERSION /
COPY ./devfiles /build/devfiles
WORKDIR /build/

RUN ./generate_devworkspace_templates.sh
RUN chmod -R g+rwX /build/resources

# validate devfile content
RUN ./check_referenced_images.sh devfiles --registries "${ALLOWED_REGISTRIES}" --tags "${ALLOWED_TAGS}"
RUN ./check_mandatory_fields.sh devfiles

# Cache projects in DS 
COPY ./build/dockerfiles/rhel.cache_projects.sh /tmp/ 
RUN /tmp/rhel.cache_projects.sh /build/ && rm -rf /tmp/rhel.cache_projects.sh /tmp/resources.tgz 

# don't do swaps, or we end up with missing content if built on s390x or ppc64le worker
# RUN ./swap_yamlfiles.sh devfiles
# RUN ./swap_images.sh devfiles
RUN ./index.sh > /build/devfiles/index.json && \
    ./list_referenced_images.sh devfiles > /build/devfiles/external_images.txt && \
    ./list_referenced_images_by_file.sh devfiles > /build/devfiles/external_images_by_devfile.txt && \
    chmod -R g+rwX /build/devfiles

<======= BOOTSTRAP DOCKERFILE =======
======= START BOOTSTRAP BUILD =======>
STEP 1/23: FROM registry.access.redhat.com/ubi8/python-38:1-121 AS builder
STEP 2/23: USER 0
--> 4a01434642f
STEP 3/23: ARG BOOTSTRAP=true
--> 456b9b37223
STEP 4/23: ENV BOOTSTRAP=${BOOTSTRAP}
--> 583b9ec9c5e
STEP 5/23: ARG ALLOWED_REGISTRIES=""
--> 2ebe84db466
STEP 6/23: ENV ALLOWED_REGISTRIES=${ALLOWED_REGISTRIES}
--> 1c114b8cae7
STEP 7/23: ARG ALLOWED_TAGS=""
--> 070de7cb668
STEP 8/23: ENV ALLOWED_TAGS=${ALLOWED_TAGS}
--> 3c288c59be6
STEP 9/23: COPY ./build/dockerfiles/content_sets_rhel8.repo /etc/yum.repos.d/
--> 7597b06ec25
STEP 10/23: COPY ./build/dockerfiles/rhel.install.sh /tmp
--> 3458358c62b
STEP 11/23: RUN /tmp/rhel.install.sh && rm -f /tmp/rhel.install.sh

Installed:
  containers-common-2:1-46.module+el8.7.0+17824+66a0202b.x86_64                 
  criu-3.15-3.module+el8.7.0+17824+66a0202b.x86_64                              
  fuse-common-3.3.0-16.el8.x86_64                                               
  fuse-overlayfs-1.9-1.module+el8.7.0+17824+66a0202b.x86_64                     
  fuse3-3.3.0-16.el8.x86_64                                                     
  fuse3-libs-3.3.0-16.el8.x86_64                                                
  iptables-libs-1.8.4-23.el8_7.1.x86_64                                         
  jansson-2.14-1.el8.x86_64                                                     
  jq-1.6-3.el8.x86_64                                                           
  kmod-25-19.el8.x86_64                                                         
  libibverbs-41.0-1.el8.x86_64                                                  
  libmnl-1.0.4-6.el8.x86_64                                                     
  libnet-1.1.6-15.el8.x86_64                                                    
  libnftnl-1.1.5-5.el8.x86_64                                                   
  libpcap-14:1.9.1-5.el8.x86_64                                                 
  libslirp-4.4.0-1.module+el8.7.0+17824+66a0202b.x86_64                         
  nftables-1:0.9.3-26.el8.x86_64                                                
  oniguruma-6.8.2-2.el8.x86_64                                                  
  protobuf-c-1.3.0-6.el8.x86_64                                                 
  runc-1:1.1.4-1.module+el8.7.0+17824+66a0202b.x86_64                           
  skopeo-2:1.9.4-0.1.module+el8.7.0+17824+66a0202b.x86_64                       
  slirp4netns-1.2.0-2.module+el8.7.0+17824+66a0202b.x86_64                      

Collecting yq
  Downloading https://files.pythonhosted.org/packages/aa/09/31d9eb047a46cf5680c4970f42bee931bd78aab4e3ded448406de4730f96/yq-3.1.1-py3-none-any.whl
Collecting argcomplete
  Downloading https://files.pythonhosted.org/packages/f0/ab/aaf32fd58b3aee615abee7f809998dc03ab7be788af4de63bb7f5bc0510b/argcomplete-2.0.6-py3-none-any.whl
Collecting toml>=0.10.0
  Downloading https://files.pythonhosted.org/packages/44/6f/7120676b6d73228c96e17f1f794d8ab046fc910d781c8d151120c3f1569e/toml-0.10.2-py2.py3-none-any.whl
Collecting PyYAML>=5.3.1
  Downloading https://files.pythonhosted.org/packages/d7/42/7ad4b6d67a16229496d4f6e74201bdbebcf4bc1e87d5a70c9297d4961bd2/PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (701kB)
Collecting xmltodict>=0.11.0
  Downloading https://files.pythonhosted.org/packages/94/db/fd0326e331726f07ff7f40675cd86aa804bfd2e5016c727fa761c934990e/xmltodict-0.13.0-py2.py3-none-any.whl
Installing collected packages: toml, PyYAML, argcomplete, xmltodict, yq
Successfully installed PyYAML-6.0 argcomplete-2.0.6 toml-0.10.2 xmltodict-0.13.0 yq-3.1.1
python: Python 3.8.13
yq: yq 3.1.1
jq: jq-1.6
--> 4b598ffb4e4
STEP 12/23: COPY ./build/scripts ./versions.json /build/
--> 2331feb58f3
STEP 13/23: COPY ./build/scripts/clone_and_zip.sh /build/build/scripts/
--> 13c55e23331
STEP 14/23: COPY ./VERSION /
--> 35652a21b27
STEP 15/23: COPY ./devfiles /build/devfiles
--> 43a848412e2
STEP 16/23: WORKDIR /build/
--> a14142c1793
STEP 17/23: RUN ./generate_devworkspace_templates.sh

> core-js@2.6.12 postinstall /build/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

[96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m

[96mThe project needs your help! Please consider supporting of core-js on Open Collective or Patreon: [0m
[96m>[94m https://opencollective.com/core-js [0m
[96m>[94m https://www.patreon.com/zloirock [0m

[96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m

+ @eclipse-che/che-devworkspace-generator@0.0.1-c8bd5c0
added 119 packages from 183 contributors and audited 119 packages in 10.262s

5 packages are looking for funding
  run `npm fund` for details

found 1 high severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details
DevWorkspace che-theia-java-lombok was generated.
DevWorkspace che-code-java-lombok was generated.
DevWorkspace che-code-java-lombok was generated.
DevWorkspace che-idea-java-lombok was generated.
DevWorkspace che-theia-quarkus-quickstart was generated.
DevWorkspace che-code-quarkus-quickstart was generated.
DevWorkspace che-code-quarkus-quickstart was generated.
DevWorkspace che-idea-quarkus-quickstart was generated.
DevWorkspace che-theia-nodejs-mongodb was generated.
DevWorkspace che-code-nodejs-mongodb was generated.
DevWorkspace che-code-nodejs-mongodb was generated.
DevWorkspace che-idea-nodejs-mongodb was generated.
DevWorkspace che-theia-nodejs-web-app was generated.
DevWorkspace che-code-nodejs-web-app was generated.
DevWorkspace che-code-nodejs-web-app was generated.
DevWorkspace che-idea-nodejs-web-app was generated.
DevWorkspace che-theia-python-hello-world was generated.
DevWorkspace che-code-python-hello-world was generated.
DevWorkspace che-code-python-hello-world was generated.
DevWorkspace che-idea-python-hello-world was generated.
DevWorkspace che-theia-cpp was generated.
DevWorkspace che-code-cpp was generated.
DevWorkspace che-code-cpp was generated.
DevWorkspace che-idea-cpp was generated.
DevWorkspace che-theia-dotnet was generated.
DevWorkspace che-code-dotnet was generated.
DevWorkspace che-code-dotnet was generated.
DevWorkspace che-idea-dotnet was generated.
DevWorkspace che-theia-golang was generated.
DevWorkspace che-code-golang was generated.
DevWorkspace che-code-golang was generated.
DevWorkspace che-idea-golang was generated.
DevWorkspace che-theia-php-hello-world was generated.
DevWorkspace che-code-php-hello-world was generated.
DevWorkspace che-code-php-hello-world was generated.
DevWorkspace che-idea-php-hello-world was generated.
--> 689fe2c2300
STEP 18/23: RUN chmod -R g+rwX /build/resources
--> 319b1bf49cd
STEP 19/23: RUN ./check_referenced_images.sh devfiles --registries "${ALLOWED_REGISTRIES}" --tags "${ALLOWED_TAGS}"
 + registry.redhat.io/devspaces/code-rhel8:3.5 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/idea-rhel8:3.5 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/machineexec-rhel8:3.5 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/theia-endpoint-rhel8:3.5 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/theia-rhel8:3.5 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/udi-rhel8:3.5 PASS - registry.redhat.io allowed
 + registry.redhat.io/rhscl/mongodb-36-rhel7:1-50 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/code-rhel8:3.5 PASS - 3.5 allowed
 + registry.redhat.io/devspaces/idea-rhel8:3.5 PASS - 3.5 allowed
 + registry.redhat.io/devspaces/machineexec-rhel8:3.5 PASS - 3.5 allowed
 + registry.redhat.io/devspaces/theia-endpoint-rhel8:3.5 PASS - 3.5 allowed
 + registry.redhat.io/devspaces/theia-rhel8:3.5 PASS - 3.5 allowed
 + registry.redhat.io/devspaces/udi-rhel8:3.5 PASS - 3.5 allowed
 = registry.redhat.io/rhscl/mongodb-36-rhel7:1-50 PASS
--> c18269ab6b1
STEP 20/23: RUN ./check_mandatory_fields.sh devfiles
Checking devfile 'devfiles/TP__cpp__c-plus-plus/meta.yaml'
Checking devfile 'devfiles/TP__dotnet__dotnet-web-simple/meta.yaml'
Checking devfile 'devfiles/TP__go__golang-health-check/meta.yaml'
Checking devfile 'devfiles/TP__php__php-hello-world/meta.yaml'
Checking devfile 'devfiles/java11-maven-lombok__lombok-project-sample/meta.yaml'
Checking devfile 'devfiles/java11-maven-quarkus__quarkus-quickstarts/meta.yaml'
Checking devfile 'devfiles/nodejs__nodejs-mongodb-sample/meta.yaml'
Checking devfile 'devfiles/nodejs__web-nodejs-sample/meta.yaml'
Checking devfile 'devfiles/python__python-hello-world/meta.yaml'
--> 4ec1589c9d0
STEP 21/23: COPY ./build/dockerfiles/rhel.cache_projects.sh /tmp/ 
--> 38331babe5f
STEP 22/23: RUN /tmp/rhel.cache_projects.sh /build/ && rm -rf /tmp/rhel.cache_projects.sh /tmp/resources.tgz 
--> 05e039d903f
STEP 23/23: RUN ./index.sh > /build/devfiles/index.json &&     ./list_referenced_images.sh devfiles > /build/devfiles/external_images.txt &&     ./list_referenced_images_by_file.sh devfiles > /build/devfiles/external_images_by_devfile.txt &&     chmod -R g+rwX /build/devfiles
COMMIT devfileregistry:tmp
--> fcc304a82c4
Successfully tagged localhost/devfileregistry:tmp
fcc304a82c41b0ea5b8c14373c5840e1d0de8f06e064a06848914110140781e3
<======= END BOOTSTRAP BUILD =======
Downloading root-local.tgz
Downloading resources.tgz
Untagged: localhost/devfileregistry:tmp
Deleted: fcc304a82c41b0ea5b8c14373c5840e1d0de8f06e064a06848914110140781e3
Deleted: 05e039d903f513aea8a320435553a0df4da75600a3f1cb75494b62e5cee44991
Deleted: 38331babe5f06f3ba368a83285a441abe8188676e8ed6a8b7ef639f8bbc665dd
Deleted: 4ec1589c9d0b7d5fdcfd6f75bf2d04b70787cd43cc58c998eff436ee53e9e9de
Deleted: c18269ab6b195a8ade215d223ba21668edc19d4b8153f745f1564344bc6908a5
Deleted: 319b1bf49cd62ede82778abcd1a483f2d049bcb461c659f3ed27f90131226fab
Deleted: 689fe2c23008bdebf1b7b6c32b311f343fc30a8f0840f0101b9f68ede0ccb9fe
Deleted: a14142c17938ca320439f90f5cf7ef1315742220b499197532486fa0c38c2b50
Deleted: 43a848412e27ed20ae2694c6cc14a8c4d7ee9dfe673967180abb8a97ad37cc1a
Deleted: 35652a21b2744d59f86e9e0b8227881d7b8aa6d85ba0b31ed46e8818c7960669
Deleted: 13c55e23331c8d6881670ecd3adddf1c2f9a1d2f16a50e13b8da22638e69577b
Deleted: 2331feb58f381f9676f32a619c2bafb1bfe212552608cf225047d78a2e387d9b
Deleted: 4b598ffb4e45d619063e51ee369c9c8e1c54b4b6cb5035bf48bab2937b996961
Deleted: 3458358c62bfefd1093aa0eeeed107a2034d01bf7eb6e24d9eb97b42ccc3a31b
Deleted: 7597b06ec25c6bba70e56a8cb186b7345aecfe50faced35ed54f165fd87cc51c
Deleted: 3c288c59be6295aae91b72a986a3501c18c8d8d1dd80f436ee31b7e6e0be329f
Deleted: 070de7cb6682e58855f14fe953ec19682ecff8abb4be8483dea0c187d6f58f34
Deleted: 1c114b8cae71846456f66c4730f1f8a99dd286ee9159af8e82ff9027f057b370
Deleted: 2ebe84db4662f74425c49749a0c2135dfeeea93ede47a6d3d0ce490fe3c1ae84
Deleted: 583b9ec9c5eb8d570950bf079cb1fcfb888844f5be4e2f3f07b4d6aff211b052
Deleted: 456b9b37223a4cec6c4b95df5ba4270932fbe163dc853d99143f680d976d2161
Deleted: 4a01434642f66dbb1c3168f3a7669a429f0bcefd2cb6a3b422a8c1bd23d5322d
File already uploaded: root-local.tgz
File already uploaded: resources.tgz
All sources were already uploaded.
rm 'resources.tgz'
rm 'root-local.tgz'
