Compare commits
90 Commits
ab337e6b1b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
fa9bec5af4
|
|||
|
4521bed92d
|
|||
|
9118543a9c
|
|||
|
68f89a42a8
|
|||
|
8443f3a779
|
|||
|
c21a9a84d9
|
|||
|
77f01ae00f
|
|||
|
272046fb56
|
|||
|
587c95e246
|
|||
|
6d84a83350
|
|||
|
46bb646903
|
|||
|
86135fbcba
|
|||
|
8e900dc8c8
|
|||
|
ed50b3d219
|
|||
|
bc79a96076
|
|||
|
8c7b00f746
|
|||
|
bd7ebc9c1b
|
|||
|
120738412f
|
|||
|
a231ada791
|
|||
|
97bc55e0af
|
|||
|
e55dce9e43
|
|||
|
4232e490b7
|
|||
|
|
1aa40a6d75 | ||
|
939c70e7df
|
|||
|
d4656630db
|
|||
|
|
c58626d017 | ||
|
|
a3144ab5b7 | ||
|
|
dbcd25c55e | ||
|
|
31484e82ab | ||
|
|
8e29d340c7 | ||
|
|
10986cac4b | ||
|
|
6008b44edb | ||
|
|
e93c62f308 | ||
|
|
8518e07b8f | ||
|
|
ab5c008846 | ||
|
|
4de38b0b08 | ||
|
453e318817
|
|||
|
b2b359b63b
|
|||
|
a030476374
|
|||
|
398ed50e13
|
|||
|
4eb9a8d71d
|
|||
|
f9d2884859
|
|||
|
4a16436000
|
|||
|
c4abd19af5
|
|||
|
019e21a5c3
|
|||
|
94f4692dc8
|
|||
|
cfed0f429f
|
|||
|
626db1fa31
|
|||
|
16c7e3226c
|
|||
|
067bff735c
|
|||
|
4f701002de
|
|||
|
ab35597839
|
|||
|
d82a5ebbe5
|
|||
|
5ec58f4b11
|
|||
|
5cca0a45e6
|
|||
|
7bb5b26edd
|
|||
|
b9785f9653
|
|||
|
e50d1d78dc
|
|||
|
60b0991dd3
|
|||
|
ecb577f655
|
|||
|
d5e9587e42
|
|||
|
302f400c39
|
|||
|
a3023036f8
|
|||
|
c57953c52d
|
|||
|
ca6432bdc7
|
|||
|
213a15cb3f
|
|||
|
cb5d8ace85
|
|||
|
|
d3f391d0d3 | ||
|
|
4184035a4a | ||
|
e22f13c105
|
|||
|
a3d4d2160c
|
|||
|
71a598cabf
|
|||
|
ec41473af3
|
|||
|
|
db3b875005 | ||
|
|
82b78116e9 | ||
| 9987810cca | |||
| f8d8671ef2 | |||
| c6ecb4cc4b | |||
| af96b1c305 | |||
| d5c75e8644 | |||
|
|
53e7af0f20 | ||
|
|
336f5b69a5 | ||
| f696a468d6 | |||
| 4d07c0e5fa | |||
| 4bc23af526 | |||
| 418adc0abd | |||
| 83431e02a9 | |||
| 481c916179 | |||
| b459c402a5 | |||
| 4f71406de2 |
60
.github/workflows/codacy.yml
vendored
Normal file
60
.github/workflows/codacy.yml
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# This workflow uses actions that are not certified by GitHub.
|
||||||
|
# They are provided by a third-party and are governed by
|
||||||
|
# separate terms of service, privacy policy, and support
|
||||||
|
# documentation.
|
||||||
|
|
||||||
|
# This workflow checks out code, performs a Codacy security scan
|
||||||
|
# and integrates the results with the
|
||||||
|
# GitHub Advanced Security code scanning feature. For more information on
|
||||||
|
# the Codacy security scan action usage and parameters, see
|
||||||
|
# https://github.com/codacy/codacy-analysis-cli-action.
|
||||||
|
# For more information on Codacy Analysis CLI in general, see
|
||||||
|
# https://github.com/codacy/codacy-analysis-cli.
|
||||||
|
|
||||||
|
name: Codacy Security Scan
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ main ]
|
||||||
|
schedule:
|
||||||
|
- cron: '44 1 * * 2'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
codacy-security-scan:
|
||||||
|
permissions:
|
||||||
|
contents: read # for actions/checkout to fetch code
|
||||||
|
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
|
||||||
|
name: Codacy Security Scan
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Checkout the repository to the GitHub Actions runner
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
|
||||||
|
- name: Run Codacy Analysis CLI
|
||||||
|
uses: codacy/codacy-analysis-cli-action@db33ad5cfab49143adf0db6e890cf4bb9fb37b1c
|
||||||
|
with:
|
||||||
|
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
|
||||||
|
# You can also omit the token and run the tools that support default configurations
|
||||||
|
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||||
|
verbose: true
|
||||||
|
output: results.sarif
|
||||||
|
format: sarif
|
||||||
|
# Adjust severity of non-security issues
|
||||||
|
gh-code-scanning-compat: true
|
||||||
|
# Force 0 exit code to allow SARIF file generation
|
||||||
|
# This will handover control about PR rejection to the GitHub side
|
||||||
|
max-allowed-issues: 2147483647
|
||||||
|
|
||||||
|
# Upload the SARIF file generated in the previous step
|
||||||
|
- name: Upload SARIF results file
|
||||||
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
|
with:
|
||||||
|
sarif_file: results.sarif
|
||||||
10
.github/workflows/docker-publish.yml
vendored
10
.github/workflows/docker-publish.yml
vendored
@@ -2,8 +2,7 @@ name: Docker CI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [ main ]
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
@@ -11,17 +10,16 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_HUB_SECRET }}
|
password: ${{ secrets.DOCKER_HUB_SECRET }}
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Build and Push from Makefile
|
name: Build and Push from Makefile
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
48
.github/workflows/snyk-container.yml
vendored
Normal file
48
.github/workflows/snyk-container.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# This workflow uses actions that are not certified by GitHub.
|
||||||
|
# They are provided by a third-party and are governed by
|
||||||
|
# separate terms of service, privacy policy, and support
|
||||||
|
# documentation.
|
||||||
|
|
||||||
|
# A sample workflow which checks out the code, builds a container
|
||||||
|
# image using Docker and scans that image for vulnerabilities using
|
||||||
|
# Snyk. The results are then uploaded to GitHub Security Code Scanning
|
||||||
|
#
|
||||||
|
# For more examples, including how to limit scans to only high-severity
|
||||||
|
# issues, monitor images for newly disclosed vulnerabilities in Snyk and
|
||||||
|
# fail PR checks for new vulnerabilities, see https://github.com/snyk/actions/
|
||||||
|
|
||||||
|
name: Snyk Container
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ main ]
|
||||||
|
schedule:
|
||||||
|
- cron: '19 16 * * 0'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
snyk:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Build a Docker image
|
||||||
|
run: docker build -t your/image-to-test .
|
||||||
|
- name: Run Snyk to check Docker image for vulnerabilities
|
||||||
|
# Snyk can be used to break the build when it detects vulnerabilities.
|
||||||
|
# In this case we want to upload the issues to GitHub Code Scanning
|
||||||
|
continue-on-error: true
|
||||||
|
uses: snyk/actions/docker@806182742461562b67788a64410098c9d9b96adb
|
||||||
|
env:
|
||||||
|
# In order to use the Snyk Action you will need to have a Snyk API token.
|
||||||
|
# More details in https://github.com/snyk/actions#getting-your-snyk-token
|
||||||
|
# or you can signup for free at https://snyk.io/login
|
||||||
|
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
||||||
|
with:
|
||||||
|
image: your/image-to-test
|
||||||
|
args: --file=Dockerfile
|
||||||
|
- name: Upload result to GitHub Code Scanning
|
||||||
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
|
with:
|
||||||
|
sarif_file: snyk.sarif
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -0,0 +1 @@
|
|||||||
|
.vscode/
|
||||||
110
Dockerfile
110
Dockerfile
@@ -1,103 +1,21 @@
|
|||||||
FROM cubetiq/calpine-os-linux:latest
|
FROM cubetiq/calpine-node:slim
|
||||||
LABEL maintainer="sombochea@cubetiqs.com"
|
LABEL maintainer="sombochea@cubetiqs.com"
|
||||||
|
|
||||||
# Build with root access
|
# Install PNPM
|
||||||
USER root
|
RUN npm install -g pnpm@latest
|
||||||
|
|
||||||
ENV NODE_VERSION 14.16.0
|
# Update NPM package
|
||||||
ENV USER_UID 1001
|
RUN npm install -g npm@latest
|
||||||
|
|
||||||
RUN addgroup -g ${USER_UID} node \
|
# Install yarn from npm package
|
||||||
&& adduser -u ${USER_UID} -G node -s /bin/sh -D node \
|
RUN npm install -g yarn@latest --force
|
||||||
&& apk add --no-cache \
|
|
||||||
libstdc++ \
|
|
||||||
&& apk add --no-cache --virtual .build-deps \
|
|
||||||
curl \
|
|
||||||
&& ARCH= && alpineArch="$(apk --print-arch)" \
|
|
||||||
&& case "${alpineArch##*-}" in \
|
|
||||||
x86_64) \
|
|
||||||
ARCH='x64' \
|
|
||||||
CHECKSUM="53cd618bd0cd387d79e954383d67b540ebfbefee9e261800eefff60e1bf38644" \
|
|
||||||
;; \
|
|
||||||
*) ;; \
|
|
||||||
esac \
|
|
||||||
&& if [ -n "${CHECKSUM}" ]; then \
|
|
||||||
set -eu; \
|
|
||||||
curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \
|
|
||||||
echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \
|
|
||||||
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
|
|
||||||
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs; \
|
|
||||||
else \
|
|
||||||
echo "Building from source" \
|
|
||||||
# backup build
|
|
||||||
&& apk add --no-cache --virtual .build-deps-full \
|
|
||||||
binutils-gold \
|
|
||||||
g++ \
|
|
||||||
gcc \
|
|
||||||
gnupg \
|
|
||||||
libgcc \
|
|
||||||
linux-headers \
|
|
||||||
make \
|
|
||||||
python3 \
|
|
||||||
# gpg keys listed at https://github.com/nodejs/node#release-keys
|
|
||||||
&& for key in \
|
|
||||||
4ED778F539E3634C779C87C6D7062848A1AB005C \
|
|
||||||
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
|
|
||||||
74F12602B6F1C4E913FAA37AD3A89613643B6201 \
|
|
||||||
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
|
|
||||||
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
|
|
||||||
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
|
|
||||||
C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
|
|
||||||
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
|
|
||||||
A48C2BEE680E841632CD4E44F07496B3EB3C1762 \
|
|
||||||
108F52B48DB57BB0CC439B2997B01419BD92F80A \
|
|
||||||
B9E2F5981AA6E0CD28160D9FF13993A75599653C \
|
|
||||||
; do \
|
|
||||||
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
|
|
||||||
gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
|
|
||||||
gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
|
|
||||||
done \
|
|
||||||
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \
|
|
||||||
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
|
|
||||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
|
||||||
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
|
|
||||||
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
|
|
||||||
&& cd "node-v$NODE_VERSION" \
|
|
||||||
&& ./configure \
|
|
||||||
&& make -j$(getconf _NPROCESSORS_ONLN) V= \
|
|
||||||
&& make install \
|
|
||||||
&& apk del .build-deps-full \
|
|
||||||
&& cd .. \
|
|
||||||
&& rm -Rf "node-v$NODE_VERSION" \
|
|
||||||
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \
|
|
||||||
fi \
|
|
||||||
&& rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \
|
|
||||||
&& apk del .build-deps \
|
|
||||||
# smoke tests
|
|
||||||
&& node --version \
|
|
||||||
&& npm --version
|
|
||||||
|
|
||||||
ENV YARN_VERSION 1.22.5
|
# Checking packages version
|
||||||
|
RUN echo "NODE: $(node --version)" \
|
||||||
RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \
|
&& echo "NPM: $(npm --version)" \
|
||||||
&& for key in \
|
&& echo "NPX: $(npx --version)" \
|
||||||
6A010C5166006599AA17F08146C2130DFD2497F5 \
|
&& echo "YARN: $(yarn --version)" \
|
||||||
; do \
|
&& echo "PNPM: $(pnpm --version)"
|
||||||
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
|
|
||||||
gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
|
|
||||||
gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
|
|
||||||
done \
|
|
||||||
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
|
|
||||||
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
|
|
||||||
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
|
|
||||||
&& mkdir -p /opt \
|
|
||||||
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
|
|
||||||
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
|
|
||||||
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
|
|
||||||
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
|
|
||||||
&& apk del .build-deps-yarn \
|
|
||||||
# smoke test
|
|
||||||
&& yarn --version
|
|
||||||
|
|
||||||
COPY entrypoint.sh /usr/local/bin/
|
COPY entrypoint.sh /usr/local/bin/
|
||||||
|
|
||||||
@@ -105,4 +23,4 @@ RUN chmod +x /usr/local/bin/entrypoint.sh
|
|||||||
|
|
||||||
ENTRYPOINT ["entrypoint.sh"]
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
|
|
||||||
CMD [ "node" ]
|
CMD [ "node" ]
|
||||||
|
|||||||
111
Dockerfile.16-15-0
Normal file
111
Dockerfile.16-15-0
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
FROM cubetiq/calpine-os-linux:latest
|
||||||
|
LABEL maintainer="sombochea@cubetiqs.com"
|
||||||
|
|
||||||
|
# Build with root access
|
||||||
|
USER root
|
||||||
|
|
||||||
|
ENV NODE_VERSION 16.15.0
|
||||||
|
ENV NODE_SHA256 4db62cabc0647fc18f537ed10b5573f3c23ffb4d4434e40713e7e472f1ed4e55
|
||||||
|
ENV USER_UID 1001
|
||||||
|
|
||||||
|
RUN addgroup -g ${USER_UID} node \
|
||||||
|
&& adduser -u ${USER_UID} -G node -s /bin/sh -D node \
|
||||||
|
&& apk add --no-cache \
|
||||||
|
libstdc++ \
|
||||||
|
&& apk add --no-cache --virtual .build-deps \
|
||||||
|
curl \
|
||||||
|
&& ARCH= && alpineArch="$(apk --print-arch)" \
|
||||||
|
&& case "${alpineArch##*-}" in \
|
||||||
|
x86_64) \
|
||||||
|
ARCH='x64' \
|
||||||
|
CHECKSUM=$NODE_SHA256 \
|
||||||
|
;; \
|
||||||
|
*) ;; \
|
||||||
|
esac \
|
||||||
|
&& if [ -n "${CHECKSUM}" ]; then \
|
||||||
|
set -eu; \
|
||||||
|
DL_ROOT="https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \
|
||||||
|
echo "Downloading Node.js from ${DL_ROOT}"; \
|
||||||
|
curl -fsSLO --compressed $DL_ROOT; \
|
||||||
|
echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \
|
||||||
|
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
|
||||||
|
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs; \
|
||||||
|
else \
|
||||||
|
echo "Building from source" \
|
||||||
|
# backup build
|
||||||
|
&& apk add --no-cache --virtual .build-deps-full \
|
||||||
|
binutils-gold \
|
||||||
|
g++ \
|
||||||
|
gcc \
|
||||||
|
gnupg \
|
||||||
|
libgcc \
|
||||||
|
linux-headers \
|
||||||
|
make \
|
||||||
|
python3 \
|
||||||
|
# gpg keys listed at https://github.com/nodejs/node#release-keys
|
||||||
|
&& for key in \
|
||||||
|
4ED778F539E3634C779C87C6D7062848A1AB005C \
|
||||||
|
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
|
||||||
|
74F12602B6F1C4E913FAA37AD3A89613643B6201 \
|
||||||
|
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
|
||||||
|
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
|
||||||
|
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
|
||||||
|
C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
|
||||||
|
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
|
||||||
|
A48C2BEE680E841632CD4E44F07496B3EB3C1762 \
|
||||||
|
108F52B48DB57BB0CC439B2997B01419BD92F80A \
|
||||||
|
B9E2F5981AA6E0CD28160D9FF13993A75599653C \
|
||||||
|
; do \
|
||||||
|
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
|
||||||
|
gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
|
||||||
|
gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
|
||||||
|
done \
|
||||||
|
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \
|
||||||
|
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
|
||||||
|
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||||
|
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
|
||||||
|
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
|
||||||
|
&& cd "node-v$NODE_VERSION" \
|
||||||
|
&& ./configure \
|
||||||
|
&& make -j$(getconf _NPROCESSORS_ONLN) V= \
|
||||||
|
&& make install \
|
||||||
|
&& apk del .build-deps-full \
|
||||||
|
&& cd .. \
|
||||||
|
&& rm -Rf "node-v$NODE_VERSION" \
|
||||||
|
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \
|
||||||
|
fi \
|
||||||
|
&& rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \
|
||||||
|
&& apk del .build-deps \
|
||||||
|
# smoke tests
|
||||||
|
&& node --version \
|
||||||
|
&& npm --version
|
||||||
|
|
||||||
|
ENV YARN_VERSION 1.22.18
|
||||||
|
|
||||||
|
RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \
|
||||||
|
&& for key in \
|
||||||
|
6A010C5166006599AA17F08146C2130DFD2497F5 \
|
||||||
|
; do \
|
||||||
|
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
|
||||||
|
gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
|
||||||
|
gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
|
||||||
|
done \
|
||||||
|
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
|
||||||
|
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
|
||||||
|
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
|
||||||
|
&& mkdir -p /opt \
|
||||||
|
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
|
||||||
|
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
|
||||||
|
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
|
||||||
|
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
|
||||||
|
&& apk del .build-deps-yarn \
|
||||||
|
# smoke test
|
||||||
|
&& yarn --version
|
||||||
|
|
||||||
|
COPY entrypoint.sh /usr/local/bin/
|
||||||
|
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
|
|
||||||
|
CMD [ "node" ]
|
||||||
12
Dockerfile.git
Normal file
12
Dockerfile.git
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM cubetiq/calpine-node:latest
|
||||||
|
LABEL maintainer="sombochea@cubetiqs.com"
|
||||||
|
|
||||||
|
RUN apk update && apk add --no-cache git
|
||||||
|
|
||||||
|
COPY entrypoint.sh /usr/local/bin/
|
||||||
|
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
|
|
||||||
|
CMD [ "node" ]
|
||||||
18
Dockerfile.slim
Normal file
18
Dockerfile.slim
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
FROM node:18-alpine
|
||||||
|
LABEL maintainer="sombochea@cubetiqs.com"
|
||||||
|
|
||||||
|
# Update NPM package
|
||||||
|
RUN npm install -g npm@latest
|
||||||
|
|
||||||
|
# Checking packages version
|
||||||
|
RUN echo "NODE: $(node --version)" \
|
||||||
|
&& echo "NPM: $(npm --version)" \
|
||||||
|
&& echo "NPX: $(npx --version)"
|
||||||
|
|
||||||
|
COPY entrypoint.sh /usr/local/bin/
|
||||||
|
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
|
|
||||||
|
CMD [ "node" ]
|
||||||
35
Makefile
35
Makefile
@@ -1,7 +1,14 @@
|
|||||||
DOCKER_IMAGE=cubetiq/calpine-node
|
DOCKER_IMAGE=cubetiq/calpine-node
|
||||||
DOCKER_IMAGE_NAME=${DOCKER_IMAGE}:14
|
DOCKER_IMAGE_GIT=cubetiq/calpine-node-git
|
||||||
|
DOCKER_IMAGE_NAME=${DOCKER_IMAGE}:18
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
@echo 'Starting docker build with slim'
|
||||||
|
docker build -f Dockerfile.slim . -t ${DOCKER_IMAGE}:slim
|
||||||
|
|
||||||
|
@echo 'Starting docker push with slim'
|
||||||
|
docker push ${DOCKER_IMAGE}:slim
|
||||||
|
|
||||||
@echo 'Starting docker build'
|
@echo 'Starting docker build'
|
||||||
docker build . -t ${DOCKER_IMAGE}
|
docker build . -t ${DOCKER_IMAGE}
|
||||||
|
|
||||||
@@ -10,4 +17,28 @@ build:
|
|||||||
docker push ${DOCKER_IMAGE}
|
docker push ${DOCKER_IMAGE}
|
||||||
docker push ${DOCKER_IMAGE_NAME}
|
docker push ${DOCKER_IMAGE_NAME}
|
||||||
|
|
||||||
.PHONY:build
|
@echo 'Starting docker build with git'
|
||||||
|
docker build -f Dockerfile.git . -t ${DOCKER_IMAGE_GIT}
|
||||||
|
|
||||||
|
@echo 'Starting docker push with git'
|
||||||
|
docker push ${DOCKER_IMAGE_GIT}
|
||||||
|
|
||||||
|
.PHONY:build
|
||||||
|
|
||||||
|
test:
|
||||||
|
@echo 'Starting docker build with slim'
|
||||||
|
docker build -f Dockerfile.slim . -t ${DOCKER_IMAGE}:slim
|
||||||
|
|
||||||
|
@echo 'Starting docker build'
|
||||||
|
docker build . -t ${DOCKER_IMAGE}
|
||||||
|
|
||||||
|
@echo 'Starting docker run with slim'
|
||||||
|
docker run --rm -it ${DOCKER_IMAGE}:slim --version
|
||||||
|
|
||||||
|
@echo 'Starting docker run'
|
||||||
|
docker run --rm -it ${DOCKER_IMAGE} --version
|
||||||
|
|
||||||
|
@echo 'Starting docker run with git'
|
||||||
|
docker run --rm -it ${DOCKER_IMAGE_GIT} --version
|
||||||
|
|
||||||
|
.PHONY:test
|
||||||
35
README.md
35
README.md
@@ -1,24 +1,45 @@
|
|||||||
# CUBETIQ Alpine OS Linux with Nodejs 14
|
# CUBETIQ Alpine OS Linux with Nodejs 18
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
- CUBETIQ Alpine OS Linux (3.13.3)
|
- CUBETIQ Alpine OS Linux (Latest)
|
||||||
- Nodejs 14 (14.16.0)
|
- Nodejs 18
|
||||||
|
- PNPM 8 (8.7.5)
|
||||||
|
|
||||||
# [Docker Hub](https://hub.docker.com/r/cubetiq/calpine-node)
|
# [Docker Hub](https://hub.docker.com/r/cubetiq/calpine-node)
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker push cubetiq/calpine-node:14
|
docker push cubetiq/calpine-node:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker run --rm -it cubetiq/calpine-node:14 /bin/sh
|
docker run --rm -it cubetiq/calpine-node:latest /bin/sh
|
||||||
|
```
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
```Dockerfile
|
||||||
|
FROM cubetiq/calpine-node:latest
|
||||||
|
LABEL maintainer="sombochea@cubetiqs.com"
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY . /usr/src/app
|
||||||
|
|
||||||
|
RUN pnpm install
|
||||||
|
|
||||||
|
CMD [ "node" , "index.js"]
|
||||||
```
|
```
|
||||||
|
|
||||||
# Contributors
|
# Contributors
|
||||||
- Sambo Chea <sombochea@cubetiqs.com>
|
|
||||||
|
- Sambo Chea <sombochea@cubetiqs.com>
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
```text
|
```text
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
@@ -40,4 +61,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECT
|
OUT OF OR IN CONNECT
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
# Examples
|
# Examples
|
||||||
- Say Hello to Docker with Nodejs
|
- Say Hello to Docker with Nodejs
|
||||||
|
- Excel file transform to json with Nodejs
|
||||||
5
examples/excel2json/.gitignore
vendored
Normal file
5
examples/excel2json/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
node_modules/
|
||||||
|
yarn.lock
|
||||||
|
package-lock.json
|
||||||
|
yarn-error*
|
||||||
|
outputs/
|
||||||
16
examples/excel2json/Dockerfile
Normal file
16
examples/excel2json/Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
FROM cubetiq/calpine-node:latest
|
||||||
|
LABEL maintainer="sombochea@cubetiqs.com"
|
||||||
|
|
||||||
|
VOLUME [ "/app/data" ]
|
||||||
|
|
||||||
|
ENV INPUT_FILE './data/people.xlsx'
|
||||||
|
ENV OUTPUT_PATH './data/outputs'
|
||||||
|
ENV MAPPER_FILE './data/mapper.json'
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
RUN pnpm install
|
||||||
|
|
||||||
|
CMD [ "node" , "index.js"]
|
||||||
11
examples/excel2json/Makefile
Normal file
11
examples/excel2json/Makefile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
DOCKER_IMAGE=cubetiq/node-excel2json
|
||||||
|
|
||||||
|
build:
|
||||||
|
@echo "Building docker image..."
|
||||||
|
docker build . -t ${DOCKER_IMAGE}
|
||||||
|
|
||||||
|
run:
|
||||||
|
@echo "Running container..."
|
||||||
|
docker run --rm -t ${DOCKER_IMAGE}
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
60
examples/excel2json/README.md
Normal file
60
examples/excel2json/README.md
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# excel2json
|
||||||
|
|
||||||
|
- Read file excel to json
|
||||||
|
- Custom mapping with custom columns and configs
|
||||||
|
|
||||||
|
# Build
|
||||||
|
|
||||||
|
```shell
|
||||||
|
bash build
|
||||||
|
```
|
||||||
|
|
||||||
|
OR
|
||||||
|
|
||||||
|
```shell
|
||||||
|
make build run
|
||||||
|
```
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker run -v /my/path:/app/data --rm -it cubetiq/node-excel2json
|
||||||
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker run -v /home/sombochea/excel2json:/app/data -e APP_NAME="EXCEL 2 JSON" -e MAPPER_FILE="./data/mapper.json" --rm -it cubetiq/node-excel2json
|
||||||
|
```
|
||||||
|
|
||||||
|
# Mapper Config
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"dataIndex": "Name",
|
||||||
|
"label": "Name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dataIndex": "Age",
|
||||||
|
"label": "Age"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configs": {
|
||||||
|
"outputPath": "./data/outputs/exported",
|
||||||
|
"outputName": "my_exported_data",
|
||||||
|
"sheetName": "Sheet1",
|
||||||
|
"saveToOutput": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
|
||||||
|
```env
|
||||||
|
APP_NAME=custom app name
|
||||||
|
INPUT_FILE=./data/mydata.xlsx
|
||||||
|
OUTPUT_PATH=./data/outputs
|
||||||
|
MAPPER_FILE=./data/mapper.json
|
||||||
|
SHEET_NAME=Sheet1
|
||||||
|
ENCODING=utf-8
|
||||||
|
```
|
||||||
3
examples/excel2json/build.sh
Normal file
3
examples/excel2json/build.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
make build run
|
||||||
18
examples/excel2json/data/mapper.json
Normal file
18
examples/excel2json/data/mapper.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"dataIndex": "Name",
|
||||||
|
"label": "Name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dataIndex": "Age",
|
||||||
|
"label": "Age"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configs": {
|
||||||
|
"outputPath": "./data/outputs/exported",
|
||||||
|
"outputName": "my_exported_data",
|
||||||
|
"sheetName": "Sheet1",
|
||||||
|
"saveToOutput": true
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
examples/excel2json/data/people.xlsx
Normal file
BIN
examples/excel2json/data/people.xlsx
Normal file
Binary file not shown.
100
examples/excel2json/excel2json.js
Normal file
100
examples/excel2json/excel2json.js
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
const XLSX = require("xlsx");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
// do export for excel to json output or data json object
|
||||||
|
function _internalExport() {
|
||||||
|
const NAME = process.env.APP_NAME || "excel2json";
|
||||||
|
console.log("APP NAME =>", NAME, "\n");
|
||||||
|
|
||||||
|
// load from env
|
||||||
|
const INPUT_FILE = process.env.INPUT_FILE || "./data/people.xlsx";
|
||||||
|
const OUTPUT_PATH = process.env.OUTPUT_PATH || "./data/outputs";
|
||||||
|
const MAPPER_FILE = process.env.MAPPER_FILE || "./data/mapper.json";
|
||||||
|
const SHEET_NAME = process.env.SHEET_NAME || "Sheet1";
|
||||||
|
const ENCODING = process.env.ENCODING || "utf-8";
|
||||||
|
|
||||||
|
// get mapper in string
|
||||||
|
var mapperString = undefined;
|
||||||
|
try {
|
||||||
|
mapperString = fs.readFileSync(
|
||||||
|
MAPPER_FILE,
|
||||||
|
{ encoding: ENCODING },
|
||||||
|
(err) => {
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
console.log("Load file suceed =>", MAPPER_FILE);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("read file error", err);
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert mapper from string to json object
|
||||||
|
const mapperJson = mapperString ? JSON.parse(mapperString) : {};
|
||||||
|
const configs = mapperJson.configs || {};
|
||||||
|
const columsData = mapperJson.data || undefined;
|
||||||
|
|
||||||
|
// read workbook from excel file
|
||||||
|
const wb = XLSX.readFile(configs.inputFile || INPUT_FILE);
|
||||||
|
const xlData = XLSX.utils.sheet_to_json(
|
||||||
|
wb.Sheets[configs.sheetName || SHEET_NAME]
|
||||||
|
);
|
||||||
|
|
||||||
|
// mapping the data from read excel file
|
||||||
|
const data = xlData.map((row) => {
|
||||||
|
if (columsData == undefined || !columsData) {
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _r = {};
|
||||||
|
|
||||||
|
columsData.map((col) => {
|
||||||
|
_r[col.label] = row[col.dataIndex];
|
||||||
|
});
|
||||||
|
|
||||||
|
return _r;
|
||||||
|
});
|
||||||
|
|
||||||
|
// parse a new path
|
||||||
|
const outputPath = configs.outputPath || OUTPUT_PATH;
|
||||||
|
|
||||||
|
// check directory and create it if not exist
|
||||||
|
if (!fs.existsSync(outputPath)) {
|
||||||
|
fs.mkdirSync(outputPath, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// able to save to output or not (default is true)
|
||||||
|
const saveToOutput = configs.saveToOutput || true;
|
||||||
|
|
||||||
|
if (saveToOutput) {
|
||||||
|
// json data output
|
||||||
|
const jsonStringData = JSON.stringify(data);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// write to file
|
||||||
|
fs.writeFileSync(
|
||||||
|
`${outputPath}/${
|
||||||
|
configs.outputName || "exported"
|
||||||
|
}_${new Date().getTime()}.json`,
|
||||||
|
jsonStringData,
|
||||||
|
(err) => {
|
||||||
|
if (err) throw err;
|
||||||
|
console.log("Write succeed!");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* excel2json
|
||||||
|
* Allow to export data from excel to json object or output of json.
|
||||||
|
*
|
||||||
|
* @returns JSON Object of result
|
||||||
|
*/
|
||||||
|
module.exports = excel2json = () => {
|
||||||
|
return _internalExport()
|
||||||
|
}
|
||||||
8
examples/excel2json/index.js
Normal file
8
examples/excel2json/index.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// import excel2json module
|
||||||
|
const excel2json = require("./excel2json");
|
||||||
|
|
||||||
|
// called function export excel2json
|
||||||
|
const exported = excel2json();
|
||||||
|
|
||||||
|
// output data from exported
|
||||||
|
console.log("Output =>\n", exported);
|
||||||
15
examples/excel2json/package.json
Normal file
15
examples/excel2json/package.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "excel2json",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Excel to json",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node index.js",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Sambo Chea <sombochea@cubetiqs.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"xlsx": "^0.16.9"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,6 @@ WORKDIR /usr/src/app
|
|||||||
|
|
||||||
COPY . /usr/src/app
|
COPY . /usr/src/app
|
||||||
|
|
||||||
RUN yarn
|
RUN pnpm install
|
||||||
|
|
||||||
CMD [ "node" , "index.js"]
|
CMD [ "node" , "index.js"]
|
||||||
3
examples/sayhello/build.sh
Normal file
3
examples/sayhello/build.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
make build run
|
||||||
6
renovate.json
Normal file
6
renovate.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:base"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user