======= 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-129 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-129 AS builder
STEP 2/23: USER 0
--> 9cd6394dfee
STEP 3/23: ARG BOOTSTRAP=true
--> 8692659ecd7
STEP 4/23: ENV BOOTSTRAP=${BOOTSTRAP}
--> 7e72163b93d
STEP 5/23: ARG ALLOWED_REGISTRIES=""
--> 036ea773138
STEP 6/23: ENV ALLOWED_REGISTRIES=${ALLOWED_REGISTRIES}
--> 7f03fe9b167
STEP 7/23: ARG ALLOWED_TAGS=""
--> c8db69ccf4e
STEP 8/23: ENV ALLOWED_TAGS=${ALLOWED_TAGS}
--> 38cf587a5ba
STEP 9/23: COPY ./build/dockerfiles/content_sets_rhel8.repo /etc/yum.repos.d/
--> a9f51524dc5
STEP 10/23: COPY ./build/dockerfiles/rhel.install.sh /tmp
--> bbf7ae90b3f
STEP 11/23: RUN /tmp/rhel.install.sh && rm -f /tmp/rhel.install.sh

Installed:
  containers-common-2:1-64.module+el8.8.0+18571+eed59fc4.x86_64                 
  criu-3.15-4.module+el8.8.0+19044+f9982fd8.x86_64                              
  fuse-common-3.3.0-16.el8.x86_64                                               
  fuse-overlayfs-1.11-1.module+el8.8.0+18634+9a268292.x86_64                    
  fuse3-3.3.0-16.el8.x86_64                                                     
  fuse3-libs-3.3.0-16.el8.x86_64                                                
  iptables-libs-1.8.4-24.el8.x86_64                                             
  jansson-2.14-1.el8.x86_64                                                     
  jq-1.6-6.el8.x86_64                                                           
  kmod-25-19.el8.x86_64                                                         
  libibverbs-44.0-2.el8.1.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.8.0+18060+3f21f2cc.x86_64                         
  mpdecimal-2.5.1-3.el8.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                                                 
  python3.11-3.11.2-2.el8_8.1.x86_64                                            
  python3.11-devel-3.11.2-2.el8_8.1.x86_64                                      
  python3.11-libs-3.11.2-2.el8_8.1.x86_64                                       
  python3.11-pip-22.3.1-2.el8.noarch                                            
  python3.11-pip-wheel-22.3.1-2.el8.noarch                                      
  python3.11-setuptools-65.5.1-2.el8.noarch                                     
  python3.11-setuptools-wheel-65.5.1-2.el8.noarch                               
  runc-1:1.1.4-1.module+el8.8.0+18060+3f21f2cc.x86_64                           
  skopeo-2:1.11.2-0.2.module+el8.8.0+18251+ad5b274c.x86_64                      
  slirp4netns-1.2.0-2.module+el8.8.0+18060+3f21f2cc.x86_64                      

Collecting yq
  Downloading yq-3.2.2-py3-none-any.whl (17 kB)
Collecting argcomplete
  Downloading argcomplete-3.1.1-py3-none-any.whl (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.5/41.5 kB 3.9 MB/s eta 0:00:00
Requirement already satisfied: pip in /usr/lib/python3.11/site-packages (22.3.1)
Collecting pip
  Downloading pip-23.2.1-py3-none-any.whl (2.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 37.0 MB/s eta 0:00:00
Collecting PyYAML>=5.3.1
  Downloading PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (757 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 757.7/757.7 kB 437.4 MB/s eta 0:00:00
Collecting xmltodict>=0.11.0
  Downloading xmltodict-0.13.0-py2.py3-none-any.whl (10.0 kB)
Collecting tomlkit>=0.11.6
  Downloading tomlkit-0.12.1-py3-none-any.whl (37 kB)
Installing collected packages: xmltodict, tomlkit, PyYAML, pip, argcomplete, yq
Successfully installed PyYAML-6.0.1 argcomplete-3.1.1 pip-23.2.1 tomlkit-0.12.1 xmltodict-0.13.0 yq-3.2.2
python: Python 3.8.16
yq: yq 3.2.2
jq: jq-1.6
--> e205248a378
STEP 12/23: COPY ./build/scripts ./versions.json /build/
--> b319ef3d8e8
STEP 13/23: COPY ./build/scripts/clone_and_zip.sh /build/build/scripts/
--> a49c2fde861
STEP 14/23: COPY ./VERSION /
--> f26b5dbc266
STEP 15/23: COPY ./devfiles /build/devfiles
--> 74d9634f056
STEP 16/23: WORKDIR /build/
--> 6f03411e2e6
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-99986b8
added 119 packages from 183 contributors and audited 119 packages in 8.083s

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

found 3 vulnerabilities (2 moderate, 1 high)
  run `npm audit fix` to fix them, or `npm audit` for details
DevWorkspace che-code-ansible-demo was generated.
DevWorkspace che-code-ansible-demo was generated.
DevWorkspace che-idea-ansible-demo 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-code-quarkus-quickstart was generated.
DevWorkspace che-code-quarkus-quickstart was generated.
DevWorkspace che-idea-quarkus-quickstart 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-code-nodejs-web-app was generated.
DevWorkspace che-code-nodejs-web-app was generated.
DevWorkspace che-idea-nodejs-web-app 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-code-cpp was generated.
DevWorkspace che-code-cpp was generated.
DevWorkspace che-idea-cpp was generated.
DevWorkspace che-code-dotnet was generated.
DevWorkspace che-code-dotnet was generated.
DevWorkspace che-idea-dotnet was generated.
DevWorkspace che-code-golang was generated.
DevWorkspace che-code-golang was generated.
DevWorkspace che-idea-golang 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.
--> 25c181c1ecc
STEP 18/23: RUN chmod -R g+rwX /build/resources
--> 7d3ae1940b0
STEP 19/23: RUN ./check_referenced_images.sh devfiles --registries "${ALLOWED_REGISTRIES}" --tags "${ALLOWED_TAGS}"
 = quay.io/devspaces/ansible-creator-ee@sha256:3ff5d2d5f17c9c1e4a352d9922e27be09641647ac028a56845aaab6f6e3c7958 PASS
 + registry.redhat.io/devspaces/code-rhel8:3.8 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/idea-rhel8:3.8 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/udi-rhel8:3.8 PASS - registry.redhat.io allowed
 + registry.redhat.io/rhscl/mongodb-36-rhel7:1-50 PASS - registry.redhat.io allowed
 = quay.io/devspaces/ansible-creator-ee@sha256:3ff5d2d5f17c9c1e4a352d9922e27be09641647ac028a56845aaab6f6e3c7958 PASS
 + registry.redhat.io/devspaces/code-rhel8:3.8 PASS - 3.8 allowed
 + registry.redhat.io/devspaces/idea-rhel8:3.8 PASS - 3.8 allowed
 + registry.redhat.io/devspaces/udi-rhel8:3.8 PASS - 3.8 allowed
 = registry.redhat.io/rhscl/mongodb-36-rhel7:1-50 PASS
--> 9d3a9eb4dd3
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/ansible__ansible-demo/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'
--> ba6e95a78ab
STEP 21/23: COPY ./build/dockerfiles/rhel.cache_projects.sh /tmp/ 
--> 1d8dbab6ebd
STEP 22/23: RUN /tmp/rhel.cache_projects.sh /build/ && rm -rf /tmp/rhel.cache_projects.sh /tmp/resources.tgz 
--> 48c2778ade9
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
--> 51b96c391d7
Successfully tagged localhost/devfileregistry:tmp
51b96c391d7929373ad6ef774c098495d7824ff3c5018258d8b7ff88fcd281b8
<======= END BOOTSTRAP BUILD =======
Downloading root-local.tgz
Downloading resources.tgz
Untagged: localhost/devfileregistry:tmp
Deleted: 51b96c391d7929373ad6ef774c098495d7824ff3c5018258d8b7ff88fcd281b8
Deleted: 48c2778ade9fe0ede0a85e5ba1f196af81e2bea448a61ccd46c87c8c43d25c85
Deleted: 1d8dbab6ebd869e91516c876437128220c4d6a17b676fada8ac962fbdf67eb3a
Deleted: ba6e95a78abc45c1ba327792d53bf333954074d56e87c3b083d506129a363d3e
Deleted: 9d3a9eb4dd38eb72575ab9efc4d8ed73a3d831823523f4dc3a62a1513c702d0f
Deleted: 7d3ae1940b0c05aaa2fc0bad532c816524a25ba7ac0f311a5c77d7e5557a33c6
Deleted: 25c181c1ecc053822b16f996a3d7c11eb70ab77de13e3545185794a24d92fa24
Deleted: 6f03411e2e691b165d01c83d5bfebe0812928033b73103745cf6ca3320b3777d
Deleted: 74d9634f056a04aef822bdb3e4fc3e221f17562b3d77aa11c03938d5446e7133
Deleted: f26b5dbc2663b47da1e1e7f6d8759cc73020bd2091860f6109417c45d4abcdd3
Deleted: a49c2fde861c9a521f109bb22f608d437c8aed0f364f48fdb3ba6c1e4913a15e
Deleted: b319ef3d8e82d4cd051a5a770e39f1d2c1cb1e8c27a310d51cf1d158630315b1
Deleted: e205248a3784364fec5dc12f2d3c88a64412e55f286489f4506c6b75412efc1f
Deleted: bbf7ae90b3fa2a9a5e5b77bc5a86937c8dd652fefeab9e510baac4c3f3b7f611
Deleted: a9f51524dc5d9b192646ed86c54afdd6cc753014e393b6bb2f739390f98a61e2
Deleted: 38cf587a5ba90121f57442c5bf904c2acdd2c2a0edc03a8f7b791302f2982d21
Deleted: c8db69ccf4e5a680d561b9b639d52ae608a9c51e75ca128c3e9a1aafa69d547c
Deleted: 7f03fe9b167a1e750fd18b9dec7c2479c456c12177197733d62f93c1c3445692
Deleted: 036ea7731381bd39eea9c28de61634edb1551f5365dbeb15cf2dc60b7d901656
Deleted: 7e72163b93decb8434a2ef48f779cab945e7e2f5949d67ea2f84a04a02dae2f4
Deleted: 8692659ecd708ae7034d52bd51487b7ea84ee906213d6114db71bdf3be957da6
Deleted: 9cd6394dfee8e1306a0ee6b85f31fc4aaf47bf6c46777ff5c4935849e9b0049d
File already uploaded: root-local.tgz
File already uploaded: resources.tgz
All sources were already uploaded.
rm 'resources.tgz'
rm 'root-local.tgz'
