Skip to content

Commit

Permalink
Setup docker build with download npm from the registry + CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
alagishev committed Jan 22, 2025
1 parent 38b68e8 commit 309ea7c
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 28 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Frontend & Docker CI Workflow

on:
release:
types: [created]
push:
branches:
- main
- release
- develop
- feature/*
delete:
branches:
- release
- feature/*

jobs:
call-frontend-ci-workflow:
uses: netcracker/qubership-apihub-ci/.github/workflows/frontend-ci.yaml@main
call-docker-ci-workflow:
needs: call-frontend-ci-workflow
uses: netcracker/qubership-apihub-ci/.github/workflows/docker-ci.yml@main
with:
name: qubership-apihub-build-task-consumer
file: Dockerfile
context: ""
platforms: linux/amd64,linux/arm64
labels: |
maintainer=qubership
qubership-apihub-build-task-consumer-package-version=${{ needs.jobs.call-frontend-ci-workflow.outputs.package_version }}
secrets:
NPMRC: ${{ secrets.NPMRC }}
17 changes: 0 additions & 17 deletions .github/workflows/frontend-ci.yaml

This file was deleted.

15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
FROM node:20
FROM docker.io/node:20

ARG TAG=dev

WORKDIR /usr/src/app

ADD .npmrc .npmrc
COPY package*.json ./
RUN npm ci
RUN apt-get update && apt-get install -y jq && rm -rf /var/lib/apt/lists/*


ADD dist dist
RUN --mount=type=secret,id=npmrc,target=.npmrc mv $(npm pack @netcracker/qubership-apihub-build-task-consumer@"$TAG") qubership-apihub-build-task-consumer.tgz
RUN tar zxvf ./qubership-apihub-build-task-consumer.tgz && mv ./package/dist dist
RUN --mount=type=secret,id=npmrc,target=.npmrc mv ./package/package.json package.json && npm install --production

USER 10001

CMD [ "node", "--max-old-space-size=3100", "--max-semi-space-size=32", "dist/main" ]
CMD [ "node", "--max-old-space-size=3100", "--max-semi-space-size=32", "dist/main" ]
12 changes: 12 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM docker.io/node:20

WORKDIR /usr/src/app

ADD .npmrc .npmrc
COPY package*.json ./
RUN npm ci
ADD dist dist

USER 10001

CMD [ "node", "--max-old-space-size=3100", "--max-semi-space-size=32", "dist/main" ]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ NodeJS microservice for APIHUB Package versions builds.
$ npm
```

## Building the app locally

```bash
npm install
npm run build
```

For build docker image rename file `Dockerfile.local` -> `Dockerfile` and execute

```bash
podman build .
```


## Running the app

```bash
Expand Down
7 changes: 3 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"adm-zip": "^0.5.10",
"dotenv": "^16.0.3",
"form-data": "^4.0.0",
"openapi-types": "^12.1.0",
"js-yaml": "4.1.0",
"jszip": "^3.10.1",
"reflect-metadata": "^0.1.13",
Expand All @@ -58,7 +59,6 @@
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.0.0",
"jest": "29.5.0",
"openapi-types": "^12.1.0",
"parse-multipart-data": "^1.5.0",
"prettier": "2.6.0",
"rimraf": "3.0.2",
Expand Down

0 comments on commit 309ea7c

Please sign in to comment.