From e7003bcaee6370d60fb0f82a65591076bed04b17 Mon Sep 17 00:00:00 2001 From: Daniele Piaggesi Date: Fri, 29 Mar 2024 15:52:00 +0100 Subject: [PATCH] feat(stuff): Added Readme.md, changed tagging system, added ng-cli 17 --- .github/workflows/ci.yml | 14 +++---- .github/workflows/release.yml | 18 ++++----- Dockerfile | 16 +++++--- README.md | 71 ++++++++++++++++++++++++++++++++++- config.json | 14 ++++++- 5 files changed, 108 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1d2b42..54a8471 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,28 +67,28 @@ jobs: } - name: Get NG_CLI_VERSION value - id: get-ng-cli-version + id: get-versions 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"; \ + + echo "node_version=$(docker run --rm ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} /bin/bash -c \ + 'cat /home/node/.node_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 }} + NODE_VERSION: ${{ steps.get-versions.outputs.node_version }} PRETTY_TAG: ${{ matrix.name }} - NG_CLI_VERSION: ${{ steps.get-ng-cli-version.outputs.ng_cli_version }} + NG_CLI_VERSION: ${{ steps.get-versions.outputs.ng_cli_version }} run: | { docker tag ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} \ - ${{ env.registry}}/${{ env.repository }}:${NG_CLI_VERSION}-${NODE_MAJOR_VERSION}; \ + ${{ env.registry}}/${{ env.repository }}:${NG_CLI_VERSION}-${NODE_VERSION}; \ if ${{ matrix.latest }}; then docker tag ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} ${{ env.registry}}/${{ env.repository }}:latest; \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 20c6ecb..cb7c3c0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,32 +58,32 @@ jobs: -f ./Dockerfile .; } - - name: Get NG_CLI_VERSION value - id: get-ng-cli-version + name: Get NG and Node complete version values + id: get-versions 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"; \ + + echo "node_version=$(docker run --rm ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} /bin/bash -c \ + 'cat /home/node/.node_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 }} + NODE_VERSION: ${{ steps.get-versions.outputs.ng_cli_version }} PRETTY_TAG: ${{ matrix.name }} - NG_CLI_VERSION: ${{ steps.get-ng-cli-version.outputs.ng_cli_version }} + NG_CLI_VERSION: ${{ steps.get-versions.outputs.node_version }} run: | { docker tag ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} \ - ${{ env.registry}}/${{ env.repository }}:${NG_CLI_VERSION}-${NODE_MAJOR_VERSION}; \ + ${{ env.registry}}/${{ env.repository }}:${NG_CLI_VERSION}-${NODE_VERSION}; \ docker push ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG}; \ - docker push ${{ env.registry}}/${{ env.repository }}:${NG_CLI_VERSION}-${NODE_MAJOR_VERSION}; \ + docker push ${{ env.registry}}/${{ env.repository }}:${NG_CLI_VERSION}-${NODE_VERSION}; \ if ${{ matrix.latest }}; then docker tag ${{ env.registry}}/${{ env.repository }}:${PRETTY_TAG} ${{ env.registry}}/${{ env.repository }}:latest; \ diff --git a/Dockerfile b/Dockerfile index 71e9dde..aa1baa6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,15 +8,19 @@ 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} + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*; \ + \ + mkdir -p /app; \ + chown -R node:node /app ; \ + \ + npm install -g @angular/cli@${NG_CLI_MAJOR_VERSION}; \ + \ + INTERACTIVE=false ng version | grep 'Angular CLI' | awk -F: '{print $2}' | tr -d ' ' >> /home/node/.ng_cli_version; \ + node -v | awk -v char="v" '{gsub(char,""); print}' >> /home/node/.node_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 \ No newline at end of file +WORKDIR /app \ No newline at end of file diff --git a/README.md b/README.md index 5431d51..30b892a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,69 @@ -[![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 +[![Release Bmeme NG-CLI container images](https://github.com/bmeme/docker-ng-cli/actions/workflows/release.yml/badge.svg?branch=main)](https://github.com/bmeme/docker-ng-cli/actions/workflows/release.yml) +[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity) +[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/) + +NG-CLI packaged by Bmeme +=========== + +This image provides a node container with NG CLI installed and support to build static Angular sites with [Scully](https://scully.io/). + +## What is contained in the images +- Angular CLI, of course +- Chromium + +## Tagging policy +This repository contains a single "dynamic" Dockerfile that receives as arguments the major version of Node and the major version of the NG CLI. Consequently, the resulting image tag consists of a first number identifying the CLI version and a second number identifying the Node version. During the build process, the complete version of the NG CLI is extracted, allowing images to be tagged with the full NG CLI version (major-minor-patch). The image build process is automated on every merge to the main branch and scheduled to run at least once a week, ensuring a continuous refresh of images for the same major releases. + +## Supported NG-CLI and Node versions +- NG-CLI `17.x.x` with Node `18.x.x` and `20.x.x` +- NG-CLI `16.x.x` with Node `18.x.x` and `16.x.x` +- NG-CLI `15.x.x` with Node `18.x.x` and `16.x.x` + +Get a look here: https://hub.docker.com/r/bmeme/ng-cli/tags + +## How to use this image + +### Manually +Creating your Angular environment an starting your Angular application is really simple: + +```shell +docker run --rm -v "$PWD":/app bmeme/ng-cli ng new myangularapp + +cd myangularapp +docker run --rm -v "$PWD":/app bmeme/ng-cli ng build + +docker run --rm -p 4200:4200 -v "$PWD":/app bmeme/ng-cli ng serve --host 0.0.0.0 +``` + +### Using a Dockerfile +```dockerfile +FROM bmeme/ng-cli:latest +COPY src/ /app + +CMD ['ng', 'serve', '--host', '0.0.0.0'] +``` +Where `src/` is the directory containing your Angular app. + +Then, run the commands to build and run the Docker image: +```shell +$ docker build -t myangularcontainer:latest . +$ docker run -d --name myangularcontainer -p 4200:4200 myangularcontainer:latest +``` +## Using `docker compose` + +```yaml +services: + php: + image: bmeme/ng-cli:latest + ports: + - 4200:4200 + volumes: + - .:/app + command: ng serve --host 0.0.0.0 +``` + +## Credits +This project is a contribution of [Bmeme :: The Digital Factory](http://www.bmeme.com). +This library is actually maintained by [Daniele Piaggesi](https://github.com/g0blin79) and +[Roberto Mariani](https://github.com/jean-louis). +Any other contribution will be really appreciated. \ No newline at end of file diff --git a/config.json b/config.json index e8ea065..be3e120 100644 --- a/config.json +++ b/config.json @@ -1,11 +1,23 @@ { "include": [ + { + "name": "17-20", + "ng_cli_major_version": "17", + "node_major_version": "20", + "latest": true + }, + { + "name": "17-18", + "ng_cli_major_version": "17", + "node_major_version": "18", + "latest": false + }, { "name": "16-18", "ng_cli_major_version": "16", "node_major_version": "18", - "latest": true + "latest": false }, { "name": "16-16",