Skip to content

Commit c282963

Browse files
committed
feat(Docker): Adding docker image for running
1 parent f4ae01e commit c282963

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,43 @@ jobs:
3636
uses: coverallsapp/github-action@master
3737
with:
3838
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
package:
40+
name: Package Application
41+
runs-on: ubuntu-latest
42+
needs:
43+
- build
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: actions/setup-node@v4
47+
with:
48+
# renovate: datasource=docker depName=node
49+
node-version: "22"
50+
- name: "Build Package"
51+
run: |
52+
npm run clean
53+
npm run build
54+
55+
- name: Write version vars
56+
run: |
57+
BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
58+
BRANCH=${GITHUB_REF_NAME#v}
59+
APP_VERSION=$(cat package.json | grep version| head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g')
60+
echo Version: $APP_VERSION
61+
echo "VERSION=$APP_VERSION" >> $GITHUB_ENV
62+
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
63+
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV
64+
65+
- name: Build Container Image
66+
id: build-image
67+
uses: redhat-actions/buildah-build@v2
68+
with:
69+
image: continuoussecuritytooling/ajv-cli
70+
tags: "latest next ${{env.APP_VERSION}} ${{env.APP_VERSION}}_rc"
71+
containerfiles: |
72+
./Dockerfile
73+
build-args: |
74+
BUILD_DATE=${{env.BUILD_DATE}}
75+
APP_VERSION=${{env.APP_VERSION}}
3976
4077
build-results:
4178
name: Build results

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM node:22.14.0-slim
2+
3+
ARG BUILD_DATE
4+
ARG APP_VERSION
5+
6+
LABEL org.opencontainers.image.authors='Martin Reinhardt (martin@m13t.de)' \
7+
org.opencontainers.image.created=$BUILD_DATE \
8+
org.opencontainers.image.version=$APP_VERSION \
9+
org.opencontainers.image.url='https://hub.docker.com/r/continuoussecuritytooling/ajv-cli' \
10+
org.opencontainers.image.documentation='https://github.com/ContinuousSecurityTooling/ajv-cli' \
11+
org.opencontainers.image.source='https://github.com/ContinuousSecurityTooling/ajv-cli.git' \
12+
org.opencontainers.image.licenses='MIT'
13+
14+
COPY dist/ docker_entrypoint.sh package-lock.json package.json /app
15+
16+
WORKDIR /app
17+
18+
RUN npm install --omit=dev &&\
19+
npm install -g ajv-formats &&\
20+
chown -R 1000:2000 /app
21+
22+
# apt update
23+
RUN apt-get update && apt-get -y upgrade &&\
24+
# clean up to slim image
25+
apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/
26+
27+
USER 1000
28+
29+
ENTRYPOINT ["/app/docker_entrypoint.sh"]

docker_entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
node index.js "$@"

0 commit comments

Comments
 (0)