├── 14 ├── .exclude-centos7 ├── .exclude-rhel8 ├── Dockerfile ├── Dockerfile.fedora ├── Dockerfile.rhel7 ├── Dockerfile.rhel8 ├── README.md ├── cccp.yml ├── root │ └── opt │ │ └── app-root │ │ └── etc │ │ ├── generate_container_user │ │ ├── npm_global_module_list │ │ └── scl_enable ├── s2i │ └── bin │ │ ├── assemble │ │ ├── init-wrapper │ │ ├── run │ │ ├── save-artifacts │ │ └── usage └── test ├── 16 ├── .exclude-c9s ├── .exclude-centos7 ├── Dockerfile ├── Dockerfile.c9s ├── Dockerfile.fedora ├── Dockerfile.rhel7 ├── Dockerfile.rhel8 ├── Dockerfile.rhel9 ├── README.md ├── cccp.yml ├── root │ └── opt │ │ └── app-root │ │ └── etc │ │ ├── generate_container_user │ │ ├── npm_global_module_list │ │ └── scl_enable ├── s2i │ └── bin │ │ ├── assemble │ │ ├── init-wrapper │ │ ├── run │ │ ├── save-artifacts │ │ └── usage └── test ├── 18 ├── .exclude-c8s ├── .exclude-c9s ├── Dockerfile.c8s ├── Dockerfile.c9s ├── Dockerfile.fedora ├── Dockerfile.rhel8 ├── Dockerfile.rhel9 ├── README.md ├── root │ └── opt │ │ └── app-root │ │ └── etc │ │ ├── generate_container_user │ │ ├── npm_global_module_list │ │ └── scl_enable ├── s2i │ └── bin │ │ ├── assemble │ │ ├── init-wrapper │ │ ├── run │ │ ├── save-artifacts │ │ └── usage └── test ├── 20 ├── .exclude-c8s ├── Dockerfile.c8s ├── Dockerfile.c9s ├── Dockerfile.fedora ├── Dockerfile.rhel8 ├── Dockerfile.rhel9 ├── README.md ├── root │ └── opt │ │ └── app-root │ │ └── etc │ │ ├── generate_container_user │ │ ├── npm_global_module_list │ │ └── scl_enable ├── s2i │ └── bin │ │ ├── assemble │ │ ├── init-wrapper │ │ ├── run │ │ ├── save-artifacts │ │ └── usage └── test ├── 22 ├── .exclude-c8s ├── .exclude-c9s ├── Dockerfile.c10s ├── Dockerfile.c8s ├── Dockerfile.c9s ├── Dockerfile.fedora ├── Dockerfile.rhel10 ├── Dockerfile.rhel8 ├── Dockerfile.rhel9 ├── README.md ├── root │ └── opt │ │ └── app-root │ │ └── etc │ │ ├── generate_container_user │ │ ├── npm_global_module_list │ │ └── scl_enable ├── s2i │ └── bin │ │ ├── assemble │ │ ├── init-wrapper │ │ ├── run │ │ ├── save-artifacts │ │ └── usage └── test ├── .github ├── auto-merge.yml ├── dependabot.yml └── workflows │ ├── auto-merge-on-demand.yml │ ├── auto-merge.yml │ ├── build-and-push.yml │ ├── container-tests.yml │ ├── container-upstream-tests.yml │ ├── openshift-pytests.yml │ ├── openshift-tests.yml │ └── pr-metadata.yml ├── .gitignore ├── .gitmodules ├── 14-minimal ├── .exclude-rhel8 ├── .exclude.c9s ├── Dockerfile.rhel8 ├── README.md ├── root │ └── usr │ │ └── bin │ │ └── fix-permissions ├── s2i │ └── bin │ │ ├── assemble │ │ ├── init-wrapper │ │ ├── run │ │ ├── save-artifacts │ │ └── usage └── test │ ├── check_imagestreams.py │ ├── examples │ ├── imagestreams │ ├── run │ ├── run-openshift-remote-cluster │ ├── test-app │ ├── test-binary │ ├── test-express-webapp │ ├── test-hw │ ├── test-incremental │ ├── test-lib-nodejs.sh │ ├── test-lib-openshift.sh │ ├── test-lib-remote-openshift.sh │ ├── test-lib.sh │ └── test-openshift.yaml ├── 16-minimal ├── Dockerfile.rhel8 ├── Dockerfile.rhel9 ├── README.md ├── root │ └── usr │ │ └── bin │ │ └── fix-permissions ├── s2i │ └── bin │ │ ├── assemble │ │ ├── init-wrapper │ │ ├── run │ │ ├── save-artifacts │ │ └── usage └── test │ ├── check_imagestreams.py │ ├── examples │ ├── imagestreams │ ├── run │ ├── run-openshift-remote-cluster │ ├── test-app │ ├── test-binary │ ├── test-express-webapp │ ├── test-hw │ ├── test-incremental │ ├── test-lib-nodejs.sh │ ├── test-lib-openshift.sh │ ├── test-lib-remote-openshift.sh │ ├── test-lib.sh │ └── test-openshift.yaml ├── 18-minimal ├── .exclude-c8s ├── .exclude-c9s ├── Dockerfile.c8s ├── Dockerfile.c9s ├── Dockerfile.fedora ├── Dockerfile.rhel8 ├── Dockerfile.rhel9 ├── README.md ├── root │ └── usr │ │ └── bin │ │ └── fix-permissions ├── s2i │ └── bin │ │ ├── assemble │ │ ├── init-wrapper │ │ ├── run │ │ ├── save-artifacts │ │ └── usage └── test │ ├── check_imagestreams.py │ ├── examples │ ├── imagestreams │ ├── run │ ├── run-openshift-remote-cluster │ ├── test-app │ ├── test-binary │ ├── test-express-webapp │ ├── test-hw │ ├── test-incremental │ ├── test-lib-nodejs.sh │ ├── test-lib-openshift.sh │ ├── test-lib-remote-openshift.sh │ ├── test-lib.sh │ └── test-openshift.yaml ├── 20-minimal ├── .exclude-c8s ├── Dockerfile.c8s ├── Dockerfile.c9s ├── Dockerfile.fedora ├── Dockerfile.rhel8 ├── Dockerfile.rhel9 ├── README.md ├── root │ └── usr │ │ └── bin │ │ └── fix-permissions ├── s2i │ └── bin │ │ ├── assemble │ │ ├── init-wrapper │ │ ├── run │ │ ├── save-artifacts │ │ └── usage └── test │ ├── check_imagestreams.py │ ├── examples │ ├── imagestreams │ ├── run │ ├── run-openshift-remote-cluster │ ├── test-app │ ├── test-binary │ ├── test-express-webapp │ ├── test-hw │ ├── test-incremental │ ├── test-lib-nodejs.sh │ ├── test-lib-openshift.sh │ ├── test-lib-remote-openshift.sh │ ├── test-lib.sh │ └── test-openshift.yaml ├── 22-minimal ├── .exclude-c8s ├── .exclude-c9s ├── Dockerfile.c10s ├── Dockerfile.c8s ├── Dockerfile.c9s ├── Dockerfile.fedora ├── Dockerfile.rhel10 ├── Dockerfile.rhel8 ├── Dockerfile.rhel9 ├── README.md ├── root │ └── usr │ │ └── bin │ │ └── fix-permissions ├── s2i │ └── bin │ │ ├── assemble │ │ ├── init-wrapper │ │ ├── run │ │ ├── save-artifacts │ │ └── usage └── test │ ├── check_imagestreams.py │ ├── examples │ ├── imagestreams │ ├── run │ ├── run-openshift-remote-cluster │ ├── test-app │ ├── test-binary │ ├── test-express-webapp │ ├── test-hw │ ├── test-incremental │ ├── test-lib-nodejs.sh │ ├── test-lib-openshift.sh │ ├── test-lib-remote-openshift.sh │ ├── test-lib.sh │ └── test-openshift.yaml ├── LICENSE ├── Makefile ├── README.md ├── examples └── from-dockerfile │ ├── .gitignore │ ├── Dockerfile │ ├── Dockerfile.s2i │ └── README.md ├── imagestreams ├── imagestreams.yaml ├── nodejs-centos.json ├── nodejs-rhel-aarch64.json └── nodejs-rhel.json └── test ├── check_imagestreams.py ├── examples ├── imagestreams ├── run ├── run-minimal ├── run-openshift-pytest ├── run-openshift-remote-cluster ├── run-upstream ├── show_all_imagestreams.py ├── test-app ├── README.md ├── iisnode.yml ├── package.json ├── server.js └── web.config ├── test-binary ├── binary.js └── package.json ├── test-express-webapp ├── app.js ├── bin │ └── www ├── package.json ├── public │ └── stylesheets │ │ └── style.css ├── routes │ ├── index.js │ └── users.js └── views │ ├── error.jade │ ├── index.jade │ └── layout.jade ├── test-hw ├── hw.js └── package.json ├── test-incremental ├── README.md ├── iisnode.yml ├── package.json ├── server.js └── web.config ├── test-lib-nodejs.sh ├── test-lib-openshift.sh ├── test-lib-remote-openshift.sh ├── test-lib.sh ├── test-openshift.yaml ├── test_imagestreams_quickstart.py ├── test_latest_imagestreams.py ├── test_nodejs_ex_standalone.py ├── test_nodejs_ex_templates.py ├── test_nodejs_s2i_standalone.py ├── test_shared_helm_nodejs_application.py └── test_shared_helm_nodejs_imagestreams.py /.github/auto-merge.yml: -------------------------------------------------------------------------------- 1 | target-branch: [] 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | version: 2 4 | updates: 5 | - package-ecosystem: gitsubmodule 6 | directory: / 7 | schedule: 8 | interval: weekly 9 | labels: 10 | - 'ready for review' 11 | - package-ecosystem: github-actions 12 | directory: / 13 | schedule: 14 | interval: monthly 15 | labels: 16 | - 'ready for review' 17 | -------------------------------------------------------------------------------- /.github/workflows/auto-merge-on-demand.yml: -------------------------------------------------------------------------------- 1 | name: Auto Merge On Demand 2 | on: 3 | issue_comment: 4 | types: 5 | - created 6 | workflow_dispatch: 7 | inputs: 8 | pr-number: 9 | description: 'Pull Request number/s ; when not provided, the workflow will run for all open PRs' 10 | required: true 11 | default: '0' 12 | 13 | permissions: 14 | contents: read 15 | 16 | jobs: 17 | # Get all open PRs 18 | gather-pull-requests: 19 | if: | 20 | github.repository_owner == 'sclorg' 21 | || (contains(github.event.comment.body, '/auto-merge') 22 | && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)) 23 | runs-on: ubuntu-latest 24 | 25 | outputs: 26 | pr-numbers: ${{ steps.get-pr-numbers.outputs.result }} 27 | pr-numbers-manual: ${{ steps.parse-manual-input.outputs.result }} 28 | 29 | steps: 30 | - id: get-pr-numbers 31 | if: inputs.pr-number == '0' 32 | name: Get all open PRs 33 | uses: actions/github-script@v7 34 | with: 35 | # !FIXME: this is not working if there is more than 100 PRs opened 36 | script: | 37 | const { data: pullRequests } = await github.rest.pulls.list({ 38 | owner: context.repo.owner, 39 | repo: context.repo.repo, 40 | state: 'open', 41 | per_page: 100 42 | }); 43 | return pullRequests.map(pr => pr.number); 44 | 45 | - id: parse-manual-input 46 | if: inputs.pr-number != '0' 47 | name: Parse manual input 48 | run: | 49 | # shellcheck disable=SC2086 50 | echo "result="[ ${{ github.event.issue.number }} ]"" >> $GITHUB_OUTPUT 51 | shell: bash 52 | 53 | validate-pr: 54 | name: 'Validation of Pull Request #${{ matrix.pr-number }}' 55 | needs: [ gather-pull-requests ] 56 | runs-on: ubuntu-latest 57 | 58 | strategy: 59 | fail-fast: false 60 | matrix: 61 | pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }} 62 | 63 | permissions: 64 | # required for merging PRs 65 | contents: write 66 | # required for PR comments and setting labels 67 | pull-requests: write 68 | 69 | steps: 70 | - name: Auto Merge wrapper 71 | uses: sclorg/auto-merge-wrapper@v1 72 | with: 73 | pr-number: ${{ matrix.pr-number }} 74 | token: ${{ secrets.GITHUB_TOKEN }} 75 | -------------------------------------------------------------------------------- /.github/workflows/auto-merge.yml: -------------------------------------------------------------------------------- 1 | name: Auto Merge 2 | on: 3 | workflow_run: 4 | workflows: [ Gather Pull Request Metadata ] 5 | types: 6 | - completed 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | download-metadata: 13 | if: > 14 | github.event.workflow_run.event == 'pull_request' && 15 | github.event.workflow_run.conclusion == 'success' 16 | runs-on: ubuntu-latest 17 | 18 | outputs: 19 | pr-metadata: ${{ steps.Artifact.outputs.pr-metadata-json }} 20 | 21 | steps: 22 | - id: Artifact 23 | name: Download Artifact 24 | uses: redhat-plumbers-in-action/download-artifact@v1 25 | with: 26 | name: pr-metadata 27 | 28 | auto-merge: 29 | needs: [ download-metadata ] 30 | runs-on: ubuntu-latest 31 | 32 | permissions: 33 | # required for merging PRs 34 | contents: write 35 | # required for PR comments and setting labels 36 | pull-requests: write 37 | 38 | steps: 39 | - name: Auto Merge wrapper 40 | uses: sclorg/auto-merge-wrapper@v1 41 | with: 42 | pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }} 43 | token: ${{ secrets.GITHUB_TOKEN }} 44 | -------------------------------------------------------------------------------- /.github/workflows/container-tests.yml: -------------------------------------------------------------------------------- 1 | on: 2 | issue_comment: 3 | types: 4 | - created 5 | jobs: 6 | container-tests: 7 | # This job only runs for '[test]' pull request comments by owner, member 8 | name: "Container tests: ${{ matrix.version }} - ${{ matrix.os_test }}" 9 | runs-on: ubuntu-latest 10 | concurrency: 11 | group: container-${{ github.event.issue.number }}-${{ matrix.version }}-${{ matrix.os_test }} 12 | cancel-in-progress: true 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | version: [ "20", "20-minimal", "22", "22-minimal" ] 17 | os_test: [ "fedora", "rhel8", "rhel9", "rhel10", "c9s", "c10s" ] 18 | test_case: [ "container" ] 19 | 20 | if: | 21 | github.event.issue.pull_request 22 | && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]')) 23 | && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association) 24 | steps: 25 | - uses: sclorg/tfaga-wrapper@main 26 | with: 27 | os_test: ${{ matrix.os_test }} 28 | version: ${{ matrix.version }} 29 | test_case: ${{ matrix.test_case }} 30 | public_api_key: ${{ secrets.TF_PUBLIC_API_KEY }} 31 | private_api_key: ${{ secrets.TF_INTERNAL_API_KEY }} 32 | -------------------------------------------------------------------------------- /.github/workflows/container-upstream-tests.yml: -------------------------------------------------------------------------------- 1 | on: 2 | issue_comment: 3 | types: 4 | - created 5 | jobs: 6 | container-tests: 7 | # This job only runs for '[test-upstream]' pull request comments by owner, member 8 | name: "Container Upstream Tests ${{ matrix.version }} - ${{ matrix.os_test }}" 9 | runs-on: ubuntu-latest 10 | concurrency: 11 | group: container-upstream-${{ github.event.issue.number }}-${{ matrix.version }}-${{ matrix.os_test }} 12 | cancel-in-progress: true 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | version: [ "20", "20-minimal", "22", "22-minimal" ] 17 | os_test: [ "fedora", "rhel8", "rhel9", "rhel10", "c9s", "c10s" ] 18 | test_case: [ "container-upstream" ] 19 | 20 | if: | 21 | github.event.issue.pull_request 22 | && (contains(github.event.comment.body, '[test-upstream]') || contains(github.event.comment.body, '[test-all]')) 23 | && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association) 24 | steps: 25 | - uses: sclorg/tfaga-wrapper@main 26 | with: 27 | os_test: ${{ matrix.os_test }} 28 | version: ${{ matrix.version }} 29 | test_case: ${{ matrix.test_case }} 30 | public_api_key: ${{ secrets.TF_PUBLIC_API_KEY }} 31 | private_api_key: ${{ secrets.TF_INTERNAL_API_KEY }} 32 | -------------------------------------------------------------------------------- /.github/workflows/openshift-pytests.yml: -------------------------------------------------------------------------------- 1 | on: 2 | issue_comment: 3 | types: 4 | - created 5 | jobs: 6 | check-imagestreams: 7 | runs-on: ubuntu-latest 8 | permissions: 9 | contents: read 10 | statuses: write 11 | if: | 12 | github.event.issue.pull_request 13 | && (contains(github.event.comment.body, '[test-openshift-pytest]') || contains(github.event.comment.body, '[test-all]')) 14 | && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association) 15 | steps: 16 | - uses: sclorg/ci-scripts/ocp-stream-generator@master 17 | with: 18 | ref: "refs/pull/${{ github.event.issue.number }}/head" 19 | 20 | openshift-pytests: 21 | name: "${{ matrix.test_case }} PyTests: ${{ matrix.version }} - ${{ matrix.os_test }}" 22 | runs-on: ubuntu-latest 23 | needs: check-imagestreams 24 | concurrency: 25 | group: ocp-pytest-${{ github.event.issue.number }}-${{ matrix.version }}-${{ matrix.os_test }} 26 | cancel-in-progress: true 27 | strategy: 28 | fail-fast: false 29 | matrix: 30 | version: [ "20", "20-minimal", "22", "22-minimal" ] 31 | os_test: [ "rhel8", "rhel9", "rhel10" ] 32 | test_case: [ "openshift-pytest" ] 33 | 34 | steps: 35 | - uses: sclorg/tfaga-wrapper@main 36 | with: 37 | os_test: ${{ matrix.os_test }} 38 | version: ${{ matrix.version }} 39 | test_case: ${{ matrix.test_case }} 40 | public_api_key: ${{ secrets.TF_PUBLIC_API_KEY }} 41 | private_api_key: ${{ secrets.TF_INTERNAL_API_KEY }} 42 | -------------------------------------------------------------------------------- /.github/workflows/openshift-tests.yml: -------------------------------------------------------------------------------- 1 | on: 2 | issue_comment: 3 | types: 4 | - created 5 | jobs: 6 | check-imagestreams: 7 | runs-on: ubuntu-latest 8 | permissions: 9 | contents: read 10 | statuses: write 11 | if: | 12 | github.event.issue.pull_request 13 | && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]')) 14 | && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association) 15 | steps: 16 | - uses: sclorg/ci-scripts/ocp-stream-generator@master 17 | with: 18 | ref: "refs/pull/${{ github.event.issue.number }}/head" 19 | 20 | openshift-tests: 21 | name: "${{ matrix.test_case }}tests: ${{ matrix.version }} - ${{ matrix.os_test }}" 22 | runs-on: ubuntu-latest 23 | needs: check-imagestreams 24 | concurrency: 25 | group: ocp-${{ github.event.issue.number }}-${{ matrix.version }}-${{ matrix.os_test }} 26 | cancel-in-progress: true 27 | strategy: 28 | fail-fast: false 29 | matrix: 30 | version: [ "20", "20-minimal", "22", "22-minimal" ] 31 | os_test: [ "rhel8", "rhel9", "rhel10" ] 32 | test_case: [ "openshift-4" ] 33 | 34 | steps: 35 | - uses: sclorg/tfaga-wrapper@main 36 | with: 37 | os_test: ${{ matrix.os_test }} 38 | version: ${{ matrix.version }} 39 | test_case: ${{ matrix.test_case }} 40 | public_api_key: ${{ secrets.TF_PUBLIC_API_KEY }} 41 | private_api_key: ${{ secrets.TF_INTERNAL_API_KEY }} 42 | -------------------------------------------------------------------------------- /.github/workflows/pr-metadata.yml: -------------------------------------------------------------------------------- 1 | name: Gather Pull Request Metadata 2 | on: 3 | pull_request: 4 | types: [ opened, reopened, synchronize ] 5 | branches: [ master ] 6 | 7 | permissions: 8 | contents: read 9 | 10 | jobs: 11 | gather-metadata: 12 | if: github.repository_owner == 'sclorg' 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Repository checkout 17 | uses: actions/checkout@v4 18 | 19 | - id: Metadata 20 | name: Gather Pull Request Metadata 21 | uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1 22 | 23 | - name: Upload artifact with gathered metadata 24 | uses: actions/upload-artifact@v4 25 | with: 26 | name: pr-metadata 27 | path: ${{ steps.Metadata.outputs.metadata-file }} 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # help.1 files complied by container-common-scripts from README.md files 2 | */root/help.1 3 | 4 | # .image-id files are generated by common.mk (common subproject) 5 | .image-id* 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "common"] 2 | path = common 3 | url = https://github.com/sclorg/container-common-scripts.git 4 | -------------------------------------------------------------------------------- /14-minimal/.exclude-rhel8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sclorg/s2i-nodejs-container/ff61c620ca06214a60080b899c257e170d0dbdb1/14-minimal/.exclude-rhel8 -------------------------------------------------------------------------------- /14-minimal/.exclude.c9s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sclorg/s2i-nodejs-container/ff61c620ca06214a60080b899c257e170d0dbdb1/14-minimal/.exclude.c9s -------------------------------------------------------------------------------- /14-minimal/Dockerfile.rhel8: -------------------------------------------------------------------------------- 1 | FROM ubi8/ubi-minimal:latest 2 | 3 | EXPOSE 8080 4 | 5 | # Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts 6 | # available on the CLI without using npm's --global installation mode 7 | # This image will be initialized with "npm run $NPM_RUN" 8 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 9 | # file for possible values of NPM_RUN 10 | # Description 11 | # Environment: 12 | # * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). 13 | # Expose ports: 14 | # * 8080 - Unprivileged port used by nodejs application 15 | ENV APP_ROOT=/opt/app-root \ 16 | # The $HOME is not set by default, but some applications need this variable 17 | HOME=/opt/app-root/src \ 18 | NPM_RUN=start \ 19 | PLATFORM="el8" \ 20 | NODEJS_VERSION=14 \ 21 | NPM_RUN=start \ 22 | NAME=nodejs 23 | 24 | ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ 25 | DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ 26 | running various Node.js $NODEJS_VERSION applications and frameworks. \ 27 | Node.js is a platform built on Chrome's JavaScript runtime for easily building \ 28 | fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ 29 | that makes it lightweight and efficient, perfect for data-intensive real-time applications \ 30 | that run across distributed devices." \ 31 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 32 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH 33 | 34 | LABEL summary="$SUMMARY" \ 35 | description="$DESCRIPTION" \ 36 | io.k8s.description="$DESCRIPTION" \ 37 | io.k8s.display-name="Node.js $NODEJS_VERSION Minimal" \ 38 | io.openshift.expose-services="8080:http" \ 39 | io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ 40 | io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ 41 | io.s2i.scripts-url="image:///usr/libexec/s2i" \ 42 | com.redhat.dev-mode="DEV_MODE:false" \ 43 | com.redhat.deployments-dir="${APP_ROOT}/src" \ 44 | com.redhat.dev-mode.port="DEBUG_PORT:5858" \ 45 | com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ 46 | name="ubi8/$NAME-$NODEJS_VERSION-minimal" \ 47 | version="1" \ 48 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ 49 | maintainer="SoftwareCollections.org " \ 50 | help="For more information visit https://github.com/sclorg/s2i-nodejs-container" 51 | 52 | RUN INSTALL_PKGS="nodejs nodejs-nodemon npm findutils tar" && \ 53 | microdnf module disable nodejs && \ 54 | microdnf module enable nodejs:$NODEJS_VERSION && \ 55 | microdnf --nodocs install $INSTALL_PKGS && \ 56 | node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ 57 | microdnf clean all && \ 58 | rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* 59 | 60 | COPY ./s2i/bin/ /usr/libexec/s2i 61 | RUN chmod +x /usr/libexec/s2i/init-wrapper 62 | 63 | # Copy extra files to the image. 64 | COPY ./root/ / 65 | 66 | # Drop the root user and make the content of /opt/app-root owned by user 1001 67 | RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" 68 | WORKDIR "$HOME" 69 | USER 1001 70 | -------------------------------------------------------------------------------- /14-minimal/README.md: -------------------------------------------------------------------------------- 1 | NodeJS 14 minimal container image 2 | ========================= 3 | 4 | **The NodeJS 14 minimal image is deprecated.** 5 | -------------------------------------------------------------------------------- /14-minimal/root/usr/bin/fix-permissions: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Allow this script to fail without failing a build 4 | set +e 5 | 6 | SYMLINK_OPT=${2:--L} 7 | 8 | # Fix permissions on the given directory or file to allow group read/write of 9 | # regular files and execute of directories. 10 | 11 | [ $(id -u) -ne 0 ] && CHECK_OWNER=" -uid $(id -u)" 12 | 13 | # If argument does not exist, script will still exit with 0, 14 | # but at least we'll see something went wrong in the log 15 | if ! [ -e "$1" ] ; then 16 | echo "ERROR: File or directory $1 does not exist." >&2 17 | # We still want to end successfully 18 | exit 0 19 | fi 20 | 21 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -gid 0 -exec chgrp 0 {} + 22 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -perm -g+rw -exec chmod g+rw {} + 23 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} -perm /u+x -a \! -perm /g+x -exec chmod g+x {} + 24 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} -type d \! -perm /g+x -exec chmod g+x {} + 25 | 26 | # Always end successfully 27 | exit 0 28 | -------------------------------------------------------------------------------- /14-minimal/s2i/bin/init-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html 4 | # Set a trap to kill the main app process when this 5 | # init script receives SIGTERM or SIGINT 6 | trap 'kill -s TERM $PID' TERM INT 7 | # Execute the main application in the background 8 | "$@" & 9 | PID=$! 10 | # wait command always terminates when trap is caught, even if the process hasn't finished yet 11 | wait $PID 12 | # Remove the trap and wait till the app process finishes completely 13 | trap - TERM INT 14 | # We wait again, since the first wait terminates when trap is caught 15 | wait $PID 16 | # Exit with the exit code of the app process 17 | STATUS=$? 18 | exit $STATUS -------------------------------------------------------------------------------- /14-minimal/s2i/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # S2I run script for the 'nodejs' image. 4 | # The run script executes the server that runs your application. 5 | # 6 | # For more information see the documentation: 7 | # https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md 8 | # 9 | 10 | set -e 11 | 12 | # Runs the nodejs application server. If the container is run in development mode, 13 | # hot deploy and debugging are enabled. 14 | run_node() { 15 | echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" 16 | if [ "$DEV_MODE" == true ]; then 17 | echo "Launching via nodemon..." 18 | exec nodemon --inspect="$DEBUG_PORT" 19 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 20 | echo "launching via init wrapper..." 21 | exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD 22 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then 23 | echo "Launching via ${NODE_CMD}" 24 | exec $NODE_CMD 25 | elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 26 | 27 | package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json) 28 | package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json) 29 | 30 | if [ -n "$package_json_start" ]; then 31 | start_command=$package_json_start 32 | elif [ -n $package_json_main ]; then 33 | start_command="node ." 34 | elif [ -f "server.js" ]; then 35 | start_command="node server.js" 36 | else 37 | echo "Failed to find file for starting the Node.js application" 38 | exit 1 39 | fi 40 | echo "launching via init wrapper..." 41 | exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command 42 | else 43 | echo "Launching via npm..." 44 | exec npm run -d $NPM_RUN 45 | fi 46 | } 47 | 48 | #Set the debug port to 5858 by default. 49 | if [ -z "$DEBUG_PORT" ]; then 50 | export DEBUG_PORT=5858 51 | fi 52 | 53 | # Set the environment to development by default. 54 | if [ -z "$DEV_MODE" ]; then 55 | export DEV_MODE=false 56 | fi 57 | 58 | # If NODE_ENV is not set by the user, then NODE_ENV is determined by whether 59 | # the container is run in development mode. 60 | if [ -z "$NODE_ENV" ]; then 61 | if [ "$DEV_MODE" == true ]; then 62 | export NODE_ENV=development 63 | else 64 | export NODE_ENV=production 65 | fi 66 | fi 67 | 68 | # If the official dockerhub node image is used, skip the SCL setup below 69 | # and just run the nodejs server 70 | if [ -d "/usr/src/app" ]; then 71 | run_node 72 | fi 73 | 74 | # Allow users to inspect/debug the builder image itself, by using: 75 | # $ docker run -i -t openshift/centos-nodejs-builder --debug 76 | # 77 | [ "$1" == "--debug" ] && exec /bin/bash 78 | 79 | run_node 80 | -------------------------------------------------------------------------------- /14-minimal/s2i/bin/save-artifacts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then 4 | tar -C "${HOME}" -cf - node_modules 5 | fi 6 | -------------------------------------------------------------------------------- /14-minimal/s2i/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` 4 | 5 | cat < $NSS_WRAPPER_PASSWD 11 | 12 | echo "default:x:${USER_ID}:${GROUP_ID}:Default Application User:${HOME}:/sbin/nologin" >> $NSS_WRAPPER_PASSWD 13 | 14 | export NSS_WRAPPER_PASSWD 15 | export NSS_WRAPPER_GROUP 16 | export LD_PRELOAD=libnss_wrapper.so 17 | fi 18 | -------------------------------------------------------------------------------- /14/root/opt/app-root/etc/npm_global_module_list: -------------------------------------------------------------------------------- 1 | async 2 | mime 3 | mkdirp 4 | qs 5 | minimatch 6 | -------------------------------------------------------------------------------- /14/root/opt/app-root/etc/scl_enable: -------------------------------------------------------------------------------- 1 | # This will make scl collection binaries work out of box. 2 | unset BASH_ENV PROMPT_COMMAND ENV 3 | source scl_source enable rh-nodejs${NODEJS_VERSION} 4 | -------------------------------------------------------------------------------- /14/s2i/bin/assemble: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Prevent running assemble in builders different than official STI image. 4 | # The official nodejs:8-onbuild already run npm install and use different 5 | # application folder. 6 | [ -d "/usr/src/app" ] && exit 0 7 | 8 | set -e 9 | 10 | # FIXME: Linking of global modules is disabled for now as it causes npm failures 11 | # under RHEL7 12 | # Global modules good to have 13 | # npmgl=$(grep "^\s*[^#\s]" ../etc/npm_global_module_list | sort -u) 14 | # Available global modules; only match top-level npm packages 15 | #global_modules=$(npm ls -g 2> /dev/null | perl -ne 'print "$1\n" if /^\S+\s(\S+)\@[\d\.-]+/' | sort -u) 16 | # List all modules in common 17 | #module_list=$(/usr/bin/comm -12 <(echo "${global_modules}") | tr '\n' ' ') 18 | # Link the modules 19 | #npm link $module_list 20 | 21 | safeLogging () { 22 | if [[ $1 =~ http[s]?://.*@.*$ ]]; then 23 | echo $1 | sed 's/^.*@/redacted@/' 24 | else 25 | echo $1 26 | fi 27 | } 28 | 29 | shopt -s dotglob 30 | if [ -d /tmp/artifacts ] && [ "$(ls /tmp/artifacts/ 2>/dev/null)" ]; then 31 | echo "---> Restoring previous build artifacts ..." 32 | mv -T --verbose /tmp/artifacts/node_modules "${HOME}/node_modules" 33 | fi 34 | 35 | echo "---> Installing application source ..." 36 | mv /tmp/src/* ./ 37 | 38 | # Fix source directory permissions 39 | fix-permissions ./ 40 | 41 | if [ ! -z $HTTP_PROXY ]; then 42 | echo "---> Setting npm http proxy to" $(safeLogging $HTTP_PROXY) 43 | npm config set proxy $HTTP_PROXY 44 | fi 45 | 46 | if [ ! -z $http_proxy ]; then 47 | echo "---> Setting npm http proxy to" $(safeLogging $http_proxy) 48 | npm config set proxy $http_proxy 49 | fi 50 | 51 | if [ ! -z $HTTPS_PROXY ]; then 52 | echo "---> Setting npm https proxy to" $(safeLogging $HTTPS_PROXY) 53 | npm config set https-proxy $HTTPS_PROXY 54 | fi 55 | 56 | if [ ! -z $https_proxy ]; then 57 | echo "---> Setting npm https proxy to" $(safeLogging $https_proxy) 58 | npm config set https-proxy $https_proxy 59 | fi 60 | 61 | # Change the npm registry mirror if provided 62 | if [ -n "$NPM_MIRROR" ]; then 63 | npm config set registry $NPM_MIRROR 64 | fi 65 | 66 | # Set the DEV_MODE to false by default. 67 | if [ -z "$DEV_MODE" ]; then 68 | export DEV_MODE=false 69 | fi 70 | 71 | # If NODE_ENV is not set by the user, then NODE_ENV is determined by whether 72 | # the container is run in development mode. 73 | if [ -z "$NODE_ENV" ]; then 74 | if [ "$DEV_MODE" == true ]; then 75 | export NODE_ENV=development 76 | else 77 | export NODE_ENV=production 78 | fi 79 | fi 80 | 81 | if [ "$NODE_ENV" != "production" ]; then 82 | 83 | echo "---> Building your Node application from source" 84 | npm install 85 | 86 | else 87 | 88 | echo "---> Installing all dependencies" 89 | NODE_ENV=development npm install 90 | 91 | #do not fail when there is no build script 92 | echo "---> Building in production mode" 93 | npm run ${NPM_BUILD:-build} --if-present 94 | 95 | echo "---> Pruning the development dependencies" 96 | npm prune 97 | 98 | NPM_TMP=$(npm config get tmp) 99 | if ! mountpoint $NPM_TMP; then 100 | echo "---> Cleaning the $NPM_TMP/npm-*" 101 | rm -rf $NPM_TMP/npm-* 102 | fi 103 | 104 | # Clear the npm's cache and tmp directories only if they are not a docker volumes 105 | NPM_CACHE=$(npm config get cache) 106 | if ! mountpoint $NPM_CACHE; then 107 | echo "---> Cleaning the npm cache $NPM_CACHE" 108 | #As of npm@5 even the 'npm cache clean --force' does not fully remove the cache directory 109 | # instead of $NPM_CACHE* use $NPM_CACHE/*. 110 | # We do not want to delete .npmrc file. 111 | rm -rf "${NPM_CACHE:?}/" 112 | fi 113 | fi 114 | 115 | # Fix source directory permissions 116 | fix-permissions ./ 117 | -------------------------------------------------------------------------------- /14/s2i/bin/init-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html 4 | # Set a trap to kill the main app process when this 5 | # init script receives SIGTERM or SIGINT 6 | trap 'kill -s TERM $PID' TERM INT 7 | # Execute the main application in the background 8 | "$@" & 9 | PID=$! 10 | # wait command always terminates when trap is caught, even if the process hasn't finished yet 11 | wait $PID 12 | # Remove the trap and wait till the app process finishes completely 13 | trap - TERM INT 14 | # We wait again, since the first wait terminates when trap is caught 15 | wait $PID 16 | # Exit with the exit code of the app process 17 | STATUS=$? 18 | exit $STATUS -------------------------------------------------------------------------------- /14/s2i/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # S2I run script for the 'nodejs' image. 4 | # The run script executes the server that runs your application. 5 | # 6 | # For more information see the documentation: 7 | # https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md 8 | # 9 | 10 | set -e 11 | 12 | if [ -e "/opt/app-root/etc/generate_container_user" ]; then 13 | source /opt/app-root/etc/generate_container_user 14 | fi 15 | 16 | # Runs the nodejs application server. If the container is run in development mode, 17 | # hot deploy and debugging are enabled. 18 | run_node() { 19 | echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" 20 | if [ "$DEV_MODE" == true ]; then 21 | echo "Launching via nodemon..." 22 | exec nodemon --inspect="$DEBUG_PORT" 23 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 24 | echo "launching via init wrapper..." 25 | exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD 26 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then 27 | echo "Launching via ${NODE_CMD}" 28 | exec $NODE_CMD 29 | elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 30 | 31 | package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json) 32 | package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json) 33 | 34 | if [ -n "$package_json_start" ]; then 35 | start_command=$package_json_start 36 | elif [ -n $package_json_main ]; then 37 | start_command="node ." 38 | elif [ -f "server.js" ]; then 39 | start_command="node server.js" 40 | else 41 | echo "Failed to find file for starting the Node.js application" 42 | exit 1 43 | fi 44 | echo "launching via init wrapper..." 45 | exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command 46 | else 47 | echo "Launching via npm..." 48 | exec npm run -d $NPM_RUN 49 | fi 50 | } 51 | 52 | #Set the debug port to 5858 by default. 53 | if [ -z "$DEBUG_PORT" ]; then 54 | export DEBUG_PORT=5858 55 | fi 56 | 57 | # Set the environment to development by default. 58 | if [ -z "$DEV_MODE" ]; then 59 | export DEV_MODE=false 60 | fi 61 | 62 | # If NODE_ENV is not set by the user, then NODE_ENV is determined by whether 63 | # the container is run in development mode. 64 | if [ -z "$NODE_ENV" ]; then 65 | if [ "$DEV_MODE" == true ]; then 66 | export NODE_ENV=development 67 | else 68 | export NODE_ENV=production 69 | fi 70 | fi 71 | 72 | # If the official dockerhub node image is used, skip the SCL setup below 73 | # and just run the nodejs server 74 | if [ -d "/usr/src/app" ]; then 75 | run_node 76 | fi 77 | 78 | # Allow users to inspect/debug the builder image itself, by using: 79 | # $ docker run -i -t openshift/centos-nodejs-builder --debug 80 | # 81 | [ "$1" == "--debug" ] && exec /bin/bash 82 | 83 | run_node 84 | -------------------------------------------------------------------------------- /14/s2i/bin/save-artifacts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then 4 | tar -C "${HOME}" -cf - node_modules 5 | fi 6 | -------------------------------------------------------------------------------- /14/s2i/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` 4 | 5 | cat <&2 17 | # We still want to end successfully 18 | exit 0 19 | fi 20 | 21 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -gid 0 -exec chgrp 0 {} + 22 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -perm -g+rw -exec chmod g+rw {} + 23 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} -perm /u+x -a \! -perm /g+x -exec chmod g+x {} + 24 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} -type d \! -perm /g+x -exec chmod g+x {} + 25 | 26 | # Always end successfully 27 | exit 0 28 | -------------------------------------------------------------------------------- /16-minimal/s2i/bin/init-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html 4 | # Set a trap to kill the main app process when this 5 | # init script receives SIGTERM or SIGINT 6 | trap 'kill -s TERM $PID' TERM INT 7 | # Execute the main application in the background 8 | "$@" & 9 | PID=$! 10 | # wait command always terminates when trap is caught, even if the process hasn't finished yet 11 | wait $PID 12 | # Remove the trap and wait till the app process finishes completely 13 | trap - TERM INT 14 | # We wait again, since the first wait terminates when trap is caught 15 | wait $PID 16 | # Exit with the exit code of the app process 17 | STATUS=$? 18 | exit $STATUS -------------------------------------------------------------------------------- /16-minimal/s2i/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # S2I run script for the 'nodejs' image. 4 | # The run script executes the server that runs your application. 5 | # 6 | # For more information see the documentation: 7 | # https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md 8 | # 9 | 10 | set -e 11 | 12 | # Runs the nodejs application server. If the container is run in development mode, 13 | # hot deploy and debugging are enabled. 14 | run_node() { 15 | echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" 16 | if [ "$DEV_MODE" == true ]; then 17 | echo "Launching via nodemon..." 18 | exec nodemon --inspect="$DEBUG_PORT" 19 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 20 | echo "launching via init wrapper..." 21 | exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD 22 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then 23 | echo "Launching via ${NODE_CMD}" 24 | exec $NODE_CMD 25 | elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 26 | 27 | package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json) 28 | package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json) 29 | 30 | if [ -n "$package_json_start" ]; then 31 | start_command=$package_json_start 32 | elif [ -n $package_json_main ]; then 33 | start_command="node ." 34 | elif [ -f "server.js" ]; then 35 | start_command="node server.js" 36 | else 37 | echo "Failed to find file for starting the Node.js application" 38 | exit 1 39 | fi 40 | echo "launching via init wrapper..." 41 | exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command 42 | else 43 | echo "Launching via npm..." 44 | exec npm run -d $NPM_RUN 45 | fi 46 | } 47 | 48 | #Set the debug port to 5858 by default. 49 | if [ -z "$DEBUG_PORT" ]; then 50 | export DEBUG_PORT=5858 51 | fi 52 | 53 | # Set the environment to development by default. 54 | if [ -z "$DEV_MODE" ]; then 55 | export DEV_MODE=false 56 | fi 57 | 58 | # If NODE_ENV is not set by the user, then NODE_ENV is determined by whether 59 | # the container is run in development mode. 60 | if [ -z "$NODE_ENV" ]; then 61 | if [ "$DEV_MODE" == true ]; then 62 | export NODE_ENV=development 63 | else 64 | export NODE_ENV=production 65 | fi 66 | fi 67 | 68 | # If the official dockerhub node image is used, skip the SCL setup below 69 | # and just run the nodejs server 70 | if [ -d "/usr/src/app" ]; then 71 | run_node 72 | fi 73 | 74 | # Allow users to inspect/debug the builder image itself, by using: 75 | # $ docker run -i -t openshift/centos-nodejs-builder --debug 76 | # 77 | [ "$1" == "--debug" ] && exec /bin/bash 78 | 79 | run_node 80 | -------------------------------------------------------------------------------- /16-minimal/s2i/bin/save-artifacts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then 4 | tar -C "${HOME}" -cf - node_modules 5 | fi 6 | -------------------------------------------------------------------------------- /16-minimal/s2i/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` 4 | 5 | cat < $NSS_WRAPPER_PASSWD 11 | 12 | echo "default:x:${USER_ID}:${GROUP_ID}:Default Application User:${HOME}:/sbin/nologin" >> $NSS_WRAPPER_PASSWD 13 | 14 | export NSS_WRAPPER_PASSWD 15 | export NSS_WRAPPER_GROUP 16 | export LD_PRELOAD=libnss_wrapper.so 17 | fi 18 | -------------------------------------------------------------------------------- /16/root/opt/app-root/etc/npm_global_module_list: -------------------------------------------------------------------------------- 1 | async 2 | mime 3 | mkdirp 4 | qs 5 | minimatch 6 | -------------------------------------------------------------------------------- /16/root/opt/app-root/etc/scl_enable: -------------------------------------------------------------------------------- 1 | # This will make scl collection binaries work out of box. 2 | unset BASH_ENV PROMPT_COMMAND ENV 3 | source scl_source enable rh-nodejs${NODEJS_VERSION} 4 | -------------------------------------------------------------------------------- /16/s2i/bin/init-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html 4 | # Set a trap to kill the main app process when this 5 | # init script receives SIGTERM or SIGINT 6 | trap 'kill -s TERM $PID' TERM INT 7 | # Execute the main application in the background 8 | "$@" & 9 | PID=$! 10 | # wait command always terminates when trap is caught, even if the process hasn't finished yet 11 | wait $PID 12 | # Remove the trap and wait till the app process finishes completely 13 | trap - TERM INT 14 | # We wait again, since the first wait terminates when trap is caught 15 | wait $PID 16 | # Exit with the exit code of the app process 17 | STATUS=$? 18 | exit $STATUS -------------------------------------------------------------------------------- /16/s2i/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # S2I run script for the 'nodejs' image. 4 | # The run script executes the server that runs your application. 5 | # 6 | # For more information see the documentation: 7 | # https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md 8 | # 9 | 10 | set -e 11 | 12 | if [ -e "/opt/app-root/etc/generate_container_user" ]; then 13 | source /opt/app-root/etc/generate_container_user 14 | fi 15 | 16 | # Runs the nodejs application server. If the container is run in development mode, 17 | # hot deploy and debugging are enabled. 18 | run_node() { 19 | echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" 20 | if [ "$DEV_MODE" == true ]; then 21 | echo "Launching via nodemon..." 22 | exec nodemon --inspect="$DEBUG_PORT" 23 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 24 | echo "launching via init wrapper..." 25 | exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD 26 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then 27 | echo "Launching via ${NODE_CMD}" 28 | exec $NODE_CMD 29 | elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 30 | 31 | package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json) 32 | package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json) 33 | 34 | if [ -n "$package_json_start" ]; then 35 | start_command=$package_json_start 36 | elif [ -n $package_json_main ]; then 37 | start_command="node ." 38 | elif [ -f "server.js" ]; then 39 | start_command="node server.js" 40 | else 41 | echo "Failed to find file for starting the Node.js application" 42 | exit 1 43 | fi 44 | echo "launching via init wrapper..." 45 | exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command 46 | else 47 | echo "Launching via npm..." 48 | exec npm run -d $NPM_RUN 49 | fi 50 | } 51 | 52 | #Set the debug port to 5858 by default. 53 | if [ -z "$DEBUG_PORT" ]; then 54 | export DEBUG_PORT=5858 55 | fi 56 | 57 | # Set the environment to development by default. 58 | if [ -z "$DEV_MODE" ]; then 59 | export DEV_MODE=false 60 | fi 61 | 62 | # If NODE_ENV is not set by the user, then NODE_ENV is determined by whether 63 | # the container is run in development mode. 64 | if [ -z "$NODE_ENV" ]; then 65 | if [ "$DEV_MODE" == true ]; then 66 | export NODE_ENV=development 67 | else 68 | export NODE_ENV=production 69 | fi 70 | fi 71 | 72 | # If the official dockerhub node image is used, skip the SCL setup below 73 | # and just run the nodejs server 74 | if [ -d "/usr/src/app" ]; then 75 | run_node 76 | fi 77 | 78 | # Allow users to inspect/debug the builder image itself, by using: 79 | # $ docker run -i -t openshift/centos-nodejs-builder --debug 80 | # 81 | [ "$1" == "--debug" ] && exec /bin/bash 82 | 83 | run_node 84 | -------------------------------------------------------------------------------- /16/s2i/bin/save-artifacts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then 4 | tar -C "${HOME}" -cf - node_modules 5 | fi 6 | -------------------------------------------------------------------------------- /16/s2i/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` 4 | 5 | cat <&2 17 | # We still want to end successfully 18 | exit 0 19 | fi 20 | 21 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -gid 0 -exec chgrp 0 {} + 22 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -perm -g+rw -exec chmod g+rw {} + 23 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} -perm /u+x -a \! -perm /g+x -exec chmod g+x {} + 24 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} -type d \! -perm /g+x -exec chmod g+x {} + 25 | 26 | # Always end successfully 27 | exit 0 28 | -------------------------------------------------------------------------------- /18-minimal/s2i/bin/init-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html 4 | # Set a trap to kill the main app process when this 5 | # init script receives SIGTERM or SIGINT 6 | trap 'kill -s TERM $PID' TERM INT 7 | # Execute the main application in the background 8 | "$@" & 9 | PID=$! 10 | # wait command always terminates when trap is caught, even if the process hasn't finished yet 11 | wait $PID 12 | # Remove the trap and wait till the app process finishes completely 13 | trap - TERM INT 14 | # We wait again, since the first wait terminates when trap is caught 15 | wait $PID 16 | # Exit with the exit code of the app process 17 | STATUS=$? 18 | exit $STATUS -------------------------------------------------------------------------------- /18-minimal/s2i/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # S2I run script for the 'nodejs' image. 4 | # The run script executes the server that runs your application. 5 | # 6 | # For more information see the documentation: 7 | # https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md 8 | # 9 | 10 | set -e 11 | 12 | # Runs the nodejs application server. If the container is run in development mode, 13 | # hot deploy and debugging are enabled. 14 | run_node() { 15 | echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" 16 | if [ "$DEV_MODE" == true ]; then 17 | echo "Launching via nodemon..." 18 | exec nodemon --inspect="$DEBUG_PORT" 19 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 20 | echo "launching via init wrapper..." 21 | exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD 22 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then 23 | echo "Launching via ${NODE_CMD}" 24 | exec $NODE_CMD 25 | elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 26 | 27 | package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json) 28 | package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json) 29 | 30 | if [ -n "$package_json_start" ]; then 31 | start_command=$package_json_start 32 | elif [ -n $package_json_main ]; then 33 | start_command="node ." 34 | elif [ -f "server.js" ]; then 35 | start_command="node server.js" 36 | else 37 | echo "Failed to find file for starting the Node.js application" 38 | exit 1 39 | fi 40 | echo "launching via init wrapper..." 41 | exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command 42 | else 43 | echo "Launching via npm..." 44 | exec npm run -d $NPM_RUN 45 | fi 46 | } 47 | 48 | #Set the debug port to 5858 by default. 49 | if [ -z "$DEBUG_PORT" ]; then 50 | export DEBUG_PORT=5858 51 | fi 52 | 53 | # Set the environment to development by default. 54 | if [ -z "$DEV_MODE" ]; then 55 | export DEV_MODE=false 56 | fi 57 | 58 | # If NODE_ENV is not set by the user, then NODE_ENV is determined by whether 59 | # the container is run in development mode. 60 | if [ -z "$NODE_ENV" ]; then 61 | if [ "$DEV_MODE" == true ]; then 62 | export NODE_ENV=development 63 | else 64 | export NODE_ENV=production 65 | fi 66 | fi 67 | 68 | # If the official dockerhub node image is used, skip the SCL setup below 69 | # and just run the nodejs server 70 | if [ -d "/usr/src/app" ]; then 71 | run_node 72 | fi 73 | 74 | # Allow users to inspect/debug the builder image itself, by using: 75 | # $ docker run -i -t openshift/centos-nodejs-builder --debug 76 | # 77 | [ "$1" == "--debug" ] && exec /bin/bash 78 | 79 | run_node 80 | -------------------------------------------------------------------------------- /18-minimal/s2i/bin/save-artifacts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then 4 | tar -C "${HOME}" -cf - node_modules 5 | fi 6 | -------------------------------------------------------------------------------- /18-minimal/s2i/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` 4 | 5 | cat < $NSS_WRAPPER_PASSWD 11 | 12 | echo "default:x:${USER_ID}:${GROUP_ID}:Default Application User:${HOME}:/sbin/nologin" >> $NSS_WRAPPER_PASSWD 13 | 14 | export NSS_WRAPPER_PASSWD 15 | export NSS_WRAPPER_GROUP 16 | export LD_PRELOAD=libnss_wrapper.so 17 | fi 18 | -------------------------------------------------------------------------------- /18/root/opt/app-root/etc/npm_global_module_list: -------------------------------------------------------------------------------- 1 | async 2 | mime 3 | mkdirp 4 | qs 5 | minimatch 6 | -------------------------------------------------------------------------------- /18/root/opt/app-root/etc/scl_enable: -------------------------------------------------------------------------------- 1 | # This will make scl collection binaries work out of box. 2 | unset BASH_ENV PROMPT_COMMAND ENV 3 | source scl_source enable rh-nodejs${NODEJS_VERSION} 4 | -------------------------------------------------------------------------------- /18/s2i/bin/init-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html 4 | # Set a trap to kill the main app process when this 5 | # init script receives SIGTERM or SIGINT 6 | trap 'kill -s TERM $PID' TERM INT 7 | # Execute the main application in the background 8 | "$@" & 9 | PID=$! 10 | # wait command always terminates when trap is caught, even if the process hasn't finished yet 11 | wait $PID 12 | # Remove the trap and wait till the app process finishes completely 13 | trap - TERM INT 14 | # We wait again, since the first wait terminates when trap is caught 15 | wait $PID 16 | # Exit with the exit code of the app process 17 | STATUS=$? 18 | exit $STATUS -------------------------------------------------------------------------------- /18/s2i/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # S2I run script for the 'nodejs' image. 4 | # The run script executes the server that runs your application. 5 | # 6 | # For more information see the documentation: 7 | # https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md 8 | # 9 | 10 | set -e 11 | 12 | if [ -e "/opt/app-root/etc/generate_container_user" ]; then 13 | source /opt/app-root/etc/generate_container_user 14 | fi 15 | 16 | # Runs the nodejs application server. If the container is run in development mode, 17 | # hot deploy and debugging are enabled. 18 | run_node() { 19 | echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" 20 | if [ "$DEV_MODE" == true ]; then 21 | echo "Launching via nodemon..." 22 | exec nodemon --inspect="$DEBUG_PORT" 23 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 24 | echo "launching via init wrapper..." 25 | exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD 26 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then 27 | echo "Launching via ${NODE_CMD}" 28 | exec $NODE_CMD 29 | elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 30 | 31 | package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json) 32 | package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json) 33 | 34 | if [ -n "$package_json_start" ]; then 35 | start_command=$package_json_start 36 | elif [ -n $package_json_main ]; then 37 | start_command="node ." 38 | elif [ -f "server.js" ]; then 39 | start_command="node server.js" 40 | else 41 | echo "Failed to find file for starting the Node.js application" 42 | exit 1 43 | fi 44 | echo "launching via init wrapper..." 45 | exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command 46 | else 47 | echo "Launching via npm..." 48 | exec npm run -d $NPM_RUN 49 | fi 50 | } 51 | 52 | #Set the debug port to 5858 by default. 53 | if [ -z "$DEBUG_PORT" ]; then 54 | export DEBUG_PORT=5858 55 | fi 56 | 57 | # Set the environment to development by default. 58 | if [ -z "$DEV_MODE" ]; then 59 | export DEV_MODE=false 60 | fi 61 | 62 | # If NODE_ENV is not set by the user, then NODE_ENV is determined by whether 63 | # the container is run in development mode. 64 | if [ -z "$NODE_ENV" ]; then 65 | if [ "$DEV_MODE" == true ]; then 66 | export NODE_ENV=development 67 | else 68 | export NODE_ENV=production 69 | fi 70 | fi 71 | 72 | # If the official dockerhub node image is used, skip the SCL setup below 73 | # and just run the nodejs server 74 | if [ -d "/usr/src/app" ]; then 75 | run_node 76 | fi 77 | 78 | # Allow users to inspect/debug the builder image itself, by using: 79 | # $ docker run -i -t openshift/centos-nodejs-builder --debug 80 | # 81 | [ "$1" == "--debug" ] && exec /bin/bash 82 | 83 | run_node 84 | -------------------------------------------------------------------------------- /18/s2i/bin/save-artifacts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then 4 | tar -C "${HOME}" -cf - node_modules 5 | fi 6 | -------------------------------------------------------------------------------- /18/s2i/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` 4 | 5 | cat <&2 17 | # We still want to end successfully 18 | exit 0 19 | fi 20 | 21 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -gid 0 -exec chgrp 0 {} + 22 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -perm -g+rw -exec chmod g+rw {} + 23 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} -perm /u+x -a \! -perm /g+x -exec chmod g+x {} + 24 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} -type d \! -perm /g+x -exec chmod g+x {} + 25 | 26 | # Always end successfully 27 | exit 0 28 | -------------------------------------------------------------------------------- /20-minimal/s2i/bin/init-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html 4 | # Set a trap to kill the main app process when this 5 | # init script receives SIGTERM or SIGINT 6 | trap 'kill -s TERM $PID' TERM INT 7 | # Execute the main application in the background 8 | "$@" & 9 | PID=$! 10 | # wait command always terminates when trap is caught, even if the process hasn't finished yet 11 | wait $PID 12 | # Remove the trap and wait till the app process finishes completely 13 | trap - TERM INT 14 | # We wait again, since the first wait terminates when trap is caught 15 | wait $PID 16 | # Exit with the exit code of the app process 17 | STATUS=$? 18 | exit $STATUS -------------------------------------------------------------------------------- /20-minimal/s2i/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # S2I run script for the 'nodejs' image. 4 | # The run script executes the server that runs your application. 5 | # 6 | # For more information see the documentation: 7 | # https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md 8 | # 9 | 10 | set -e 11 | 12 | # Runs the nodejs application server. If the container is run in development mode, 13 | # hot deploy and debugging are enabled. 14 | run_node() { 15 | echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" 16 | if [ "$DEV_MODE" == true ]; then 17 | echo "Launching via nodemon..." 18 | exec nodemon --inspect="$DEBUG_PORT" 19 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 20 | echo "launching via init wrapper..." 21 | exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD 22 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then 23 | echo "Launching via ${NODE_CMD}" 24 | exec $NODE_CMD 25 | elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 26 | 27 | package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json) 28 | package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json) 29 | 30 | if [ -n "$package_json_start" ]; then 31 | start_command=$package_json_start 32 | elif [ -n $package_json_main ]; then 33 | start_command="node ." 34 | elif [ -f "server.js" ]; then 35 | start_command="node server.js" 36 | else 37 | echo "Failed to find file for starting the Node.js application" 38 | exit 1 39 | fi 40 | echo "launching via init wrapper..." 41 | exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command 42 | else 43 | echo "Launching via npm..." 44 | exec npm run -d $NPM_RUN 45 | fi 46 | } 47 | 48 | #Set the debug port to 5858 by default. 49 | if [ -z "$DEBUG_PORT" ]; then 50 | export DEBUG_PORT=5858 51 | fi 52 | 53 | # Set the environment to development by default. 54 | if [ -z "$DEV_MODE" ]; then 55 | export DEV_MODE=false 56 | fi 57 | 58 | # If NODE_ENV is not set by the user, then NODE_ENV is determined by whether 59 | # the container is run in development mode. 60 | if [ -z "$NODE_ENV" ]; then 61 | if [ "$DEV_MODE" == true ]; then 62 | export NODE_ENV=development 63 | else 64 | export NODE_ENV=production 65 | fi 66 | fi 67 | 68 | # If the official dockerhub node image is used, skip the SCL setup below 69 | # and just run the nodejs server 70 | if [ -d "/usr/src/app" ]; then 71 | run_node 72 | fi 73 | 74 | # Allow users to inspect/debug the builder image itself, by using: 75 | # $ docker run -i -t openshift/centos-nodejs-builder --debug 76 | # 77 | [ "$1" == "--debug" ] && exec /bin/bash 78 | 79 | run_node 80 | -------------------------------------------------------------------------------- /20-minimal/s2i/bin/save-artifacts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then 4 | tar -C "${HOME}" -cf - node_modules 5 | fi 6 | -------------------------------------------------------------------------------- /20-minimal/s2i/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` 4 | 5 | cat < nodejs-sample-app 12 | 13 | You can then run the resulting image via: 14 | podman run -p 8080:8080 nodejs-sample-app 15 | EOF 16 | -------------------------------------------------------------------------------- /20-minimal/test/check_imagestreams.py: -------------------------------------------------------------------------------- 1 | ../../common/check_imagestreams.py -------------------------------------------------------------------------------- /20-minimal/test/examples: -------------------------------------------------------------------------------- 1 | ../../examples -------------------------------------------------------------------------------- /20-minimal/test/imagestreams: -------------------------------------------------------------------------------- 1 | ../../imagestreams -------------------------------------------------------------------------------- /20-minimal/test/run: -------------------------------------------------------------------------------- 1 | ../../test/run-minimal -------------------------------------------------------------------------------- /20-minimal/test/run-openshift-remote-cluster: -------------------------------------------------------------------------------- 1 | ../../test/run-openshift-remote-cluster -------------------------------------------------------------------------------- /20-minimal/test/test-app: -------------------------------------------------------------------------------- 1 | ../../test/test-app -------------------------------------------------------------------------------- /20-minimal/test/test-binary: -------------------------------------------------------------------------------- 1 | ../../test/test-binary -------------------------------------------------------------------------------- /20-minimal/test/test-express-webapp: -------------------------------------------------------------------------------- 1 | ../../test/test-express-webapp -------------------------------------------------------------------------------- /20-minimal/test/test-hw: -------------------------------------------------------------------------------- 1 | ../../test/test-hw -------------------------------------------------------------------------------- /20-minimal/test/test-incremental: -------------------------------------------------------------------------------- 1 | ../../test/test-incremental -------------------------------------------------------------------------------- /20-minimal/test/test-lib-nodejs.sh: -------------------------------------------------------------------------------- 1 | ../../test/test-lib-nodejs.sh -------------------------------------------------------------------------------- /20-minimal/test/test-lib-openshift.sh: -------------------------------------------------------------------------------- 1 | ../../common/test-lib-openshift.sh -------------------------------------------------------------------------------- /20-minimal/test/test-lib-remote-openshift.sh: -------------------------------------------------------------------------------- 1 | ../../common/test-lib-remote-openshift.sh -------------------------------------------------------------------------------- /20-minimal/test/test-lib.sh: -------------------------------------------------------------------------------- 1 | ../../common/test-lib.sh -------------------------------------------------------------------------------- /20-minimal/test/test-openshift.yaml: -------------------------------------------------------------------------------- 1 | ../../common/test-openshift.yaml -------------------------------------------------------------------------------- /20/.exclude-c8s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sclorg/s2i-nodejs-container/ff61c620ca06214a60080b899c257e170d0dbdb1/20/.exclude-c8s -------------------------------------------------------------------------------- /20/Dockerfile.fedora: -------------------------------------------------------------------------------- 1 | FROM quay.io/fedora/s2i-core:38 2 | 3 | # This image provides a Node.JS environment you can use to run your Node.JS 4 | # applications. 5 | 6 | EXPOSE 8080 7 | 8 | # Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts 9 | # available on the CLI without using npm's --global installation mode 10 | # This image will be initialized with "npm run $NPM_RUN" 11 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 12 | # file for possible values of NPM_RUN 13 | # Description 14 | # Environment: 15 | # * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). 16 | # Expose ports: 17 | # * 8080 - Unprivileged port used by nodejs application 18 | 19 | ENV NODEJS_VERSION=20 \ 20 | NPM_RUN=start \ 21 | NAME=nodejs \ 22 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 23 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH 24 | 25 | ENV SUMMARY="Platform for building and running Node.js $NODEJS_VERSION applications" \ 26 | DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ 27 | building and running various Node.js $NODEJS_VERSION applications and frameworks. \ 28 | Node.js is a platform built on Chrome's JavaScript runtime for easily building \ 29 | fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ 30 | that makes it lightweight and efficient, perfect for data-intensive real-time applications \ 31 | that run across distributed devices." 32 | 33 | LABEL summary="$SUMMARY" \ 34 | description="$DESCRIPTION" \ 35 | io.k8s.description="$DESCRIPTION" \ 36 | io.k8s.display-name="Node.js $NODEJS_VERSION" \ 37 | io.openshift.expose-services="8080:http" \ 38 | io.openshift.tags="builder,$NAME,$NAME$NODEJS_VERSION" \ 39 | io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ 40 | io.s2i.scripts-url="image:///usr/libexec/s2i" \ 41 | com.redhat.dev-mode="DEV_MODE:false" \ 42 | com.redhat.deployments-dir="${APP_ROOT}/src" \ 43 | com.redhat.dev-mode.port="DEBUG_PORT:5858"\ 44 | com.redhat.component="$NAME" \ 45 | name="fedora/$NAME-$NODEJS_VERSION" \ 46 | version="$NODEJS_VERSION" \ 47 | maintainer="SoftwareCollections.org " \ 48 | help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \ 49 | usage="oc new-app $FGC/$NAME~" 50 | 51 | RUN MODULE_DEPS="make gcc gcc-c++ libatomic_ops git openssl-devel" && \ 52 | INSTALL_PKGS="$MODULE_DEPS nodejs$NODEJS_VERSION nodejs-nodemon nodejs$NODEJS_VERSION-npm nss_wrapper-libs which" && \ 53 | yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ 54 | rpm -V $INSTALL_PKGS && \ 55 | ln -s /usr/bin/node-$NODEJS_VERSION /usr/bin/node && \ 56 | ln -s /usr/bin/npm-$NODEJS_VERSION /usr/bin/npm && \ 57 | ln -s /usr/bin/npx-$NODEJS_VERSION /usr/bin/npx && \ 58 | ln -s /usr/lib/node_modules_18/nodemon /usr/lib/node_modules_$NODEJS_VERSION/nodemon && \ 59 | node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ 60 | yum -y clean all --enablerepo='*' 61 | 62 | # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH 63 | COPY ./s2i/bin/ $STI_SCRIPTS_PATH 64 | RUN chmod +x $STI_SCRIPTS_PATH/init-wrapper 65 | 66 | # Copy extra files to the image, including help file. 67 | COPY ./root/ / 68 | 69 | # Drop the root user and make the content of /opt/app-root owned by user 1001 70 | RUN chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \ 71 | rpm-file-permissions 72 | 73 | USER 1001 74 | 75 | # Set the default CMD to print the usage of the language image 76 | CMD $STI_SCRIPTS_PATH/usage 77 | -------------------------------------------------------------------------------- /20/root/opt/app-root/etc/generate_container_user: -------------------------------------------------------------------------------- 1 | # Set current user in nss_wrapper 2 | USER_ID=$(id -u) 3 | GROUP_ID=$(id -g) 4 | 5 | if [ x"$USER_ID" != x"0" -a x"$USER_ID" != x"1001" ]; then 6 | 7 | NSS_WRAPPER_PASSWD=/opt/app-root/etc/passwd 8 | NSS_WRAPPER_GROUP=/etc/group 9 | 10 | cat /etc/passwd | sed -e 's/^default:/builder:/' > $NSS_WRAPPER_PASSWD 11 | 12 | echo "default:x:${USER_ID}:${GROUP_ID}:Default Application User:${HOME}:/sbin/nologin" >> $NSS_WRAPPER_PASSWD 13 | 14 | export NSS_WRAPPER_PASSWD 15 | export NSS_WRAPPER_GROUP 16 | export LD_PRELOAD=libnss_wrapper.so 17 | fi 18 | -------------------------------------------------------------------------------- /20/root/opt/app-root/etc/npm_global_module_list: -------------------------------------------------------------------------------- 1 | async 2 | mime 3 | mkdirp 4 | qs 5 | minimatch 6 | -------------------------------------------------------------------------------- /20/root/opt/app-root/etc/scl_enable: -------------------------------------------------------------------------------- 1 | # This will make scl collection binaries work out of box. 2 | unset BASH_ENV PROMPT_COMMAND ENV 3 | source scl_source enable rh-nodejs${NODEJS_VERSION} 4 | -------------------------------------------------------------------------------- /20/s2i/bin/init-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html 4 | # Set a trap to kill the main app process when this 5 | # init script receives SIGTERM or SIGINT 6 | trap 'kill -s TERM $PID' TERM INT 7 | # Execute the main application in the background 8 | "$@" & 9 | PID=$! 10 | # wait command always terminates when trap is caught, even if the process hasn't finished yet 11 | wait $PID 12 | # Remove the trap and wait till the app process finishes completely 13 | trap - TERM INT 14 | # We wait again, since the first wait terminates when trap is caught 15 | wait $PID 16 | # Exit with the exit code of the app process 17 | STATUS=$? 18 | exit $STATUS -------------------------------------------------------------------------------- /20/s2i/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # S2I run script for the 'nodejs' image. 4 | # The run script executes the server that runs your application. 5 | # 6 | # For more information see the documentation: 7 | # https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md 8 | # 9 | 10 | set -e 11 | 12 | if [ -e "/opt/app-root/etc/generate_container_user" ]; then 13 | source /opt/app-root/etc/generate_container_user 14 | fi 15 | 16 | # Runs the nodejs application server. If the container is run in development mode, 17 | # hot deploy and debugging are enabled. 18 | run_node() { 19 | echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" 20 | if [ "$DEV_MODE" == true ]; then 21 | echo "Launching via nodemon..." 22 | exec nodemon --inspect="$DEBUG_PORT" 23 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 24 | echo "launching via init wrapper..." 25 | exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD 26 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then 27 | echo "Launching via ${NODE_CMD}" 28 | exec $NODE_CMD 29 | elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 30 | 31 | package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json) 32 | package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json) 33 | 34 | if [ -n "$package_json_start" ]; then 35 | start_command=$package_json_start 36 | elif [ -n $package_json_main ]; then 37 | start_command="node ." 38 | elif [ -f "server.js" ]; then 39 | start_command="node server.js" 40 | else 41 | echo "Failed to find file for starting the Node.js application" 42 | exit 1 43 | fi 44 | echo "launching via init wrapper..." 45 | exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command 46 | else 47 | echo "Launching via npm..." 48 | exec npm run -d $NPM_RUN 49 | fi 50 | } 51 | 52 | #Set the debug port to 5858 by default. 53 | if [ -z "$DEBUG_PORT" ]; then 54 | export DEBUG_PORT=5858 55 | fi 56 | 57 | # Set the environment to development by default. 58 | if [ -z "$DEV_MODE" ]; then 59 | export DEV_MODE=false 60 | fi 61 | 62 | # If NODE_ENV is not set by the user, then NODE_ENV is determined by whether 63 | # the container is run in development mode. 64 | if [ -z "$NODE_ENV" ]; then 65 | if [ "$DEV_MODE" == true ]; then 66 | export NODE_ENV=development 67 | else 68 | export NODE_ENV=production 69 | fi 70 | fi 71 | 72 | # If the official dockerhub node image is used, skip the SCL setup below 73 | # and just run the nodejs server 74 | if [ -d "/usr/src/app" ]; then 75 | run_node 76 | fi 77 | 78 | # Allow users to inspect/debug the builder image itself, by using: 79 | # $ docker run -i -t openshift/centos-nodejs-builder --debug 80 | # 81 | [ "$1" == "--debug" ] && exec /bin/bash 82 | 83 | run_node 84 | -------------------------------------------------------------------------------- /20/s2i/bin/save-artifacts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then 4 | tar -C "${HOME}" -cf - node_modules 5 | fi 6 | -------------------------------------------------------------------------------- /20/s2i/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` 4 | 5 | cat < nodejs-sample-app 12 | 13 | You can then run the resulting image via: 14 | podman run -p 8080:8080 nodejs-sample-app 15 | EOF 16 | -------------------------------------------------------------------------------- /20/test: -------------------------------------------------------------------------------- 1 | ../test -------------------------------------------------------------------------------- /22-minimal/.exclude-c8s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sclorg/s2i-nodejs-container/ff61c620ca06214a60080b899c257e170d0dbdb1/22-minimal/.exclude-c8s -------------------------------------------------------------------------------- /22-minimal/.exclude-c9s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sclorg/s2i-nodejs-container/ff61c620ca06214a60080b899c257e170d0dbdb1/22-minimal/.exclude-c9s -------------------------------------------------------------------------------- /22-minimal/Dockerfile.c10s: -------------------------------------------------------------------------------- 1 | FROM quay.io/sclorg/s2i-core-c10s 2 | 3 | EXPOSE 8080 4 | 5 | # Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts 6 | # available on the CLI without using npm's --global installation mode 7 | # This image will be initialized with "npm run $NPM_RUN" 8 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 9 | # file for possible values of NPM_RUN 10 | # Description 11 | # Environment: 12 | # * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). 13 | # Expose ports: 14 | # * 8080 - Unprivileged port used by nodejs application 15 | ENV APP_ROOT=/opt/app-root \ 16 | # The $HOME is not set by default, but some applications need this variable 17 | HOME=/opt/app-root/src \ 18 | NPM_RUN=start \ 19 | PLATFORM="el10" \ 20 | NODEJS_VERSION=22 \ 21 | NPM_RUN=start \ 22 | NAME=nodejs 23 | 24 | ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ 25 | DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ 26 | running various Node.js $NODEJS_VERSION applications and frameworks. \ 27 | Node.js is a platform built on Chrome's JavaScript runtime for easily building \ 28 | fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ 29 | that makes it lightweight and efficient, perfect for data-intensive real-time applications \ 30 | that run across distributed devices." \ 31 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 32 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH 33 | 34 | LABEL summary="$SUMMARY" \ 35 | description="$DESCRIPTION" \ 36 | io.k8s.description="$DESCRIPTION" \ 37 | io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \ 38 | io.openshift.expose-services="8080:http" \ 39 | io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ 40 | io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ 41 | io.s2i.scripts-url="image:///usr/libexec/s2i" \ 42 | com.redhat.dev-mode="DEV_MODE:false" \ 43 | com.redhat.deployments-dir="${APP_ROOT}/src" \ 44 | com.redhat.dev-mode.port="DEBUG_PORT:5858" \ 45 | com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ 46 | name="sclorg/$NAME-$NODEJS_VERSION-minimal-c10s" \ 47 | version="1" \ 48 | maintainer="SoftwareCollections.org " \ 49 | help="For more information visit https://github.com/sclorg/s2i-nodejs-container" 50 | 51 | # nodejs-full-i18n is included for error strings 52 | RUN INSTALL_PKGS="nodejs$NODEJS_VERSION nodejs-nodemon nodejs$NODEJS_VERSION-full-i18n npm findutils tar which" && \ 53 | dnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ 54 | node-22 -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ 55 | dnf clean all && \ 56 | rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* 57 | 58 | COPY ./s2i/bin/ /usr/libexec/s2i 59 | RUN chmod +x /usr/libexec/s2i/init-wrapper 60 | 61 | # Copy extra files to the image. 62 | COPY ./root/ / 63 | 64 | # Drop the root user and make the content of /opt/app-root owned by user 1001 65 | RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" 66 | WORKDIR "$HOME" 67 | USER 1001 68 | -------------------------------------------------------------------------------- /22-minimal/Dockerfile.c8s: -------------------------------------------------------------------------------- 1 | FROM quay.io/sclorg/s2i-core-c8s 2 | 3 | EXPOSE 8080 4 | 5 | # Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts 6 | # available on the CLI without using npm's --global installation mode 7 | # This image will be initialized with "npm run $NPM_RUN" 8 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 9 | # file for possible values of NPM_RUN 10 | # Description 11 | # Environment: 12 | # * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). 13 | # Expose ports: 14 | # * 8080 - Unprivileged port used by nodejs application 15 | ENV APP_ROOT=/opt/app-root \ 16 | # The $HOME is not set by default, but some applications need this variable 17 | HOME=/opt/app-root/src \ 18 | NPM_RUN=start \ 19 | PLATFORM="el8" \ 20 | NODEJS_VERSION=20 \ 21 | NPM_RUN=start \ 22 | NAME=nodejs 23 | 24 | ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ 25 | DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ 26 | running various Node.js $NODEJS_VERSION applications and frameworks. \ 27 | Node.js is a platform built on Chrome's JavaScript runtime for easily building \ 28 | fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ 29 | that makes it lightweight and efficient, perfect for data-intensive real-time applications \ 30 | that run across distributed devices." \ 31 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 32 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH 33 | 34 | LABEL summary="$SUMMARY" \ 35 | description="$DESCRIPTION" \ 36 | io.k8s.description="$DESCRIPTION" \ 37 | io.k8s.display-name="Node.js $NODEJS_VERSION Minimal" \ 38 | io.openshift.expose-services="8080:http" \ 39 | io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ 40 | io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ 41 | io.s2i.scripts-url="image:///usr/libexec/s2i" \ 42 | com.redhat.dev-mode="DEV_MODE:false" \ 43 | com.redhat.deployments-dir="${APP_ROOT}/src" \ 44 | com.redhat.dev-mode.port="DEBUG_PORT:5858" \ 45 | com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ 46 | name="sclorg/$NAME-$NODEJS_VERSION-minimal-c8s" \ 47 | version="1" \ 48 | maintainer="SoftwareCollections.org " \ 49 | help="For more information visit https://github.com/sclorg/s2i-nodejs-container" 50 | 51 | # nodejs-full-i18n is included for error strings 52 | RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar which" && \ 53 | yum -y module disable nodejs && \ 54 | yum -y module enable nodejs:$NODEJS_VERSION && \ 55 | yum -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ 56 | node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ 57 | yum clean all && \ 58 | rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* 59 | 60 | COPY ./s2i/bin/ /usr/libexec/s2i 61 | RUN chmod +x /usr/libexec/s2i/init-wrapper 62 | 63 | # Copy extra files to the image. 64 | COPY ./root/ / 65 | 66 | # Drop the root user and make the content of /opt/app-root owned by user 1001 67 | RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" 68 | WORKDIR "$HOME" 69 | USER 1001 70 | -------------------------------------------------------------------------------- /22-minimal/Dockerfile.c9s: -------------------------------------------------------------------------------- 1 | FROM quay.io/sclorg/s2i-core-c9s 2 | 3 | EXPOSE 8080 4 | 5 | # Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts 6 | # available on the CLI without using npm's --global installation mode 7 | # This image will be initialized with "npm run $NPM_RUN" 8 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 9 | # file for possible values of NPM_RUN 10 | # Description 11 | # Environment: 12 | # * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). 13 | # Expose ports: 14 | # * 8080 - Unprivileged port used by nodejs application 15 | ENV APP_ROOT=/opt/app-root \ 16 | # The $HOME is not set by default, but some applications need this variable 17 | HOME=/opt/app-root/src \ 18 | NPM_RUN=start \ 19 | PLATFORM="el9" \ 20 | NODEJS_VERSION=22 \ 21 | NPM_RUN=start \ 22 | NAME=nodejs 23 | 24 | ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ 25 | DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ 26 | running various Node.js $NODEJS_VERSION applications and frameworks. \ 27 | Node.js is a platform built on Chrome's JavaScript runtime for easily building \ 28 | fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ 29 | that makes it lightweight and efficient, perfect for data-intensive real-time applications \ 30 | that run across distributed devices." \ 31 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 32 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH 33 | 34 | LABEL summary="$SUMMARY" \ 35 | description="$DESCRIPTION" \ 36 | io.k8s.description="$DESCRIPTION" \ 37 | io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \ 38 | io.openshift.expose-services="8080:http" \ 39 | io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ 40 | io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ 41 | io.s2i.scripts-url="image:///usr/libexec/s2i" \ 42 | com.redhat.dev-mode="DEV_MODE:false" \ 43 | com.redhat.deployments-dir="${APP_ROOT}/src" \ 44 | com.redhat.dev-mode.port="DEBUG_PORT:5858" \ 45 | com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ 46 | name="sclorg/$NAME-$NODEJS_VERSION-minimal-c9s" \ 47 | version="1" \ 48 | maintainer="SoftwareCollections.org " \ 49 | help="For more information visit https://github.com/sclorg/s2i-nodejs-container" 50 | 51 | # nodejs-full-i18n is included for error strings 52 | RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar which" && \ 53 | yum -y module disable nodejs && \ 54 | yum -y module enable nodejs:$NODEJS_VERSION && \ 55 | yum -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ 56 | node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ 57 | yum clean all && \ 58 | rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* 59 | 60 | COPY ./s2i/bin/ /usr/libexec/s2i 61 | RUN chmod +x /usr/libexec/s2i/init-wrapper 62 | 63 | # Copy extra files to the image. 64 | COPY ./root/ / 65 | 66 | # Drop the root user and make the content of /opt/app-root owned by user 1001 67 | RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" 68 | WORKDIR "$HOME" 69 | USER 1001 70 | -------------------------------------------------------------------------------- /22-minimal/Dockerfile.fedora: -------------------------------------------------------------------------------- 1 | FROM quay.io/fedora/fedora-minimal:40 2 | 3 | EXPOSE 8080 4 | 5 | # Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts 6 | # available on the CLI without using npm's --global installation mode 7 | # This image will be initialized with "npm run $NPM_RUN" 8 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 9 | # file for possible values of NPM_RUN 10 | # Description 11 | # Environment: 12 | # * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). 13 | # Expose ports: 14 | # * 8080 - Unprivileged port used by nodejs application 15 | ENV APP_ROOT=/opt/app-root \ 16 | # The $HOME is not set by default, but some applications need this variable 17 | HOME=/opt/app-root/src \ 18 | NPM_RUN=start \ 19 | PLATFORM="fedora" \ 20 | NODEJS_VERSION=22 \ 21 | NPM_RUN=start \ 22 | NAME=nodejs 23 | 24 | ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ 25 | DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ 26 | running various Node.js $NODEJS_VERSION applications and frameworks. \ 27 | Node.js is a platform built on Chrome's JavaScript runtime for easily building \ 28 | fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ 29 | that makes it lightweight and efficient, perfect for data-intensive real-time applications \ 30 | that run across distributed devices." \ 31 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 32 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH 33 | 34 | LABEL summary="$SUMMARY" \ 35 | description="$DESCRIPTION" \ 36 | io.k8s.description="$DESCRIPTION" \ 37 | io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \ 38 | io.openshift.expose-services="8080:http" \ 39 | io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ 40 | io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ 41 | io.s2i.scripts-url="image:///usr/libexec/s2i" \ 42 | com.redhat.dev-mode="DEV_MODE:false" \ 43 | com.redhat.deployments-dir="${APP_ROOT}/src" \ 44 | com.redhat.dev-mode.port="DEBUG_PORT:5858" \ 45 | com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ 46 | name="fedora/$NAME-$NODEJS_VERSION-minimal" \ 47 | version="1" \ 48 | maintainer="SoftwareCollections.org " \ 49 | help="For more information visit https://github.com/sclorg/s2i-nodejs-container" 50 | 51 | # nodejs-full-i18n is included for error strings 52 | RUN INSTALL_PKGS="nodejs$NODEJS_VERSION nodejs-nodemon nodejs$NODEJS_VERSION-full-i18n nodejs$NODEJS_VERSION-npm findutils tar which nss_wrapper-libs" && \ 53 | microdnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ 54 | microdnf clean all && \ 55 | ln -s /usr/bin/node-$NODEJS_VERSION /usr/bin/node && \ 56 | ln -s /usr/bin/npm-$NODEJS_VERSION /usr/bin/npm && \ 57 | ln -s /usr/bin/npx-$NODEJS_VERSION /usr/bin/npx && \ 58 | node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ 59 | rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* 60 | 61 | # 62 | COPY ./s2i/bin/ /usr/libexec/s2i 63 | RUN chmod +x /usr/libexec/s2i/init-wrapper 64 | 65 | # Copy extra files to the image. 66 | COPY ./root/ / 67 | 68 | # Drop the root user and make the content of /opt/app-root owned by user 1001 69 | RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" 70 | WORKDIR "$HOME" 71 | USER 1001 72 | -------------------------------------------------------------------------------- /22-minimal/Dockerfile.rhel10: -------------------------------------------------------------------------------- 1 | FROM ubi10-minimal:latest 2 | 3 | EXPOSE 8080 4 | 5 | # Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts 6 | # available on the CLI without using npm's --global installation mode 7 | # This image will be initialized with "npm run $NPM_RUN" 8 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 9 | # file for possible values of NPM_RUN 10 | # Description 11 | # Environment: 12 | # * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). 13 | # Expose ports: 14 | # * 8080 - Unprivileged port used by nodejs application 15 | ENV APP_ROOT=/opt/app-root \ 16 | # The $HOME is not set by default, but some applications need this variable 17 | HOME=/opt/app-root/src \ 18 | NPM_RUN=start \ 19 | PLATFORM="el10" \ 20 | NODEJS_VERSION=22 \ 21 | NPM_RUN=start \ 22 | NAME=nodejs 23 | 24 | ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ 25 | DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ 26 | running various Node.js $NODEJS_VERSION applications and frameworks. \ 27 | Node.js is a platform built on Chrome's JavaScript runtime for easily building \ 28 | fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ 29 | that makes it lightweight and efficient, perfect for data-intensive real-time applications \ 30 | that run across distributed devices." \ 31 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 32 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH 33 | 34 | LABEL summary="$SUMMARY" \ 35 | description="$DESCRIPTION" \ 36 | io.k8s.description="$DESCRIPTION" \ 37 | io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \ 38 | io.openshift.expose-services="8080:http" \ 39 | io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ 40 | io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ 41 | io.s2i.scripts-url="image:///usr/libexec/s2i" \ 42 | com.redhat.dev-mode="DEV_MODE:false" \ 43 | com.redhat.deployments-dir="${APP_ROOT}/src" \ 44 | com.redhat.dev-mode.port="DEBUG_PORT:5858" \ 45 | com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ 46 | name="ubi9/$NAME-$NODEJS_VERSION-minimal" \ 47 | version="1" \ 48 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ 49 | maintainer="SoftwareCollections.org " \ 50 | help="For more information visit https://github.com/sclorg/s2i-nodejs-container" 51 | 52 | # nodejs-full-i18n is included for error strings 53 | RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar which" && \ 54 | microdnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ 55 | node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ 56 | microdnf clean all && \ 57 | rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* 58 | 59 | COPY ./s2i/bin/ /usr/libexec/s2i 60 | RUN chmod +x /usr/libexec/s2i/init-wrapper 61 | 62 | # Copy extra files to the image. 63 | COPY ./root/ / 64 | 65 | # Drop the root user and make the content of /opt/app-root owned by user 1001 66 | RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" 67 | WORKDIR "$HOME" 68 | USER 1001 69 | -------------------------------------------------------------------------------- /22-minimal/Dockerfile.rhel8: -------------------------------------------------------------------------------- 1 | FROM ubi8/ubi-minimal:latest 2 | 3 | EXPOSE 8080 4 | 5 | # Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts 6 | # available on the CLI without using npm's --global installation mode 7 | # This image will be initialized with "npm run $NPM_RUN" 8 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 9 | # file for possible values of NPM_RUN 10 | # Description 11 | # Environment: 12 | # * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). 13 | # Expose ports: 14 | # * 8080 - Unprivileged port used by nodejs application 15 | ENV APP_ROOT=/opt/app-root \ 16 | # The $HOME is not set by default, but some applications need this variable 17 | HOME=/opt/app-root/src \ 18 | NPM_RUN=start \ 19 | PLATFORM="el8" \ 20 | NODEJS_VERSION=22 \ 21 | NPM_RUN=start \ 22 | NAME=nodejs 23 | 24 | ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ 25 | DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ 26 | running various Node.js $NODEJS_VERSION applications and frameworks. \ 27 | Node.js is a platform built on Chrome's JavaScript runtime for easily building \ 28 | fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ 29 | that makes it lightweight and efficient, perfect for data-intensive real-time applications \ 30 | that run across distributed devices." \ 31 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 32 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH 33 | 34 | LABEL summary="$SUMMARY" \ 35 | description="$DESCRIPTION" \ 36 | io.k8s.description="$DESCRIPTION" \ 37 | io.k8s.display-name="Node.js $NODEJS_VERSION Minimal" \ 38 | io.openshift.expose-services="8080:http" \ 39 | io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ 40 | io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ 41 | io.s2i.scripts-url="image:///usr/libexec/s2i" \ 42 | com.redhat.dev-mode="DEV_MODE:false" \ 43 | com.redhat.deployments-dir="${APP_ROOT}/src" \ 44 | com.redhat.dev-mode.port="DEBUG_PORT:5858" \ 45 | com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ 46 | name="ubi8/$NAME-$NODEJS_VERSION-minimal" \ 47 | version="1" \ 48 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ 49 | maintainer="SoftwareCollections.org " \ 50 | help="For more information visit https://github.com/sclorg/s2i-nodejs-container" 51 | 52 | # nodejs-full-i18n is included for error strings 53 | RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar which" && \ 54 | microdnf -y module disable nodejs && \ 55 | microdnf -y module enable nodejs:$NODEJS_VERSION && \ 56 | microdnf --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ 57 | node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ 58 | microdnf clean all && \ 59 | rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* 60 | 61 | COPY ./s2i/bin/ /usr/libexec/s2i 62 | RUN chmod +x /usr/libexec/s2i/init-wrapper 63 | 64 | # Copy extra files to the image. 65 | COPY ./root/ / 66 | 67 | # Drop the root user and make the content of /opt/app-root owned by user 1001 68 | RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" 69 | WORKDIR "$HOME" 70 | USER 1001 71 | -------------------------------------------------------------------------------- /22-minimal/Dockerfile.rhel9: -------------------------------------------------------------------------------- 1 | FROM ubi9/ubi-minimal 2 | 3 | EXPOSE 8080 4 | 5 | # Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts 6 | # available on the CLI without using npm's --global installation mode 7 | # This image will be initialized with "npm run $NPM_RUN" 8 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 9 | # file for possible values of NPM_RUN 10 | # Description 11 | # Environment: 12 | # * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). 13 | # Expose ports: 14 | # * 8080 - Unprivileged port used by nodejs application 15 | ENV APP_ROOT=/opt/app-root \ 16 | # The $HOME is not set by default, but some applications need this variable 17 | HOME=/opt/app-root/src \ 18 | NPM_RUN=start \ 19 | PLATFORM="el9" \ 20 | NODEJS_VERSION=22 \ 21 | NPM_RUN=start \ 22 | NAME=nodejs 23 | 24 | ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ 25 | DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ 26 | running various Node.js $NODEJS_VERSION applications and frameworks. \ 27 | Node.js is a platform built on Chrome's JavaScript runtime for easily building \ 28 | fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ 29 | that makes it lightweight and efficient, perfect for data-intensive real-time applications \ 30 | that run across distributed devices." \ 31 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 32 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH 33 | 34 | LABEL summary="$SUMMARY" \ 35 | description="$DESCRIPTION" \ 36 | io.k8s.description="$DESCRIPTION" \ 37 | io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \ 38 | io.openshift.expose-services="8080:http" \ 39 | io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ 40 | io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ 41 | io.s2i.scripts-url="image:///usr/libexec/s2i" \ 42 | com.redhat.dev-mode="DEV_MODE:false" \ 43 | com.redhat.deployments-dir="${APP_ROOT}/src" \ 44 | com.redhat.dev-mode.port="DEBUG_PORT:5858" \ 45 | com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ 46 | name="ubi9/$NAME-$NODEJS_VERSION-minimal" \ 47 | version="1" \ 48 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ 49 | maintainer="SoftwareCollections.org " \ 50 | help="For more information visit https://github.com/sclorg/s2i-nodejs-container" 51 | 52 | # nodejs-full-i18n is included for error strings 53 | RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar which" && \ 54 | microdnf -y module disable nodejs && \ 55 | microdnf -y module enable nodejs:$NODEJS_VERSION && \ 56 | microdnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ 57 | node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ 58 | microdnf clean all && \ 59 | rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* 60 | 61 | COPY ./s2i/bin/ /usr/libexec/s2i 62 | RUN chmod +x /usr/libexec/s2i/init-wrapper 63 | 64 | # Copy extra files to the image. 65 | COPY ./root/ / 66 | 67 | # Drop the root user and make the content of /opt/app-root owned by user 1001 68 | RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" 69 | WORKDIR "$HOME" 70 | USER 1001 71 | -------------------------------------------------------------------------------- /22-minimal/root/usr/bin/fix-permissions: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Allow this script to fail without failing a build 4 | set +e 5 | 6 | SYMLINK_OPT=${2:--L} 7 | 8 | # Fix permissions on the given directory or file to allow group read/write of 9 | # regular files and execute of directories. 10 | 11 | [ $(id -u) -ne 0 ] && CHECK_OWNER=" -uid $(id -u)" 12 | 13 | # If argument does not exist, script will still exit with 0, 14 | # but at least we'll see something went wrong in the log 15 | if ! [ -e "$1" ] ; then 16 | echo "ERROR: File or directory $1 does not exist." >&2 17 | # We still want to end successfully 18 | exit 0 19 | fi 20 | 21 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -gid 0 -exec chgrp 0 {} + 22 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -perm -g+rw -exec chmod g+rw {} + 23 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} -perm /u+x -a \! -perm /g+x -exec chmod g+x {} + 24 | find $SYMLINK_OPT "$1" ${CHECK_OWNER} -type d \! -perm /g+x -exec chmod g+x {} + 25 | 26 | # Always end successfully 27 | exit 0 28 | -------------------------------------------------------------------------------- /22-minimal/s2i/bin/init-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html 4 | # Set a trap to kill the main app process when this 5 | # init script receives SIGTERM or SIGINT 6 | trap 'kill -s TERM $PID' TERM INT 7 | # Execute the main application in the background 8 | "$@" & 9 | PID=$! 10 | # wait command always terminates when trap is caught, even if the process hasn't finished yet 11 | wait $PID 12 | # Remove the trap and wait till the app process finishes completely 13 | trap - TERM INT 14 | # We wait again, since the first wait terminates when trap is caught 15 | wait $PID 16 | # Exit with the exit code of the app process 17 | STATUS=$? 18 | exit $STATUS -------------------------------------------------------------------------------- /22-minimal/s2i/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # S2I run script for the 'nodejs' image. 4 | # The run script executes the server that runs your application. 5 | # 6 | # For more information see the documentation: 7 | # https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md 8 | # 9 | 10 | set -e 11 | 12 | # Runs the nodejs application server. If the container is run in development mode, 13 | # hot deploy and debugging are enabled. 14 | run_node() { 15 | echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" 16 | if [ "$DEV_MODE" == true ]; then 17 | echo "Launching via nodemon..." 18 | exec nodemon --inspect="$DEBUG_PORT" 19 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 20 | echo "launching via init wrapper..." 21 | exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD 22 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then 23 | echo "Launching via ${NODE_CMD}" 24 | exec $NODE_CMD 25 | elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 26 | 27 | package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json) 28 | package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json) 29 | 30 | if [ -n "$package_json_start" ]; then 31 | start_command=$package_json_start 32 | elif [ -n $package_json_main ]; then 33 | start_command="node ." 34 | elif [ -f "server.js" ]; then 35 | start_command="node server.js" 36 | else 37 | echo "Failed to find file for starting the Node.js application" 38 | exit 1 39 | fi 40 | echo "launching via init wrapper..." 41 | exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command 42 | else 43 | echo "Launching via npm..." 44 | exec npm run -d $NPM_RUN 45 | fi 46 | } 47 | 48 | #Set the debug port to 5858 by default. 49 | if [ -z "$DEBUG_PORT" ]; then 50 | export DEBUG_PORT=5858 51 | fi 52 | 53 | # Set the environment to development by default. 54 | if [ -z "$DEV_MODE" ]; then 55 | export DEV_MODE=false 56 | fi 57 | 58 | # If NODE_ENV is not set by the user, then NODE_ENV is determined by whether 59 | # the container is run in development mode. 60 | if [ -z "$NODE_ENV" ]; then 61 | if [ "$DEV_MODE" == true ]; then 62 | export NODE_ENV=development 63 | else 64 | export NODE_ENV=production 65 | fi 66 | fi 67 | 68 | # If the official dockerhub node image is used, skip the SCL setup below 69 | # and just run the nodejs server 70 | if [ -d "/usr/src/app" ]; then 71 | run_node 72 | fi 73 | 74 | # Allow users to inspect/debug the builder image itself, by using: 75 | # $ docker run -i -t openshift/centos-nodejs-builder --debug 76 | # 77 | [ "$1" == "--debug" ] && exec /bin/bash 78 | 79 | run_node 80 | -------------------------------------------------------------------------------- /22-minimal/s2i/bin/save-artifacts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then 4 | tar -C "${HOME}" -cf - node_modules 5 | fi 6 | -------------------------------------------------------------------------------- /22-minimal/s2i/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` 4 | 5 | cat < nodejs-sample-app 12 | 13 | You can then run the resulting image via: 14 | podman run -p 8080:8080 nodejs-sample-app 15 | EOF 16 | -------------------------------------------------------------------------------- /22-minimal/test/check_imagestreams.py: -------------------------------------------------------------------------------- 1 | ../../common/check_imagestreams.py -------------------------------------------------------------------------------- /22-minimal/test/examples: -------------------------------------------------------------------------------- 1 | ../../examples/ -------------------------------------------------------------------------------- /22-minimal/test/imagestreams: -------------------------------------------------------------------------------- 1 | ../../imagestreams/ -------------------------------------------------------------------------------- /22-minimal/test/run: -------------------------------------------------------------------------------- 1 | ../../test/run-minimal -------------------------------------------------------------------------------- /22-minimal/test/run-openshift-remote-cluster: -------------------------------------------------------------------------------- 1 | ../../test/run-openshift-remote-cluster -------------------------------------------------------------------------------- /22-minimal/test/test-app: -------------------------------------------------------------------------------- 1 | ../../test/test-app -------------------------------------------------------------------------------- /22-minimal/test/test-binary: -------------------------------------------------------------------------------- 1 | ../../test/test-binary -------------------------------------------------------------------------------- /22-minimal/test/test-express-webapp: -------------------------------------------------------------------------------- 1 | ../../test/test-express-webapp -------------------------------------------------------------------------------- /22-minimal/test/test-hw: -------------------------------------------------------------------------------- 1 | ../../test/test-hw -------------------------------------------------------------------------------- /22-minimal/test/test-incremental: -------------------------------------------------------------------------------- 1 | ../../test/test-incremental -------------------------------------------------------------------------------- /22-minimal/test/test-lib-nodejs.sh: -------------------------------------------------------------------------------- 1 | ../../test/test-lib-nodejs.sh -------------------------------------------------------------------------------- /22-minimal/test/test-lib-openshift.sh: -------------------------------------------------------------------------------- 1 | ../../common/test-lib-openshift.sh -------------------------------------------------------------------------------- /22-minimal/test/test-lib-remote-openshift.sh: -------------------------------------------------------------------------------- 1 | ../../common/test-lib-remote-openshift.sh -------------------------------------------------------------------------------- /22-minimal/test/test-lib.sh: -------------------------------------------------------------------------------- 1 | ../../common/test-lib.sh -------------------------------------------------------------------------------- /22-minimal/test/test-openshift.yaml: -------------------------------------------------------------------------------- 1 | ../../common/test-openshift.yaml -------------------------------------------------------------------------------- /22/.exclude-c8s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sclorg/s2i-nodejs-container/ff61c620ca06214a60080b899c257e170d0dbdb1/22/.exclude-c8s -------------------------------------------------------------------------------- /22/.exclude-c9s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sclorg/s2i-nodejs-container/ff61c620ca06214a60080b899c257e170d0dbdb1/22/.exclude-c9s -------------------------------------------------------------------------------- /22/Dockerfile.fedora: -------------------------------------------------------------------------------- 1 | FROM quay.io/fedora/s2i-core:40 2 | 3 | # This image provides a Node.JS environment you can use to run your Node.JS 4 | # applications. 5 | 6 | EXPOSE 8080 7 | 8 | # Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts 9 | # available on the CLI without using npm's --global installation mode 10 | # This image will be initialized with "npm run $NPM_RUN" 11 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 12 | # file for possible values of NPM_RUN 13 | # Description 14 | # Environment: 15 | # * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). 16 | # Expose ports: 17 | # * 8080 - Unprivileged port used by nodejs application 18 | 19 | ENV NODEJS_VERSION=22 \ 20 | NPM_RUN=start \ 21 | NAME=nodejs \ 22 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 23 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH 24 | 25 | ENV SUMMARY="Platform for building and running Node.js $NODEJS_VERSION applications" \ 26 | DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ 27 | building and running various Node.js $NODEJS_VERSION applications and frameworks. \ 28 | Node.js is a platform built on Chrome's JavaScript runtime for easily building \ 29 | fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ 30 | that makes it lightweight and efficient, perfect for data-intensive real-time applications \ 31 | that run across distributed devices." 32 | 33 | LABEL summary="$SUMMARY" \ 34 | description="$DESCRIPTION" \ 35 | io.k8s.description="$DESCRIPTION" \ 36 | io.k8s.display-name="Node.js $NODEJS_VERSION" \ 37 | io.openshift.expose-services="8080:http" \ 38 | io.openshift.tags="builder,$NAME,$NAME$NODEJS_VERSION" \ 39 | io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ 40 | io.s2i.scripts-url="image:///usr/libexec/s2i" \ 41 | com.redhat.dev-mode="DEV_MODE:false" \ 42 | com.redhat.deployments-dir="${APP_ROOT}/src" \ 43 | com.redhat.dev-mode.port="DEBUG_PORT:5858"\ 44 | com.redhat.component="$NAME" \ 45 | name="fedora/$NAME-$NODEJS_VERSION" \ 46 | version="$NODEJS_VERSION" \ 47 | maintainer="SoftwareCollections.org " \ 48 | help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \ 49 | usage="oc new-app $FGC/$NAME~" 50 | 51 | RUN INSTALL_PKGS="make gcc gcc-c++ libatomic_ops git openssl-devel nodejs$NODEJS_VERSION nodejs-nodemon nodejs$NODEJS_VERSION-npm nss_wrapper-libs which" && \ 52 | dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ 53 | rpm -V $INSTALL_PKGS && \ 54 | ln -s /usr/bin/node-$NODEJS_VERSION /usr/bin/node && \ 55 | ln -s /usr/bin/npm-$NODEJS_VERSION /usr/bin/npm && \ 56 | ln -s /usr/bin/npx-$NODEJS_VERSION /usr/bin/npx && \ 57 | node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ 58 | dnf -y clean all --enablerepo='*' 59 | 60 | # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH 61 | COPY ./s2i/bin/ $STI_SCRIPTS_PATH 62 | RUN chmod +x /usr/libexec/s2i/init-wrapper 63 | 64 | # Copy extra files to the image, including help file. 65 | COPY ./root/ / 66 | 67 | # Drop the root user and make the content of /opt/app-root owned by user 1001 68 | RUN chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \ 69 | rpm-file-permissions 70 | 71 | USER 1001 72 | 73 | # Set the default CMD to print the usage of the language image 74 | CMD $STI_SCRIPTS_PATH/usage 75 | -------------------------------------------------------------------------------- /22/root/opt/app-root/etc/generate_container_user: -------------------------------------------------------------------------------- 1 | # Set current user in nss_wrapper 2 | USER_ID=$(id -u) 3 | GROUP_ID=$(id -g) 4 | 5 | if [ x"$USER_ID" != x"0" -a x"$USER_ID" != x"1001" ]; then 6 | 7 | NSS_WRAPPER_PASSWD=/opt/app-root/etc/passwd 8 | NSS_WRAPPER_GROUP=/etc/group 9 | 10 | cat /etc/passwd | sed -e 's/^default:/builder:/' > $NSS_WRAPPER_PASSWD 11 | 12 | echo "default:x:${USER_ID}:${GROUP_ID}:Default Application User:${HOME}:/sbin/nologin" >> $NSS_WRAPPER_PASSWD 13 | 14 | export NSS_WRAPPER_PASSWD 15 | export NSS_WRAPPER_GROUP 16 | export LD_PRELOAD=libnss_wrapper.so 17 | fi 18 | -------------------------------------------------------------------------------- /22/root/opt/app-root/etc/npm_global_module_list: -------------------------------------------------------------------------------- 1 | async 2 | mime 3 | mkdirp 4 | qs 5 | minimatch 6 | -------------------------------------------------------------------------------- /22/root/opt/app-root/etc/scl_enable: -------------------------------------------------------------------------------- 1 | # This will make scl collection binaries work out of box. 2 | unset BASH_ENV PROMPT_COMMAND ENV 3 | source scl_source enable rh-nodejs${NODEJS_VERSION} 4 | -------------------------------------------------------------------------------- /22/s2i/bin/init-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html 4 | # Set a trap to kill the main app process when this 5 | # init script receives SIGTERM or SIGINT 6 | trap 'kill -s TERM $PID' TERM INT 7 | # Execute the main application in the background 8 | "$@" & 9 | PID=$! 10 | # wait command always terminates when trap is caught, even if the process hasn't finished yet 11 | wait $PID 12 | # Remove the trap and wait till the app process finishes completely 13 | trap - TERM INT 14 | # We wait again, since the first wait terminates when trap is caught 15 | wait $PID 16 | # Exit with the exit code of the app process 17 | STATUS=$? 18 | exit $STATUS -------------------------------------------------------------------------------- /22/s2i/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # S2I run script for the 'nodejs' image. 4 | # The run script executes the server that runs your application. 5 | # 6 | # For more information see the documentation: 7 | # https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md 8 | # 9 | 10 | set -e 11 | 12 | if [ -e "/opt/app-root/etc/generate_container_user" ]; then 13 | source /opt/app-root/etc/generate_container_user 14 | fi 15 | 16 | # Runs the nodejs application server. If the container is run in development mode, 17 | # hot deploy and debugging are enabled. 18 | run_node() { 19 | echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" 20 | if [ "$DEV_MODE" == true ]; then 21 | echo "Launching via nodemon..." 22 | exec nodemon --inspect="$DEBUG_PORT" 23 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 24 | echo "launching via init wrapper..." 25 | exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD 26 | elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then 27 | echo "Launching via ${NODE_CMD}" 28 | exec $NODE_CMD 29 | elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then 30 | 31 | package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json) 32 | package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json) 33 | 34 | if [ -n "$package_json_start" ]; then 35 | start_command=$package_json_start 36 | elif [ -n $package_json_main ]; then 37 | start_command="node ." 38 | elif [ -f "server.js" ]; then 39 | start_command="node server.js" 40 | else 41 | echo "Failed to find file for starting the Node.js application" 42 | exit 1 43 | fi 44 | echo "launching via init wrapper..." 45 | exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command 46 | else 47 | echo "Launching via npm..." 48 | exec npm run -d $NPM_RUN 49 | fi 50 | } 51 | 52 | #Set the debug port to 5858 by default. 53 | if [ -z "$DEBUG_PORT" ]; then 54 | export DEBUG_PORT=5858 55 | fi 56 | 57 | # Set the environment to development by default. 58 | if [ -z "$DEV_MODE" ]; then 59 | export DEV_MODE=false 60 | fi 61 | 62 | # If NODE_ENV is not set by the user, then NODE_ENV is determined by whether 63 | # the container is run in development mode. 64 | if [ -z "$NODE_ENV" ]; then 65 | if [ "$DEV_MODE" == true ]; then 66 | export NODE_ENV=development 67 | else 68 | export NODE_ENV=production 69 | fi 70 | fi 71 | 72 | # If the official dockerhub node image is used, skip the SCL setup below 73 | # and just run the nodejs server 74 | if [ -d "/usr/src/app" ]; then 75 | run_node 76 | fi 77 | 78 | # Allow users to inspect/debug the builder image itself, by using: 79 | # $ docker run -i -t openshift/centos-nodejs-builder --debug 80 | # 81 | [ "$1" == "--debug" ] && exec /bin/bash 82 | 83 | run_node 84 | -------------------------------------------------------------------------------- /22/s2i/bin/save-artifacts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then 4 | tar -C "${HOME}" -cf - node_modules 5 | fi 6 | -------------------------------------------------------------------------------- /22/s2i/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` 4 | 5 | cat < nodejs-sample-app 12 | 13 | You can then run the resulting image via: 14 | podman run -p 8080:8080 nodejs-sample-app 15 | EOF 16 | -------------------------------------------------------------------------------- /22/test: -------------------------------------------------------------------------------- 1 | ../test/ -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Include common Makefile code. 2 | BASE_IMAGE_NAME = nodejs 3 | VERSIONS = 20 20-minimal 22 22-minimal 4 | OPENSHIFT_NAMESPACES = 5 | 6 | # HACK: Ensure that 'git pull' for old clones doesn't cause confusion. 7 | # New clones should use '--recursive'. 8 | .PHONY: $(shell test -f common/common.mk || echo >&2 'Please do "git submodule update --init" first.') 9 | 10 | include common/common.mk 11 | 12 | .PHONY: test-upstream 13 | test-upstream: tag 14 | VERSIONS="$(VERSIONS)" TEST_UPSTREAM=yes common/test.sh 15 | -------------------------------------------------------------------------------- /examples/from-dockerfile/.gitignore: -------------------------------------------------------------------------------- 1 | app-src 2 | 3 | -------------------------------------------------------------------------------- /examples/from-dockerfile/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi8/nodejs-16 2 | 3 | # Add application sources 4 | ADD app-src . 5 | 6 | # In case you run into permission errors during build (eg. by use of umask) 7 | # running the fix-permission script will make sure all bits are as expected by the image 8 | USER 0 9 | RUN fix-permissions ./ 10 | USER 1001 11 | 12 | # Install the dependencies 13 | RUN npm install 14 | 15 | # Run script uses standard ways to run the application 16 | CMD npm run -d start 17 | -------------------------------------------------------------------------------- /examples/from-dockerfile/Dockerfile.s2i: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi8/nodejs-16 2 | 3 | # This image supports the Source-to-Image 4 | # (see more at https://docs.openshift.com/container-platform/3.11/creating_images/s2i.html). 5 | # In order to support the Source-to-Image framework, there are some interesting 6 | # scripts inside the builder image, that can be run in a Dockerfile directly as well: 7 | # * The `/usr/libexec/s2i/assemble` script inside the image is run in order 8 | # to produce a new image with the application artifacts. 9 | # The script takes sources of a given application and places them into 10 | # appropriate directories inside the image. 11 | # * The `/usr/libexec/s2i/run` script executes the application and is set as 12 | # a default command in the resulting container image. 13 | 14 | # Add application sources to a directory that the assemble script expects them 15 | # and set permissions so that the container runs without root access 16 | USER 0 17 | ADD app-src /tmp/src 18 | RUN chown -R 1001:0 /tmp/src 19 | USER 1001 20 | 21 | # Let the assemble script to install the dependencies 22 | RUN /usr/libexec/s2i/assemble 23 | 24 | # Run script uses standard ways to run the application 25 | CMD /usr/libexec/s2i/run 26 | -------------------------------------------------------------------------------- /examples/from-dockerfile/README.md: -------------------------------------------------------------------------------- 1 | Dockerfile examples 2 | =================== 3 | 4 | This directory contains example Dockerfiles that demonstrate how to use the image with a Dockerfile and `docker build`. 5 | 6 | For demonstration, we use an application code available at https://github.com/sclorg/nodejs-ex.git. 7 | 8 | Pull the source to the local machine first: 9 | ``` 10 | git clone https://github.com/sclorg/nodejs-ex.git app-src 11 | ``` 12 | 13 | Then, build a new image from a Dockerfile in this directory: 14 | ``` 15 | docker build -f Dockerfile -t node-app . 16 | ``` 17 | 18 | And run the resulting image with the final application: 19 | ``` 20 | docker run -ti --rm node-app 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /imagestreams/imagestreams.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: nodejs 3 | pretty_name: Node.js 4 | sample_repo: https://github.com/sclorg/nodejs-ex.git 5 | category: builder 6 | description: >- 7 | Build and run Node.js APP_VERSION applications on DISTRO_NAME. For more information 8 | about using this builder image, including OpenShift considerations, see 9 | https://github.com/sclorg/s2i-nodejs-container/blob/master/APP_VERSION/README.md. 10 | imagestream_files: 11 | - filename: nodejs-centos.json 12 | latest: "22-ubi9" 13 | distros: 14 | - name: UBI 8 15 | app_versions: ["20", "20-minimal"] 16 | 17 | - name: UBI 9 18 | app_versions: ["20", "20-minimal", "22", "22-minimal"] 19 | custom_tags: 20 | - name: "20-ubi8-minimal" 21 | distro: UBI 8 22 | app_version: "20-minimal" 23 | - name: "20-ubi9-minimal" 24 | distro: UBI 9 25 | app_version: "20-minimal" 26 | - name: "22-ubi9-minimal" 27 | distro: UBI 9 28 | app_version: "22-minimal" 29 | 30 | - filename: nodejs-rhel.json 31 | latest: "22-ubi9" 32 | distros: 33 | - name: UBI 8 34 | app_versions: ["20", "20-minimal"] 35 | 36 | - name: UBI 9 37 | app_versions: ["20", "20-minimal", "22", "22-minimal"] 38 | # these are non standard tags, maintained for backwards compatibility 39 | custom_tags: 40 | - name: "20-ubi8-minimal" 41 | distro: UBI 8 42 | app_version: "20-minimal" 43 | - name: "20-ubi9-minimal" 44 | distro: UBI 9 45 | app_version: "20-minimal" 46 | - name: "22-ubi9-minimal" 47 | distro: UBI 9 48 | app_version: "22-minimal" 49 | 50 | - filename: nodejs-rhel-aarch64.json 51 | latest: "22-ubi9" 52 | distros: 53 | - name: UBI 8 54 | app_versions: ["20", "20-minimal"] 55 | 56 | - name: UBI 9 57 | app_versions: ["20", "20-minimal", "22", "22-minimal"] 58 | custom_tags: 59 | - name: "20-ubi8-minimal" 60 | distro: UBI 8 61 | app_version: "20-minimal" 62 | - name: "20-ubi9-minimal" 63 | distro: UBI 9 64 | app_version: "20-minimal" 65 | - name: "22-ubi9-minimal" 66 | distro: UBI 9 67 | app_version: "22-minimal" 68 | ... 69 | -------------------------------------------------------------------------------- /test/check_imagestreams.py: -------------------------------------------------------------------------------- 1 | ../common/check_imagestreams.py -------------------------------------------------------------------------------- /test/examples: -------------------------------------------------------------------------------- 1 | ../examples -------------------------------------------------------------------------------- /test/imagestreams: -------------------------------------------------------------------------------- 1 | ../imagestreams -------------------------------------------------------------------------------- /test/run-openshift-pytest: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # IMAGE_NAME specifies a name of the candidate image used for testing. 4 | # The image has to be available before this script is executed. 5 | # VERSION specifies the major version of the MariaDB in format of X.Y 6 | # OS specifies RHEL version (e.g. OS=rhel7) 7 | # 8 | 9 | THISDIR=$(dirname ${BASH_SOURCE[0]}) 10 | 11 | cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_*.py 12 | -------------------------------------------------------------------------------- /test/run-openshift-remote-cluster: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Test the NodeJS image in OpenShift. 4 | # 5 | # IMAGE_NAME specifies a name of the candidate image used for testing. 6 | # The image has to be available before this script is executed. 7 | # 8 | 9 | THISDIR=$(dirname ${BASH_SOURCE[0]}) 10 | 11 | source "${THISDIR}/test-lib.sh" 12 | source "${THISDIR}/test-lib-openshift.sh" 13 | source "${THISDIR}/test-lib-nodejs.sh" 14 | source "${THISDIR}/test-lib-remote-openshift.sh" 15 | 16 | TEST_LIST="\ 17 | test_nodejs_s2i_container 18 | test_nodejs_s2i_app_ex 19 | test_nodejs_s2i_templates 20 | test_nodejs_imagestream 21 | test_latest_imagestreams 22 | " 23 | 24 | # change the branch to a different value if a new change in the example 25 | # app needs to be tested 26 | BRANCH_TO_TEST=master 27 | 28 | trap ct_os_cleanup EXIT SIGINT 29 | 30 | ct_os_set_ocp4 || exit $OC_ERR 31 | 32 | ct_os_check_compulsory_vars || exit $OC_ERR 33 | 34 | ct_os_check_login || exit $OC_ERR 35 | 36 | ct_os_tag_image_for_cvp "nodejs" 37 | 38 | ct_pull_or_import_postgresql || exit $OC_ERR 39 | 40 | set -u 41 | 42 | test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined' 43 | test -n "${VERSION-}" || false 'make sure $VERSION is defined' 44 | 45 | # For testing on OpenShift 4 we use internal registry 46 | export CT_OCP4_TEST=true 47 | export CT_SKIP_UPLOAD_IMAGE=true 48 | 49 | TEST_SUMMARY='' 50 | TEST_SET=${TESTS:-$TEST_LIST} ct_run_tests_from_testset "openshift-remote-cluster" 51 | 52 | 53 | # vim: set tabstop=2:shiftwidth=2:expandtab: 54 | -------------------------------------------------------------------------------- /test/show_all_imagestreams.py: -------------------------------------------------------------------------------- 1 | ../common/show_all_imagestreams.py -------------------------------------------------------------------------------- /test/test-app/README.md: -------------------------------------------------------------------------------- 1 | node-echo 2 | ========= 3 | 4 | node.js echo server, returns request data to response 5 | -------------------------------------------------------------------------------- /test/test-app/iisnode.yml: -------------------------------------------------------------------------------- 1 | # For documentation see https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml 2 | 3 | # loggingEnabled: false 4 | # debuggingEnabled: false 5 | # devErrorsEnabled: false 6 | node_env: production 7 | # nodeProcessCountPerApplication: 1 8 | # maxConcurrentRequestsPerProcess: 1024 9 | # maxNamedPipeConnectionRetry: 24 10 | # namedPipeConnectionRetryDelay: 250 11 | # maxNamedPipeConnectionPoolSize: 512 12 | # maxNamedPipePooledConnectionAge: 30000 13 | # asyncCompletionThreadCount: 0 14 | # initialRequestBufferSize: 4096 15 | # maxRequestBufferSize: 65536 16 | watchedFiles: iisnode.yml;node_modules\*;*.js 17 | # uncFileChangesPollingInterval: 5000 18 | # gracefulShutdownTimeout: 60000 19 | # logDirectoryNameSuffix: logs 20 | # debuggerPortRange: 5058-6058 21 | # debuggerPathSegment: debug 22 | # maxLogFileSizeInKB: 128 23 | # appendToExistingLog: false 24 | # logFileFlushInterval: 5000 25 | # flushResponse: false 26 | # enableXFF: false 27 | # promoteServerVars: -------------------------------------------------------------------------------- /test/test-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-echo", 3 | "version": "0.0.1", 4 | "description": "node-echo", 5 | "main": "server.js", 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "nodemon": "*" 10 | }, 11 | "engine": { 12 | "node": "*", 13 | "npm": "*" 14 | }, 15 | "scripts": { 16 | "dev": "nodemon --ignore node_modules/ server.js", 17 | "start": "node server.js" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "http://github.com/bettiolo/node-echo.git" 22 | }, 23 | "keywords": [ 24 | "Echo" 25 | ], 26 | "author": "Marco Bettiolo ", 27 | "license": "", 28 | "bugs": { 29 | "url": "http://github.com/bettiolo/node-echo/issues" 30 | }, 31 | "homepage": "http://apilb.com" 32 | } 33 | -------------------------------------------------------------------------------- /test/test-app/server.js: -------------------------------------------------------------------------------- 1 | var util = require('util'); 2 | var http = require('http'); 3 | var url = require('url'); 4 | var qs = require('querystring'); 5 | var os = require('os') 6 | var port = process.env.PORT || process.env.port || process.env.OPENSHIFT_NODEJS_PORT || 8080; 7 | var ip = process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; 8 | var nodeEnv = process.env.NODE_ENV || 'unknown'; 9 | var server = http.createServer(function (req, res) { 10 | var url_parts = url.parse(req.url, true); 11 | 12 | var body = ''; 13 | req.on('data', function (data) { 14 | body += data; 15 | }); 16 | req.on('end', function () { 17 | var formattedBody = qs.parse(body); 18 | 19 | res.writeHead(200, {'Content-Type': 'text/plain'}); 20 | 21 | res.write('This is a node.js echo service\n'); 22 | res.write('Host: ' + req.headers.host + '\n'); 23 | res.write('\n'); 24 | res.write('node.js Production Mode: ' + (nodeEnv == 'production' ? 'yes' : 'no') + '\n'); 25 | res.write('\n'); 26 | res.write('HTTP/' + req.httpVersion +'\n'); 27 | res.write('Request headers:\n'); 28 | res.write(util.inspect(req.headers, null) + '\n'); 29 | res.write('Request query:\n'); 30 | res.write(util.inspect(url_parts.query, null) + '\n'); 31 | res.write('Request body:\n'); 32 | res.write(util.inspect(formattedBody, null) + '\n'); 33 | res.write('\n'); 34 | res.write('Host: ' + os.hostname() + '\n'); 35 | res.write('OS Type: ' + os.type() + '\n'); 36 | res.write('OS Platform: ' + os.platform() + '\n'); 37 | res.write('OS Arch: ' + os.arch() + '\n'); 38 | res.write('OS Release: ' + os.release() + '\n'); 39 | res.write('OS Uptime: ' + os.uptime() + '\n'); 40 | res.write('OS Free memory: ' + os.freemem() / 1024 / 1024 + 'mb\n'); 41 | res.write('OS Total memory: ' + os.totalmem() / 1024 / 1024 + 'mb\n'); 42 | res.write('OS CPU count: ' + os.cpus().length + '\n'); 43 | res.write('OS CPU model: ' + os.cpus()[0].model + '\n'); 44 | res.write('OS CPU speed: ' + os.cpus()[0].speed + 'mhz\n'); 45 | res.end('\n'); 46 | 47 | }); 48 | }); 49 | server.listen(port); 50 | console.log('Server running on ' + ip + ':' + port); 51 | -------------------------------------------------------------------------------- /test/test-app/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/test-binary/binary.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var ip = process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; 3 | var port = process.env.PORT || process.env.port || process.env.OPENSHIFT_NODEJS_PORT || 8080; 4 | 5 | var server = http.createServer(function(req, res) { 6 | res.writeHead(200); 7 | res.end('Hello World!'); 8 | }); 9 | server.listen(port); 10 | 11 | console.log("Server running on " + ip + ":" + port); 12 | -------------------------------------------------------------------------------- /test/test-binary/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-world", 3 | "version": "0.0.1", 4 | "main": "binary.js", 5 | "engine": { 6 | "node": "*", 7 | "npm": "*" 8 | }, 9 | "dependencies": { 10 | "node-rdkafka": "*" 11 | }, 12 | "scripts": { 13 | "start": "node binary.js", 14 | "dev": "node binary.js" 15 | }, 16 | "license": "" 17 | } 18 | -------------------------------------------------------------------------------- /test/test-express-webapp/app.js: -------------------------------------------------------------------------------- 1 | var createError = require('http-errors'); 2 | var express = require('express'); 3 | var path = require('path'); 4 | var cookieParser = require('cookie-parser'); 5 | var logger = require('morgan'); 6 | 7 | var indexRouter = require('./routes/index'); 8 | var usersRouter = require('./routes/users'); 9 | 10 | var app = express(); 11 | 12 | // view engine setup 13 | app.set('views', path.join(__dirname, 'views')); 14 | app.set('view engine', 'jade'); 15 | 16 | app.use(logger('dev')); 17 | app.use(express.json()); 18 | app.use(express.urlencoded({ extended: false })); 19 | app.use(cookieParser()); 20 | app.use(express.static(path.join(__dirname, 'public'))); 21 | 22 | app.use('/', indexRouter); 23 | app.use('/users', usersRouter); 24 | 25 | // catch 404 and forward to error handler 26 | app.use(function(req, res, next) { 27 | next(createError(404)); 28 | }); 29 | 30 | // error handler 31 | app.use(function(err, req, res, next) { 32 | // set locals, only providing error in development 33 | res.locals.message = err.message; 34 | res.locals.error = req.app.get('env') === 'development' ? err : {}; 35 | 36 | // render the error page 37 | res.status(err.status || 500); 38 | res.render('error'); 39 | }); 40 | 41 | module.exports = app; 42 | -------------------------------------------------------------------------------- /test/test-express-webapp/bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | var app = require('../app'); 8 | var debug = require('debug')('test-express-webapp:server'); 9 | var http = require('http'); 10 | 11 | /** 12 | * Get port from environment and store in Express. 13 | */ 14 | 15 | var port = normalizePort(process.env.PORT || '8080'); 16 | app.set('port', port); 17 | 18 | /** 19 | * Create HTTP server. 20 | */ 21 | 22 | var server = http.createServer(app); 23 | 24 | /** 25 | * Listen on provided port, on all network interfaces. 26 | */ 27 | 28 | server.listen(port); 29 | server.on('error', onError); 30 | server.on('listening', onListening); 31 | 32 | /** 33 | * Normalize a port into a number, string, or false. 34 | */ 35 | 36 | function normalizePort(val) { 37 | var port = parseInt(val, 10); 38 | 39 | if (isNaN(port)) { 40 | // named pipe 41 | return val; 42 | } 43 | 44 | if (port >= 0) { 45 | // port number 46 | return port; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | /** 53 | * Event listener for HTTP server "error" event. 54 | */ 55 | 56 | function onError(error) { 57 | if (error.syscall !== 'listen') { 58 | throw error; 59 | } 60 | 61 | var bind = typeof port === 'string' 62 | ? 'Pipe ' + port 63 | : 'Port ' + port; 64 | 65 | // handle specific listen errors with friendly messages 66 | switch (error.code) { 67 | case 'EACCES': 68 | console.error(bind + ' requires elevated privileges'); 69 | process.exit(1); 70 | break; 71 | case 'EADDRINUSE': 72 | console.error(bind + ' is already in use'); 73 | process.exit(1); 74 | break; 75 | default: 76 | throw error; 77 | } 78 | } 79 | 80 | /** 81 | * Event listener for HTTP server "listening" event. 82 | */ 83 | 84 | function onListening() { 85 | var addr = server.address(); 86 | var bind = typeof addr === 'string' 87 | ? 'pipe ' + addr 88 | : 'port ' + addr.port; 89 | debug('Listening on ' + bind); 90 | } 91 | -------------------------------------------------------------------------------- /test/test-express-webapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-express-webapp", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node ./bin/www" 7 | }, 8 | "dependencies": { 9 | "cookie-parser": "*", 10 | "debug": "*", 11 | "express": "*", 12 | "http-errors": "*", 13 | "jade": "*", 14 | "morgan": "*" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/test-express-webapp/public/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 50px; 3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; 4 | } 5 | 6 | a { 7 | color: #00B7FF; 8 | } 9 | -------------------------------------------------------------------------------- /test/test-express-webapp/routes/index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | 4 | /* GET home page. */ 5 | router.get('/', function(req, res, next) { 6 | res.render('index', { title: 'Express Testing Application' }); 7 | }); 8 | 9 | module.exports = router; 10 | -------------------------------------------------------------------------------- /test/test-express-webapp/routes/users.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | 4 | /* GET users listing. */ 5 | router.get('/', function(req, res, next) { 6 | res.send('respond with a resource'); 7 | }); 8 | 9 | module.exports = router; 10 | -------------------------------------------------------------------------------- /test/test-express-webapp/views/error.jade: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h1= message 5 | h2= error.status 6 | pre #{error.stack} 7 | -------------------------------------------------------------------------------- /test/test-express-webapp/views/index.jade: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h1= title 5 | p Welcome to #{title} 6 | -------------------------------------------------------------------------------- /test/test-express-webapp/views/layout.jade: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | title= title 5 | link(rel='stylesheet', href='/stylesheets/style.css') 6 | body 7 | block content 8 | -------------------------------------------------------------------------------- /test/test-hw/hw.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var ip = process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; 3 | var port = process.env.PORT || process.env.port || process.env.OPENSHIFT_NODEJS_PORT || 8080; 4 | 5 | var server = http.createServer(function(req, res) { 6 | res.writeHead(200); 7 | res.end('Hello World!'); 8 | }); 9 | server.listen(port); 10 | 11 | console.log("Server running on " + ip + ":" + port); 12 | -------------------------------------------------------------------------------- /test/test-hw/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-world", 3 | "version": "0.0.1", 4 | "main": "hw.js", 5 | "engine": { 6 | "node": "*", 7 | "npm": "*" 8 | }, 9 | "scripts": { 10 | "start": "node hw.js", 11 | "dev": "node hw.js" 12 | }, 13 | "license": "" 14 | } 15 | -------------------------------------------------------------------------------- /test/test-incremental/README.md: -------------------------------------------------------------------------------- 1 | node-echo 2 | ========= 3 | 4 | node.js echo server, returns request data to response 5 | -------------------------------------------------------------------------------- /test/test-incremental/iisnode.yml: -------------------------------------------------------------------------------- 1 | # For documentation see https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml 2 | 3 | # loggingEnabled: false 4 | # debuggingEnabled: false 5 | # devErrorsEnabled: false 6 | node_env: production 7 | # nodeProcessCountPerApplication: 1 8 | # maxConcurrentRequestsPerProcess: 1024 9 | # maxNamedPipeConnectionRetry: 24 10 | # namedPipeConnectionRetryDelay: 250 11 | # maxNamedPipeConnectionPoolSize: 512 12 | # maxNamedPipePooledConnectionAge: 30000 13 | # asyncCompletionThreadCount: 0 14 | # initialRequestBufferSize: 4096 15 | # maxRequestBufferSize: 65536 16 | watchedFiles: iisnode.yml;node_modules\*;*.js 17 | # uncFileChangesPollingInterval: 5000 18 | # gracefulShutdownTimeout: 60000 19 | # logDirectoryNameSuffix: logs 20 | # debuggerPortRange: 5058-6058 21 | # debuggerPathSegment: debug 22 | # maxLogFileSizeInKB: 128 23 | # appendToExistingLog: false 24 | # logFileFlushInterval: 5000 25 | # flushResponse: false 26 | # enableXFF: false 27 | # promoteServerVars: -------------------------------------------------------------------------------- /test/test-incremental/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-echo", 3 | "version": "0.0.1", 4 | "description": "node-echo", 5 | "main": "server.js", 6 | "dependencies": { 7 | "yarn": "*" 8 | }, 9 | "devDependencies": { 10 | "nodemon": "*" 11 | }, 12 | "engine": { 13 | "node": "*", 14 | "npm": "*" 15 | }, 16 | "scripts": { 17 | "dev": "nodemon --ignore node_modules/ server.js", 18 | "start": "node server.js" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "http://github.com/bettiolo/node-echo.git" 23 | }, 24 | "keywords": [ 25 | "Echo" 26 | ], 27 | "author": "Marco Bettiolo ", 28 | "license": "", 29 | "bugs": { 30 | "url": "http://github.com/bettiolo/node-echo/issues" 31 | }, 32 | "homepage": "http://apilb.com" 33 | } 34 | -------------------------------------------------------------------------------- /test/test-incremental/server.js: -------------------------------------------------------------------------------- 1 | var util = require('util'); 2 | var http = require('http'); 3 | var url = require('url'); 4 | var qs = require('querystring'); 5 | var os = require('os') 6 | var port = process.env.PORT || process.env.port || process.env.OPENSHIFT_NODEJS_PORT || 8080; 7 | var ip = process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; 8 | var nodeEnv = process.env.NODE_ENV || 'unknown'; 9 | var server = http.createServer(function (req, res) { 10 | var url_parts = url.parse(req.url, true); 11 | 12 | var body = ''; 13 | req.on('data', function (data) { 14 | body += data; 15 | }); 16 | req.on('end', function () { 17 | var formattedBody = qs.parse(body); 18 | 19 | res.writeHead(200, {'Content-Type': 'text/plain'}); 20 | 21 | res.write('This is a node.js echo service\n'); 22 | res.write('Host: ' + req.headers.host + '\n'); 23 | res.write('\n'); 24 | res.write('node.js Production Mode: ' + (nodeEnv == 'production' ? 'yes' : 'no') + '\n'); 25 | res.write('\n'); 26 | res.write('HTTP/' + req.httpVersion +'\n'); 27 | res.write('Request headers:\n'); 28 | res.write(util.inspect(req.headers, null) + '\n'); 29 | res.write('Request query:\n'); 30 | res.write(util.inspect(url_parts.query, null) + '\n'); 31 | res.write('Request body:\n'); 32 | res.write(util.inspect(formattedBody, null) + '\n'); 33 | res.write('\n'); 34 | res.write('Host: ' + os.hostname() + '\n'); 35 | res.write('OS Type: ' + os.type() + '\n'); 36 | res.write('OS Platform: ' + os.platform() + '\n'); 37 | res.write('OS Arch: ' + os.arch() + '\n'); 38 | res.write('OS Release: ' + os.release() + '\n'); 39 | res.write('OS Uptime: ' + os.uptime() + '\n'); 40 | res.write('OS Free memory: ' + os.freemem() / 1024 / 1024 + 'mb\n'); 41 | res.write('OS Total memory: ' + os.totalmem() / 1024 / 1024 + 'mb\n'); 42 | res.write('OS CPU count: ' + os.cpus().length + '\n'); 43 | res.write('OS CPU model: ' + os.cpus()[0].model + '\n'); 44 | res.write('OS CPU speed: ' + os.cpus()[0].speed + 'mhz\n'); 45 | res.end('\n'); 46 | 47 | }); 48 | }); 49 | server.listen(port); 50 | console.log('Server running on ' + ip + ':' + port); 51 | -------------------------------------------------------------------------------- /test/test-incremental/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/test-lib-openshift.sh: -------------------------------------------------------------------------------- 1 | ../common/test-lib-openshift.sh -------------------------------------------------------------------------------- /test/test-lib-remote-openshift.sh: -------------------------------------------------------------------------------- 1 | ../common/test-lib-remote-openshift.sh -------------------------------------------------------------------------------- /test/test-lib.sh: -------------------------------------------------------------------------------- 1 | ../common/test-lib.sh -------------------------------------------------------------------------------- /test/test-openshift.yaml: -------------------------------------------------------------------------------- 1 | ../common/test-openshift.yaml -------------------------------------------------------------------------------- /test/test_imagestreams_quickstart.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | import pytest 5 | 6 | from container_ci_suite.openshift import OpenShiftAPI 7 | from container_ci_suite.utils import check_variables 8 | 9 | 10 | if not check_variables(): 11 | print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") 12 | sys.exit(1) 13 | 14 | 15 | VERSION = os.getenv("VERSION") 16 | IMAGE_NAME = os.getenv("IMAGE_NAME") 17 | OS = os.getenv("OS") 18 | 19 | DEPLOYED_PGSQL_IMAGE = "quay.io/sclorg/postgresql-15-c9s" 20 | 21 | NODEJS_TAGS = { 22 | "rhel8": "-ubi8", 23 | "rhel9": "-ubi9" 24 | } 25 | NODEJS_TAG = NODEJS_TAGS.get(OS, None) 26 | PGSQL_IMAGE_TAG = f"postgresql:15-c9s" 27 | IMAGE_TAG = f"15-c9s" 28 | 29 | 30 | # Replacement with 'test_python_s2i_templates' 31 | class TestImagestreamsQuickstart: 32 | 33 | def setup_method(self): 34 | self.oc_api = OpenShiftAPI(pod_name_prefix="nodejs-example", version=VERSION, shared_cluster=True) 35 | assert self.oc_api.upload_image(DEPLOYED_PGSQL_IMAGE, PGSQL_IMAGE_TAG) 36 | 37 | def teardown_method(self): 38 | self.oc_api.delete_project() 39 | 40 | @pytest.mark.parametrize( 41 | "template", 42 | [ 43 | "nodejs.json", 44 | "nodejs-postgresql-persistent.json", 45 | ] 46 | ) 47 | def test_nodejs_template_inside_cluster(self, template): 48 | new_version = VERSION 49 | if "minimal" in VERSION: 50 | new_version = VERSION.replace("-minimal", "") 51 | service_name = "nodejs-example" 52 | if os == "rhel10": 53 | pytest.skip("Do NOT test on RHEL10 yet.") 54 | template_url = self.oc_api.get_raw_url_for_json( 55 | container="nodejs-ex", dir="openshift/templates", filename=template, branch="master" 56 | ) 57 | openshift_args = [ 58 | f"SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git", 59 | f"SOURCE_REPOSITORY_REF=master", 60 | f"NODEJS_VERSION={VERSION}", 61 | f"NAME={service_name}" 62 | ] 63 | if template != "nodejs.json": 64 | openshift_args = [ 65 | f"SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git", 66 | f"SOURCE_REPOSITORY_REF=master", 67 | f"POSTGRESQL_VERSION={IMAGE_TAG}", 68 | f"NODEJS_VERSION={VERSION}", 69 | f"NAME={service_name}", 70 | f"DATABASE_USER=testu", 71 | f"DATABASE_PASSWORD=testpwd", 72 | f"DATABASE_ADMIN_PASSWORD=testadminpwd" 73 | ] 74 | assert self.oc_api.imagestream_quickstart( 75 | imagestream_file="imagestreams/nodejs-rhel.json", 76 | template_file=template_url, 77 | image_name=IMAGE_NAME, 78 | name_in_template="nodejs", 79 | openshift_args=openshift_args 80 | ) 81 | assert self.oc_api.is_template_deployed(name_in_template=service_name) 82 | assert self.oc_api.check_response_inside_cluster( 83 | name_in_template=service_name, expected_output="Node.js Crud Application" 84 | ) 85 | 86 | -------------------------------------------------------------------------------- /test/test_latest_imagestreams.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | from pathlib import Path 5 | 6 | from container_ci_suite.imagestreams import ImageStreamChecker 7 | from container_ci_suite.utils import check_variables 8 | 9 | TEST_DIR = Path(os.path.abspath(os.path.dirname(__file__))) 10 | 11 | if not check_variables(): 12 | print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") 13 | sys.exit(1) 14 | 15 | VERSION = os.getenv("VERSION") 16 | 17 | 18 | class TestLatestImagestreams: 19 | 20 | def setup_method(self): 21 | self.isc = ImageStreamChecker(working_dir=TEST_DIR.parent) 22 | print(TEST_DIR.parent.parent) 23 | 24 | def test_latest_imagestream(self): 25 | self.latest_version = self.isc.get_latest_version() 26 | assert self.latest_version != "" 27 | self.isc.check_imagestreams(self.latest_version) 28 | -------------------------------------------------------------------------------- /test/test_nodejs_ex_standalone.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | import pytest 5 | 6 | from container_ci_suite.utils import check_variables 7 | from container_ci_suite.openshift import OpenShiftAPI 8 | 9 | if not check_variables(): 10 | print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") 11 | sys.exit(1) 12 | 13 | 14 | VERSION = os.getenv("VERSION") 15 | IMAGE_NAME = os.getenv("IMAGE_NAME") 16 | OS = os.getenv("TARGET") 17 | 18 | 19 | class TestNodeJSExTemplate: 20 | 21 | def setup_method(self): 22 | self.oc_api = OpenShiftAPI(pod_name_prefix="nodejs-testing", version=VERSION) 23 | 24 | def teardown_method(self): 25 | self.oc_api.delete_project() 26 | 27 | def test_nodejs_ex_template_inside_cluster(self): 28 | service_name = "nodejs-testing" 29 | assert self.oc_api.deploy_s2i_app( 30 | image_name=IMAGE_NAME, app=f"https://github.com/sclorg/nodejs-ex.git", 31 | context=".", 32 | service_name=service_name 33 | ) 34 | assert self.oc_api.is_template_deployed(name_in_template=service_name) 35 | assert self.oc_api.check_response_inside_cluster( 36 | name_in_template=service_name, expected_output="Node.js Crud Application" 37 | ) 38 | -------------------------------------------------------------------------------- /test/test_nodejs_ex_templates.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | import pytest 5 | from container_ci_suite.openshift import OpenShiftAPI 6 | from container_ci_suite.utils import check_variables 7 | 8 | if not check_variables(): 9 | print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") 10 | sys.exit(1) 11 | 12 | 13 | VERSION = os.getenv("VERSION") 14 | IMAGE_NAME = os.getenv("IMAGE_NAME") 15 | OS = os.getenv("TARGET") 16 | 17 | DEPLOYED_PGSQL_IMAGE = "quay.io/sclorg/postgresql-15-c9s" 18 | 19 | NODEJS_TAGS = { 20 | "rhel8": "-ubi8", 21 | "rhel9": "-ubi9" 22 | } 23 | NODEJS_TAG = NODEJS_TAGS.get(OS, None) 24 | PGSQL_IMAGE_NAME = f"postgresql:15-c9s" 25 | IMAGE_TAG = f"15-c9s" 26 | 27 | 28 | class TestDeployNodeJSExTemplate: 29 | 30 | def setup_method(self): 31 | self.oc_api = OpenShiftAPI(pod_name_prefix="nodejs-testing", version=VERSION) 32 | assert self.oc_api.upload_image(DEPLOYED_PGSQL_IMAGE, PGSQL_IMAGE_NAME) 33 | 34 | def teardown_method(self): 35 | self.oc_api.delete_project() 36 | 37 | @pytest.mark.parametrize( 38 | "template", 39 | [ 40 | "nodejs.json", 41 | "nodejs-postgresql-persistent.json", 42 | ] 43 | ) 44 | def test_nodejs_ex_template_inside_cluster(self, template): 45 | service_name = "nodejs-testing" 46 | if os == "rhel10": 47 | pytest.skip("Do NOT test on RHEL10 yet.") 48 | template_url = self.oc_api.get_raw_url_for_json( 49 | container="nodejs-ex", dir="openshift/templates", filename=template, branch="master" 50 | ) 51 | new_version = VERSION 52 | if "minimal" in VERSION: 53 | new_version = VERSION.replace("-minimal", "") 54 | openshift_args = [ 55 | "SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git", 56 | "SOURCE_REPOSITORY_REF=master", 57 | f"NODEJS_VERSION={new_version}", 58 | f"NAME={service_name}" 59 | ] 60 | if template != "nodejs.json": 61 | openshift_args = [ 62 | "SOURCE_REPOSITORY_URL=https://github.com/sclorg/nodejs-ex.git", 63 | "SOURCE_REPOSITORY_REF=master", 64 | f"POSTGRESQL_VERSION={IMAGE_TAG}", 65 | f"NODEJS_VERSION={new_version}", 66 | f"NAME={service_name}", 67 | "DATABASE_USER=testu", 68 | "DATABASE_PASSWORD=testpwd", 69 | "DATABASE_ADMIN_PASSWORD=testadminpwd" 70 | ] 71 | assert self.oc_api.deploy_template_with_image( 72 | image_name=IMAGE_NAME, 73 | template=template_url, 74 | name_in_template="nodejs", 75 | openshift_args=openshift_args 76 | 77 | ) 78 | assert self.oc_api.is_template_deployed(name_in_template=service_name) 79 | assert self.oc_api.check_response_inside_cluster( 80 | name_in_template=service_name, expected_output="Node.js Crud Application" 81 | ) 82 | -------------------------------------------------------------------------------- /test/test_nodejs_s2i_standalone.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | import pytest 5 | 6 | from container_ci_suite.utils import check_variables 7 | from container_ci_suite.openshift import OpenShiftAPI 8 | 9 | if not check_variables(): 10 | print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") 11 | sys.exit(1) 12 | 13 | 14 | VERSION = os.getenv("VERSION") 15 | IMAGE_NAME = os.getenv("IMAGE_NAME") 16 | OS = os.getenv("TARGET") 17 | 18 | 19 | class TestNodeJSExTemplate: 20 | 21 | def setup_method(self): 22 | self.oc_api = OpenShiftAPI(pod_name_prefix="nodejs-testing", version=VERSION) 23 | 24 | def teardown_method(self): 25 | self.oc_api.delete_project() 26 | 27 | def test_nodejs_ex_template_inside_cluster(self): 28 | service_name = "nodejs-testing" 29 | assert self.oc_api.deploy_s2i_app( 30 | image_name=IMAGE_NAME, app=f"https://github.com/sclorg/s2i-nodejs-container.git", 31 | context="test/test-app", 32 | service_name=service_name 33 | ) 34 | assert self.oc_api.is_template_deployed(name_in_template=service_name) 35 | assert self.oc_api.check_response_inside_cluster( 36 | name_in_template=service_name, expected_output="This is a node.js echo service" 37 | ) 38 | -------------------------------------------------------------------------------- /test/test_shared_helm_nodejs_application.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | import pytest 5 | from pathlib import Path 6 | 7 | from container_ci_suite.helm import HelmChartsAPI 8 | from container_ci_suite.utils import check_variables 9 | 10 | if not check_variables(): 11 | print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") 12 | sys.exit(1) 13 | 14 | test_dir = Path(os.path.abspath(os.path.dirname(__file__))) 15 | 16 | VERSION = os.getenv("VERSION") 17 | IMAGE_NAME = os.getenv("IMAGE_NAME") 18 | OS = os.getenv("TARGET") 19 | 20 | TAGS = { 21 | "rhel8": "-ubi8", 22 | "rhel9": "-ubi9" 23 | } 24 | TAG = TAGS.get(OS, None) 25 | 26 | 27 | class TestHelmNodeJSApplication: 28 | 29 | def setup_method(self): 30 | package_name = "redhat-nodejs-application" 31 | path = test_dir 32 | self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) 33 | self.hc_api.clone_helm_chart_repo( 34 | repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", 35 | subdir="charts/redhat" 36 | ) 37 | 38 | def teardown_method(self): 39 | self.hc_api.delete_project() 40 | 41 | def test_by_helm_test(self): 42 | self.hc_api.package_name = "redhat-nodejs-imagestreams" 43 | self.hc_api.helm_package() 44 | assert self.hc_api.helm_installation() 45 | self.hc_api.package_name = "redhat-nodejs-application" 46 | assert self.hc_api.helm_package() 47 | assert self.hc_api.helm_installation( 48 | values={ 49 | "nodejs": f"{VERSION}{TAG}", 50 | "namespace": self.hc_api.namespace 51 | } 52 | ) 53 | assert self.hc_api.is_s2i_pod_running(pod_name_prefix="nodejs-example") 54 | assert self.hc_api.test_helm_chart(expected_str=["Node.js Crud Application"]) 55 | -------------------------------------------------------------------------------- /test/test_shared_helm_nodejs_imagestreams.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | import pytest 5 | from pathlib import Path 6 | 7 | from container_ci_suite.helm import HelmChartsAPI 8 | from container_ci_suite.utils import check_variables 9 | 10 | if not check_variables(): 11 | print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") 12 | sys.exit(1) 13 | 14 | test_dir = Path(os.path.abspath(os.path.dirname(__file__))) 15 | 16 | 17 | class TestHelmRHELNodeJSImageStreams: 18 | 19 | def setup_method(self): 20 | package_name = "redhat-nodejs-imagestreams" 21 | path = test_dir 22 | self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) 23 | self.hc_api.clone_helm_chart_repo( 24 | repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", 25 | subdir="charts/redhat" 26 | ) 27 | 28 | def teardown_method(self): 29 | self.hc_api.delete_project() 30 | 31 | @pytest.mark.parametrize( 32 | "version,registry,expected", 33 | [ 34 | ("22-ubi9", "registry.redhat.io/ubi9/nodejs-22:latest", True), 35 | ("22-ubi9-minimal", "registry.redhat.io/ubi9/nodejs-22-minimal:latest", True), 36 | ("20-ubi9", "registry.redhat.io/ubi9/nodejs-20:latest", True), 37 | ("20-ubi9-minimal", "registry.redhat.io/ubi9/nodejs-20-minimal:latest", True), 38 | ("20-ubi8", "registry.redhat.io/ubi8/nodejs-20:latest", True), 39 | ("20-ubi8-minimal", "registry.redhat.io/ubi8/nodejs-20-minimal:latest", True), 40 | ("18-ubi9", "registry.redhat.io/ubi9/nodejs-18:latest", False), 41 | ("18-ubi9-minimal", "registry.redhat.io/ubi9/nodejs-18-minimal:latest", False), 42 | ("18-ubi8", "registry.redhat.io/ubi8/nodejs-18:latest", False), 43 | ("18-ubi8-minimal", "registry.redhat.io/ubi8/nodejs-18-minimal:latest", False), 44 | ], 45 | ) 46 | def test_package_imagestream(self, version, registry, expected): 47 | assert self.hc_api.helm_package() 48 | assert self.hc_api.helm_installation() 49 | assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected 50 | --------------------------------------------------------------------------------