======= 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
--> 814735ce24d
STEP 3/23: ARG BOOTSTRAP=true
--> c7dc59b5f1d
STEP 4/23: ENV BOOTSTRAP=${BOOTSTRAP}
--> b6c81282fae
STEP 5/23: ARG ALLOWED_REGISTRIES=""
--> fdf2083cf8d
STEP 6/23: ENV ALLOWED_REGISTRIES=${ALLOWED_REGISTRIES}
--> 1b9fe57aca5
STEP 7/23: ARG ALLOWED_TAGS=""
--> 419e3385f1d
STEP 8/23: ENV ALLOWED_TAGS=${ALLOWED_TAGS}
--> 69bb0e88541
STEP 9/23: COPY ./build/dockerfiles/content_sets_rhel8.repo /etc/yum.repos.d/
--> a6622b8a1dc
STEP 10/23: COPY ./build/dockerfiles/rhel.install.sh /tmp
--> a196d2ceeab
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 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: argcomplete, toml, PyYAML, xmltodict, 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
--> c96c95984f3
STEP 12/23: COPY ./build/scripts ./versions.json /build/
--> a5f4ca1b8f9
STEP 13/23: COPY ./build/scripts/clone_and_zip.sh /build/build/scripts/
--> 870bb1c81df
STEP 14/23: COPY ./VERSION /
--> 2aefa10eba9
STEP 15/23: COPY ./devfiles /build/devfiles
--> 120d08cc7cb
STEP 16/23: WORKDIR /build/
--> f1536bd24ac
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 182 contributors and audited 120 packages in 9.092s

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

found 0 vulnerabilities

+ @eclipse-che/che-code-devworkspace-handler@1.64.0-dev-210b722
added 2 packages from 1 contributor and audited 239 packages in 1.989s

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

found 0 vulnerabilities

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
No sidecar policy. Setting to useDevContainer
--> 989ccacb979
STEP 18/23: RUN chmod -R g+rwX /build/resources
--> 471291dc853
STEP 19/23: RUN ./check_referenced_images.sh devfiles --registries "${ALLOWED_REGISTRIES}" --tags "${ALLOWED_TAGS}"
 + registry.redhat.io/devspaces/code-rhel8:3.3 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/machineexec-rhel8:3.3 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/theia-endpoint-rhel8:3.3 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/theia-rhel8:3.3 PASS - registry.redhat.io allowed
 + registry.redhat.io/devspaces/udi-rhel8:3.3 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.3 PASS - 3.3 allowed
 + registry.redhat.io/devspaces/machineexec-rhel8:3.3 PASS - 3.3 allowed
 + registry.redhat.io/devspaces/theia-endpoint-rhel8:3.3 PASS - 3.3 allowed
 + registry.redhat.io/devspaces/theia-rhel8:3.3 PASS - 3.3 allowed
 + registry.redhat.io/devspaces/udi-rhel8:3.3 PASS - 3.3 allowed
 = registry.redhat.io/rhscl/mongodb-36-rhel7:1-50 PASS
--> 25aa72bc73e
STEP 20/23: RUN ./check_mandatory_fields.sh devfiles
Checking devfile 'devfiles/03_java11-maven-gradle/meta.yaml'
Checking devfile 'devfiles/03_java11-maven-lombok/meta.yaml'
Checking devfile 'devfiles/03_java11-maven-quarkus/meta.yaml'
Checking devfile 'devfiles/04_nodejs-mongo/meta.yaml'
Checking devfile 'devfiles/04_nodejs-simple/meta.yaml'
Checking devfile 'devfiles/04_python/meta.yaml'
Checking devfile 'devfiles/05_cpp/meta.yaml'
Checking devfile 'devfiles/05_dotnet/meta.yaml'
Checking devfile 'devfiles/05_go/meta.yaml'
Checking devfile 'devfiles/05_php-cake/meta.yaml'
--> c5a7bf6c9c7
STEP 21/23: COPY ./build/dockerfiles/rhel.cache_projects.sh /tmp/ 
--> c18bff79417
STEP 22/23: RUN /tmp/rhel.cache_projects.sh /build/ && rm -rf /tmp/rhel.cache_projects.sh /tmp/resources.tgz 
--> 26968676066
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
--> 2fab5014bad
Successfully tagged localhost/devfileregistry:tmp
2fab5014bad5c6c2d8f95e68cece84a8457dc3da731de5f5b807a72673febe0b
<======= END BOOTSTRAP BUILD =======
Downloading root-local.tgz
Downloading resources.tgz
DIFF START *****
diff --suppress-common-lines -u -r /tmp/tmp.Zoeram6m8f/devfiles/05_go/devworkspace-che-theia-latest.yaml /tmp/tmp.iupvOd3vcu/devfiles/05_go/devworkspace-che-theia-latest.yaml
--- /tmp/tmp.Zoeram6m8f/devfiles/05_go/devworkspace-che-theia-latest.yaml	2022-11-22 11:00:47.000000000 -0500
+++ /tmp/tmp.iupvOd3vcu/devfiles/05_go/devworkspace-che-theia-latest.yaml	2022-11-23 06:29:17.021470828 -0500
@@ -182,9 +182,6 @@
               relative:extension/resources/github_com/golang/vscode-go/releases/download/v0_23_0/go-0.23.0.vsix
             - >-
               relative:extension/resources/github_com/fabric8-analytics/fabric8-analytics-vscode-extension/releases/download/0_3_6/fabric8-analytics-0.3.6.vsix
-          che-theia.eclipse.org/vscode-preferences:
-            go.lintTool: golangci-lint
-            go.lintFlags: '--fast'
           app.kubernetes.io/name: tools
       - name: che-theia-golang
         plugin:
Binary files /tmp/tmp.Zoeram6m8f/resources/v2/golang-health-check.zip and /tmp/tmp.iupvOd3vcu/resources/v2/golang-health-check.zip differ
***** END DIFF
Untagged: localhost/devfileregistry:tmp
Deleted: 2fab5014bad5c6c2d8f95e68cece84a8457dc3da731de5f5b807a72673febe0b
Deleted: 26968676066ffd3cfb474bf870d59ed95e40392c48224a29bc4e81fa1f8599bf
Deleted: c18bff79417c1d666340b21cff8f8fee281b58aa8b4cf2752d6bc05789f13408
Deleted: c5a7bf6c9c7395fb9911db5938154727dd160594bc05488421a934e3a7f13e7f
Deleted: 25aa72bc73e7f1995905819244b0e34972818fbb36d44d331213ed90a67f7a95
Deleted: 471291dc853870cfc95f8c6456b5ec5eef070453716edaa811f68492857af0ee
Deleted: 989ccacb979fa099334cb21a2d6e051f3dffa8690b0ff498b69e007187af98c4
Deleted: f1536bd24ac839cd5f7da84ae9f9ce6f9bea42acd39e5a0e2a98898d5eca923f
Deleted: 120d08cc7cb0bd79c7c2495bff6a538acef5df6d8105dd2b1dc84865638a5f44
Deleted: 2aefa10eba9c1d2d18d6156bfdc61960cdb3a621475f04cf296d262e1a6c9e71
Deleted: 870bb1c81dfaf86f5086aa916d81f125fed1892df0db92b9c11cd9d45e75c77b
Deleted: a5f4ca1b8f93c202e65310a15f896d9642417de03a360fa86d46d45eb1c82aa4
Deleted: c96c95984f3fc1c52f03e0be8b74672201894f1d889d12255767f9dcfccc3212
Deleted: a196d2ceeab1ab08cc43366dfe7a1cfdcaf8c98937114426d152b324abbee2f1
Deleted: a6622b8a1dcdacff528237e1b5c3ef0bda52618aa8daeb40e5bf268d6ee8a5be
Deleted: 69bb0e8854104744f82a5e82bedda59f74b69b42e494eeefe4a35e6b9bd22c9c
Deleted: 419e3385f1d6d40b9e5d03916287595582d3cb3e79fcf4d3282c22f0be5d4f6f
Deleted: 1b9fe57aca5dd79166d71a13362cd1e0453e4935a20aabfe147cda2d9af65189
Deleted: fdf2083cf8d9916896361c214bd3b812e8f3c79eeaaf7d7be4639a21d9d3eaaa
Deleted: b6c81282faed9204e33e16e35091119ef0293b36e517ee25b7710ed70f490342
Deleted: c7dc59b5f1d1a30ac279bea68e1f1bd356a8128b96120f743a54dbc0ca8db97b
Deleted: 814735ce24da2bada78a06a0968023a6a7f0e1933438ee7d953140f41eccde63
File already uploaded: root-local.tgz
Uploading: resources.tgz
Source upload succeeded. Don't forget to commit the sources file
rm 'resources.tgz'
rm 'root-local.tgz'
