Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
lib
19 changes: 19 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ jobs:
name: code-coverage-report
path: coverage/**

build-docker:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: lint dockerfile
uses: luke142367/[email protected]
with:
target: Dockerfile
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/[email protected]
- name: build docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
tags: ${{ secrets.DOCKERHUB_USERNAME }}/linux-top-parser:latest

code-analysis:
runs-on: ubuntu-latest
needs: build
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/release-and-publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- major

env:
GITHUB_REGISTRY: ghcr.io
NODE_VERSION: 18.x

jobs:
Expand Down Expand Up @@ -72,3 +73,19 @@ jobs:
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

- name: log in to the container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/[email protected]
- name: publish docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ env.GITHUB_REGISTRY }}/sweetim/linux-top-parser:${{ steps.get_latest_git_tag.outputs.latest_git_tag }}
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:18-alpine as builder

WORKDIR /app
COPY ./src ./src
COPY package.json LICENSE ./
RUN npm ci
RUN npm run build

FROM node:18-alpine

RUN addgroup -S user \
&& adduser -S user -G user

WORKDIR /app
COPY --from=builder /app/package.json /app/LICENSE ./
COPY --from=builder /app/lib ./lib
RUN npm install --production

USER user

CMD ["node", "./lib/bin.js"]