Skip to content

Commit

Permalink
Merge pull request #68 from kool-dev/node-20
Browse files Browse the repository at this point in the history
Drop node 16; Add node 20/21
  • Loading branch information
fabriciojs authored Oct 22, 2023
2 parents 6311fc5 + 67a2ed0 commit b17eb55
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
strategy:
matrix:
version: [16, 18]
version: [18, 20, 21]
runs-on: [ubuntu-latest, buildjet-4vcpu-ubuntu-2204-arm]
runs-on: ${{ matrix.runs-on }}

Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [16, 18]
version: [18, 20, 21]

steps:
- uses: docker/login-action@v3
Expand Down
2 changes: 1 addition & 1 deletion 16/Dockerfile → 20/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine
FROM node:20-alpine

ENV ASUSER= \
UID=0 \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions 21/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM node:21-alpine

ENV ASUSER= \
UID=0 \
ENTRYPOINT=entrypoint.node.sh

WORKDIR /app

RUN adduser -D -u 1337 kool && deluser --remove-home node \
# deps
&& apk add --no-cache \
bash \
git \
shadow \
su-exec \
curl \
# build tools
g++ \
libpng-dev \
make \
zlib-dev \
&& npm install -g pnpm \
&& rm -rf rm -rf /root/.npm/* \
# dockerize
&& curl -L https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-alpine-linux-amd64-v0.6.1.tar.gz | tar xz \
&& mv dockerize /usr/local/bin/dockerize

COPY root-npmrc /root/.npmrc
COPY --chown=kool:kool kool-npmrc /home/kool/.npmrc
COPY entrypoint /entrypoint

RUN chmod +x /entrypoint

RUN mkdir -p /usr/local/lib/node_modules && chmod -R 777 /usr/local/lib/node_modules

RUN npm i --location=global npm@latest

ENTRYPOINT [ "/entrypoint" ]
20 changes: 20 additions & 0 deletions 21/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
set -e

# Run as current user
CURRENT_USER=${ASUSER:-${UID:-0}}

if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then
usermod -u $CURRENT_USER kool
fi

# Run entrypoint if provided
if [ ! -z "$ENTRYPOINT" ] && [ -f "$ENTRYPOINT" ]; then
bash $ENTRYPOINT
fi

if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then
exec su-exec kool "$@"
else
exec "$@"
fi
4 changes: 4 additions & 0 deletions 21/kool-npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scripts-prepend-node-path=true
package-import-method=copy
shamefully-hoist=true
store-dir=/home/kool/.pnpm-store
4 changes: 4 additions & 0 deletions 21/root-npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scripts-prepend-node-path=true
package-import-method=copy
shamefully-hoist=true
store-dir=/root/.pnpm-store
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@ Minimal [Node](https://nodejs.org/en/) Docker image. It's use is intended for [k

## Available Tags

### 16

- [16](https://github.com/kool-dev/docker-node/blob/master/16/Dockerfile)

### 18

- [18](https://github.com/kool-dev/docker-node/blob/master/18/Dockerfile)

### 20

- [20](https://github.com/kool-dev/docker-node/blob/master/20/Dockerfile)

### 21

- [21](https://github.com/kool-dev/docker-node/blob/master/21/Dockerfile)

### Legacy tags

The following images have been discontinued, but still exist on Hub Docker in case you need them. We strongly advise moving to the newer versions.

- [10](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/10/Dockerfile), [10-qa](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/10-qa/Dockerfile), [10-adonis](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/10-adonis/Dockerfile), [10-adonis-qa](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/10-adonis-qa/Dockerfile), [10-nest](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/10-nest/Dockerfile), [10-nest-qa](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/10-nest-qa/Dockerfile)
- [12](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/12/Dockerfile), [12-qa](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/12-qa/Dockerfile), [12-adonis](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/12-adonis/Dockerfile), [12-adonis-qa](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/12-adonis-qa/Dockerfile), [12-nest](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/12-nest/Dockerfile), [12-nest-qa](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/12-nest-qa/Dockerfile)
- [14](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/14/Dockerfile), [14-qa](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/14-qa/Dockerfile), [14-adonis](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/14-adonis/Dockerfile), [14-adonis-qa](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/14-adonis-qa/Dockerfile), [14-nest](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/14-nest/Dockerfile), [14-nest-qa](https://github.com/kool-dev/docker-node/tree/legacy-2022-07/14-nest-qa/Dockerfile)
- [16](https://github.com/kool-dev/docker-node/blob/master/16/Dockerfile)

## Environment Variables

Expand Down
37 changes: 31 additions & 6 deletions fwd-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"output": ".",
"builds": [
{
"name": "16",
"name": "18",
"data": {
"from": "node:16-alpine",
"version": "16"
"from": "node:18-alpine",
"version": "18"
},
"files": [
{
Expand All @@ -27,10 +27,35 @@
]
},
{
"name": "18",
"name": "20",
"data": {
"from": "node:18-alpine",
"version": "18"
"from": "node:20-alpine",
"version": "20"
},
"files": [
{
"name": "Dockerfile",
"path": "template/Dockerfile"
},
{
"name": "entrypoint",
"path": "template/entrypoint"
},
{
"name": "kool-npmrc",
"path": "template/kool-npmrc"
},
{
"name": "root-npmrc",
"path": "template/root-npmrc"
}
]
},
{
"name": "21",
"data": {
"from": "node:21-alpine",
"version": "21"
},
"files": [
{
Expand Down
6 changes: 4 additions & 2 deletions kool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ scripts:
build:
# parse templates
- kool run template
# node 16
- docker build --pull -t kooldev/node:16 16
# node 18
- docker build --pull -t kooldev/node:18 18
# node 20
- docker build --pull -t kooldev/node:20 20
# node 21
- docker build --pull -t kooldev/node:21 21

0 comments on commit b17eb55

Please sign in to comment.