Skip to content

Commit

Permalink
first_import
Browse files Browse the repository at this point in the history
  • Loading branch information
g0blin79 committed Mar 28, 2024
1 parent ce16a20 commit 2b2e7a9
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 0 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
name: CI Bmeme NG-CLI container images
on:
push:
branches:
- "*"
- "*/*"
- "**"
- "!main"

env:
registry: docker.io
repository: bmeme/ng-cli

jobs:

configure:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
-
name: Checkout to repository
uses: actions/checkout@v3
-
name: Set matrix data
id: set-matrix
run: echo "matrix=$(jq -c . < ./config.json)" >> $GITHUB_OUTPUT

build:
name: Build and test Bmeme NG-CLI container images using Docker
runs-on: ubuntu-latest
needs: configure
strategy:
matrix: ${{ fromJson(needs.configure.outputs.matrix) }}
steps:
-
name: Check out the codebase.
uses: actions/checkout@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Lint Dockerfile
id: lint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: ./Dockerfile
config: .hadolint.yaml
-
name: Build images
id: build
env:
NG_CLI_MAJOR_VERSION: ${{ matrix.ng_cli_major_version }}
NODE_MAJOR_VERSION: ${{ matrix.node_major_version }}
PRETTY_TAG: ${{ matrix.name }}
run: |
{
docker build \
--build-arg NODE_MAJOR_VERSION=${NODE_MAJOR_VERSION} \
--build-arg NG_CLI_MAJOR_VERSION=${NG_CLI_MAJOR_VERSION} \
-t ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} \
-f ./Dockerfile .;
}
-
name: Get NG_CLI_VERSION value
id: get-ng-cli-version
env:
NG_CLI_MAJOR_VERSION: ${{ matrix.ng_cli_major_version }}
NODE_MAJOR_VERSION: ${{ matrix.node_major_version }}
PRETTY_TAG: ${{ matrix.name }}
run: |
{
echo "ng_cli_version=$(docker run --rm ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} /bin/bash -c \
'cat /home/node/.ng_cli_version')" >> "$GITHUB_OUTPUT"; \
}
-
name: Tag images
id: tag
env:
NG_CLI_MAJOR_VERSION: ${{ matrix.ng_cli_major_version }}
NODE_MAJOR_VERSION: ${{ matrix.node_major_version }}
PRETTY_TAG: ${{ matrix.name }}
NG_CLI_VERSION: ${{ steps.get-ng-cli-version.outputs.ng_cli_version }}
run: |
{
docker tag ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} \
${{ env.registry}}/${{ env.repository }}:${NG_CLI_VERSION}-${NODE_MAJOR_VERSION}; \
if ${{ matrix.latest }}; then
docker tag ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} ${{ env.registry}}/${{ env.repository }}:latest; \
fi
}
-
name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
id: trivy
with:
image-ref: ${{ env.registry }}/${{ env.repository }}:${{ matrix.name }}
format: 'sarif'
exit-code: '0'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL'
output: 'trivy-results-${{ matrix.name }}.sarif'
-
name: Upload Trivy scan results to GitHub Security tab
id: trivy-upload
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results-${{ matrix.name }}.sarif'
-
name: Scan image
id: scan
uses: anchore/scan-action@v3
with:
image: ${{ env.registry }}/${{ env.repository }}:${{ matrix.name }}
severity-cutoff: critical
fail-build: false
-
name: upload Anchore scan SARIF report
id: scan-upload
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
92 changes: 92 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
name: Release Bmeme NG-CLI container images
on:
push:
branches:
- "main"
schedule:
- cron: 00 00 */7 * *

env:
registry: docker.io
repository: bmeme/ng-cli

jobs:

configure:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
-
name: Checkout to repository
uses: actions/checkout@v3
-
name: Set matrix data
id: set-matrix
run: echo "matrix=$(jq -c . < ./config.json)" >> $GITHUB_OUTPUT

build:
name: Build and push Bmeme NG-CLI container images
runs-on: ubuntu-latest
needs: configure
strategy:
matrix: ${{ fromJson(needs.configure.outputs.matrix) }}
steps:
-
name: Check out the codebase.
uses: actions/checkout@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build images
id: build
env:
NG_CLI_MAJOR_VERSION: ${{ matrix.ng_cli_major_version }}
NODE_MAJOR_VERSION: ${{ matrix.node_major_version }}
PRETTY_TAG: ${{ matrix.name }}
run: |
{
docker build \
--build-arg NODE_MAJOR_VERSION=${NODE_MAJOR_VERSION} \
--build-arg NG_CLI_MAJOR_VERSION=${NG_CLI_MAJOR_VERSION} \
-t ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} \
-f ./Dockerfile .;
}
-
name: Get NG_CLI_VERSION value
id: get-ng-cli-version
env:
NG_CLI_MAJOR_VERSION: ${{ matrix.ng_cli_major_version }}
NODE_MAJOR_VERSION: ${{ matrix.node_major_version }}
PRETTY_TAG: ${{ matrix.name }}
run: |
{
echo "ng_cli_version=$(docker run --rm ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} /bin/bash -c \
'cat /home/node/.ng_cli_version')" >> "$GITHUB_OUTPUT"; \
}
-
name: Tag and push images
id: tag
env:
NG_CLI_MAJOR_VERSION: ${{ matrix.ng_cli_major_version }}
NODE_MAJOR_VERSION: ${{ matrix.node_major_version }}
PRETTY_TAG: ${{ matrix.name }}
NG_CLI_VERSION: ${{ steps.get-ng-cli-version.outputs.ng_cli_version }}
run: |
{
docker tag ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} \
${{ env.registry}}/${{ env.repository }}:${NG_CLI_VERSION}-${NODE_MAJOR_VERSION}; \
docker push ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG}; \
docker push ${{ env.registry}}/${{ env.repository }}:${NG_CLI_VERSION}-${NODE_MAJOR_VERSION}; \
if ${{ matrix.latest }}; then
docker tag ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} ${{ env.registry}}/${{ env.repository }}:latest; \
docker push ${{ env.registry}}/${{ env.repository }}:latest
fi
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.idea
/.vscode
10 changes: 10 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ignored:
- DL3000
- DL3008
- DL3018
- DL4006
- SC1010
- SC2086

trustedRegistries:
- docker.io
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ARG NODE_MAJOR_VERSION
FROM node:${NODE_MAJOR_VERSION}-slim

ARG NG_CLI_MAJOR_VERSION
ENV NG_CLI_MAJOR_VERSION ${NG_CLI_MAJOR_VERSION}

RUN set -eux; \
apt-get update && apt-get install --no-install-recommends -y \
chromium \
ca-certificates; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*;

RUN npm install -g @angular/cli@${NG_CLI_MAJOR_VERSION}

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV SCULLY_PUPPETEER_EXECUTABLE_PATH '/usr/bin/chromium'

USER node

RUN INTERACTIVE=false ng version | grep 'Angular CLI' | awk -F: '{print $2}' | tr -d ' ' >> ${HOME}/.ng_cli_version

WORKDIR /home/node
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Bonsaimeme Srl

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
[![CI Bmeme NG-CLI container images](https://github.com/bmeme/docker-ng-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/bmeme/docker-ng-cli/actions/workflows/ci.yml)
# docker-ng-cli
29 changes: 29 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"include":
[
{
"name": "16-18",
"ng_cli_major_version": "16",
"node_major_version": "18",
"latest": true
},
{
"name": "16-16",
"ng_cli_major_version": "16",
"node_major_version": "16",
"latest": false
},
{
"name": "15-18",
"ng_cli_major_version": "15",
"node_major_version": "18",
"latest": false
},
{
"name": "15-16",
"ng_cli_major_version": "15",
"node_major_version": "16",
"latest": false
}
]
}

0 comments on commit 2b2e7a9

Please sign in to comment.