Skip to content

Commit

Permalink
feat: 增加 node 相关 Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkunwang223 committed May 30, 2024
1 parent 344dfde commit 7088e62
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/node-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build Node Image

on:
workflow_dispatch:
inputs:
node22Version:
description: 'Node 22 Version'
default: '22.2.0'
required: true
node21Version:
description: 'Node 21 Version'
default: '21.7.3'
required: true

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build Node-22 and Push
uses: docker/build-push-action@v5
with:
context: ./node/22
file: Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
push: true
build-args:
NODE_VERSION=${{ github.event.inputs.node22Version }}
tags: |
1panel/node:${{ github.event.inputs.node22Version }}
#outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build Node-21 and Push
uses: docker/build-push-action@v5
with:
context: ./node/21
file: Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
push: true
build-args:
NODE_VERSION=${{ github.event.inputs.node21Version }}
tags: |
1panel/node:${{ github.event.inputs.node21Version }}
#outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
cache-from: type=gha
cache-to: type=gha,mode=max
10 changes: 10 additions & 0 deletions node/18/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG NODE_VERSION

FROM node:${NODE_VERSION}

RUN npm install -g pnpm

COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "node" ]
11 changes: 11 additions & 0 deletions node/18/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -e

# Run command with node if the first argument contains a "-" or is not a system command. The last
# part inside the "{}" is a workaround for the following bug in ash/dash:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
set -- node "$@"
fi

exec "$@"
10 changes: 10 additions & 0 deletions node/20/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG NODE_VERSION

FROM node:${NODE_VERSION}

RUN npm install -g pnpm

COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]

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

# Run command with node if the first argument contains a "-" or is not a system command. The last
# part inside the "{}" is a workaround for the following bug in ash/dash:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
set -- node "$@"
fi

exec "$@"
10 changes: 10 additions & 0 deletions node/21/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG NODE_VERSION

FROM node:${NODE_VERSION}

RUN npm install -g pnpm

COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]

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

# Run command with node if the first argument contains a "-" or is not a system command. The last
# part inside the "{}" is a workaround for the following bug in ash/dash:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
set -- node "$@"
fi

exec "$@"
10 changes: 10 additions & 0 deletions node/22/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG NODE_VERSION

FROM node:${NODE_VERSION}

RUN npm install -g pnpm

COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "node" ]
11 changes: 11 additions & 0 deletions node/22/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -e

# Run command with node if the first argument contains a "-" or is not a system command. The last
# part inside the "{}" is a workaround for the following bug in ash/dash:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
set -- node "$@"
fi

exec "$@"
Empty file removed nodejs/.gitkeep
Empty file.

0 comments on commit 7088e62

Please sign in to comment.