======= BOOTSTRAP DOCKERFILE =======>
#
# Copyright (c) 2018-2022 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
# registry.access.redhat.com/ubi8/python-38
FROM registry-proxy.engineering.redhat.com/rh-osbs/ubi8-python-38:1-100 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-proxy.engineering.redhat.com/rh-osbs/ubi8-python-38:1-100 AS builder
STEP 2/23: USER 0
--> 56ec26bd0a2
STEP 3/23: ARG BOOTSTRAP=true
--> 711a61beb21
STEP 4/23: ENV BOOTSTRAP=${BOOTSTRAP}
--> 807b5ec1b3a
STEP 5/23: ARG ALLOWED_REGISTRIES=""
--> b72de7e942b
STEP 6/23: ENV ALLOWED_REGISTRIES=${ALLOWED_REGISTRIES}
--> a32a7fc011c
STEP 7/23: ARG ALLOWED_TAGS=""
--> 308b3ea028d
STEP 8/23: ENV ALLOWED_TAGS=${ALLOWED_TAGS}
--> 14d6332c799
STEP 9/23: COPY ./build/dockerfiles/content_sets_rhel8.repo /etc/yum.repos.d/
--> 0e8f2ec194a
STEP 10/23: COPY ./build/dockerfiles/rhel.install.sh /tmp
--> c80782c2a77
STEP 11/23: RUN /tmp/rhel.install.sh && rm -f /tmp/rhel.install.sh

Upgraded:
  bash-4.4.20-4.el8_6.x86_64                                                    
  dnf-4.7.0-11.el8.noarch                                                       
  dnf-data-4.7.0-11.el8.noarch                                                  
  nodejs-1:14.20.1-2.module+el8.7.0+16991+b0a68a3e.x86_64                       
  nodejs-docs-1:14.20.1-2.module+el8.7.0+16991+b0a68a3e.noarch                  
  nodejs-full-i18n-1:14.20.1-2.module+el8.7.0+16991+b0a68a3e.x86_64             
  npm-1:6.14.17-1.14.20.1.2.module+el8.7.0+16991+b0a68a3e.x86_64                
  python3-dnf-4.7.0-11.el8.noarch                                               
  python38-3.8.13-1.module+el8.7.0+15641+2ece4388.x86_64                        
  python38-devel-3.8.13-1.module+el8.7.0+15641+2ece4388.x86_64                  
  python38-libs-3.8.13-1.module+el8.7.0+15641+2ece4388.x86_64                   
  python38-pip-19.3.1-6.module+el8.7.0+15823+8950cfa7.noarch                    
  tar-2:1.30-6.el8.x86_64                                                       
  yum-4.7.0-11.el8.noarch                                                       
Installed:
  containers-common-2:1-43.module+el8.7.0+17064+3b31f55c.x86_64                 
  criu-3.15-3.module+el8.7.0+17064+3b31f55c.x86_64                              
  fuse-common-3.3.0-16.el8.x86_64                                               
  fuse-overlayfs-1.9-1.module+el8.7.0+17064+3b31f55c.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.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+17064+3b31f55c.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+17064+3b31f55c.x86_64                           
  skopeo-2:1.9.3-1.module+el8.7.0+17064+3b31f55c.x86_64                         
  slirp4netns-1.2.0-2.module+el8.7.0+17064+3b31f55c.x86_64                      

Collecting yq
  Downloading https://files.pythonhosted.org/packages/60/2c/ab35b5ec3b884b6e33b18ba3f6be6b94d607501fca1e5a8de22988690cdb/yq-3.1.0-py3-none-any.whl
Collecting argcomplete
  Downloading https://files.pythonhosted.org/packages/d3/e5/c5509683462e51b070df9e83e7f72c1ccfe3f733f328b4a0f06804c27278/argcomplete-2.0.0-py2.py3-none-any.whl
Collecting xmltodict>=0.11.0
  Downloading https://files.pythonhosted.org/packages/94/db/fd0326e331726f07ff7f40675cd86aa804bfd2e5016c727fa761c934990e/xmltodict-0.13.0-py2.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)
Installing collected packages: xmltodict, argcomplete, toml, PyYAML, yq
Successfully installed PyYAML-6.0 argcomplete-2.0.0 toml-0.10.2 xmltodict-0.13.0 yq-3.1.0
python: Python 3.8.13
yq: yq 3.1.0
jq: jq-1.6
--> 9a7a9e907ec
STEP 12/23: COPY ./build/scripts ./versions.json /build/
--> 6de270e0472
STEP 13/23: COPY ./build/scripts/clone_and_zip.sh /build/build/scripts/
--> 0a99b4e3ee1
STEP 14/23: COPY ./VERSION /
--> 5c8993bad59
STEP 15/23: COPY ./devfiles /build/devfiles
--> b1fe785585d
STEP 16/23: WORKDIR /build/
--> 77517a75f7d
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-theia-devworkspace-handler@0.0.1-1649678182
added 120 packages from 183 contributors and audited 120 packages in 10.01s

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
+ @eclipse-che/che-code-devworkspace-handler@1.64.0-dev-210b722
added 2 packages from 1 contributor and audited 239 packages in 2.752s

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

found 5 high severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
No sidecar policy. Setting to useDevContainer
No sidecar policy. Setting to useDevContainer
No sidecar policy. Setting to useDevContainer
No sidecar policy. Setting to useDevContainer
No sidecar policy. Setting to useDevContainer
No sidecar policy. Setting to useDevContainer
No sidecar policy. Setting to useDevContainer
No sidecar policy. Setting to useDevContainer
No sidecar policy. Setting to useDevContainer
--> c4a31acf158
STEP 18/23: RUN chmod -R g+rwX /build/resources
--> fad9f848ee8
STEP 19/23: RUN ./check_referenced_images.sh devfiles --registries "${ALLOWED_REGISTRIES}" --tags "${ALLOWED_TAGS}"
 + registry.redhat.io/devspaces/code-rhel8:3.4 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/machineexec-rhel8:3.4 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/theia-endpoint-rhel8:3.4 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/theia-rhel8:3.4 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/udi-rhel8:3.4 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.4 PASS - 3.4 allowed
 + registry.redhat.io/devspaces/machineexec-rhel8:3.4 PASS - 3.4 allowed
 + registry.redhat.io/devspaces/theia-endpoint-rhel8:3.4 PASS - 3.4 allowed
 + registry.redhat.io/devspaces/theia-rhel8:3.4 PASS - 3.4 allowed
 + registry.redhat.io/devspaces/udi-rhel8:3.4 PASS - 3.4 allowed
 = registry.redhat.io/rhscl/mongodb-36-rhel7:1-50 PASS
--> d9e88f52b48
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'
--> b8f67761926
STEP 21/23: COPY ./build/dockerfiles/rhel.cache_projects.sh /tmp/ 
--> a6c23a596e4
STEP 22/23: RUN /tmp/rhel.cache_projects.sh /build/ && rm -rf /tmp/rhel.cache_projects.sh /tmp/resources.tgz 
--> 22d13f6fe9a
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
--> f56d1f8e67e
Successfully tagged localhost/devfileregistry:tmp
f56d1f8e67e0c24cb7b6ceafc461add9d37326aa0ff0487f6cb3eeb47f92e7bf
<======= END BOOTSTRAP BUILD =======
Downloading root-local.tgz
Downloading resources.tgz
Untagged: localhost/devfileregistry:tmp
Deleted: f56d1f8e67e0c24cb7b6ceafc461add9d37326aa0ff0487f6cb3eeb47f92e7bf
Deleted: 22d13f6fe9a2f91f7f027a734a425340bff0e2199021d3fe343cbf1989504b1d
Deleted: a6c23a596e4d60444394f941251b8f8f6dfd972a39f30af2cf2d96638b95a31f
Deleted: b8f6776192661d6c61d9f87e39a640ac2561c176fa4b272a08f3a614e2fb9fbe
Deleted: d9e88f52b48cc59f71ef715831e4e6e5dce1af413f11c9f0ba62023e5d4e485a
Deleted: fad9f848ee83c57026148396006fc36df1d7e6f620a678779fd4a4528082445d
Deleted: c4a31acf15819153f77ebe896bc8c2c9aae9d84d540c206f155cab66dd873f5b
Deleted: 77517a75f7dd0f5bbd240cd4297925546f0be4cbac4e992f21ec2f9164cb3840
Deleted: b1fe785585d142b5ca30bb4fb9d49fe29cdb63f2d2a9349628fc2f9a5fc73dc9
Deleted: 5c8993bad59ae5e47907e0ffcafb766dd2335592aae18a5daf6f8def108ebe52
Deleted: 0a99b4e3ee1048655689720cf2dcb06b1d38f63332a81f750c86ce36f4c31dd6
Deleted: 6de270e0472b87dd8edf779ebc0748ef65dffabe7e94a80e4771ab66e31a8193
Deleted: 9a7a9e907ec2ca56f9c137052bf1b8177041832443aa4999cc6f6ad2e4d45285
Deleted: c80782c2a771523ff20c4341c8adcc9ee9ae16152fcd0a125312ac66cc82c755
Deleted: 0e8f2ec194a81ff20673e1d5530903118985b0d6f67d6641c9019e3066fcef2d
Deleted: 14d6332c799bd54f0b84556c3c730cdbc5ed1b81ecfb4d6e1f186276119eab13
Deleted: 308b3ea028da3f8c6f4f2ee4efa991796856f8c71d076b051af7bdc870d2192a
Deleted: a32a7fc011c2c86becdf8f6948ff8a64f6e792a9ba5c1fb77b99752eccf2d745
Deleted: b72de7e942b43b4d7518ed8aa3ebcd366470e5c7c9c2a9f83f4df3186bd297ea
Deleted: 807b5ec1b3a7e7856d50529bd6de8ffc2bef66ed1e4cb83e5d23bd3d8e58cc83
Deleted: 711a61beb218b7b8936cb103368dc97132f3c1d8b8524768ba2c7def680e861e
Deleted: 56ec26bd0a2032b4d2549f577765a8eb2ec0cc21087f2f6adaf4ecf09ffb23d0
File already uploaded: root-local.tgz
File already uploaded: resources.tgz
All sources were already uploaded.
rm 'resources.tgz'
rm 'root-local.tgz'
