Skip to content

Commit 9153487

Browse files
committed
feat: create node 24 image
1 parent 8343cb2 commit 9153487

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Publish Node.js 24 image to Docker Hub
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'node24/**'
9+
10+
permissions:
11+
contents: write
12+
13+
env:
14+
IMAGE_NAME: dev-node24
15+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
16+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
17+
DOCKERHUB_ID: ${{ secrets.DOCKERHUB_ID }}
18+
19+
jobs:
20+
build_and_push:
21+
if: github.event_name != 'pull_request'
22+
name: Build and push Node.js 24 image
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v5
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Check for changes in node24 directory
31+
id: changes
32+
uses: dorny/paths-filter@v3
33+
with:
34+
filters: |
35+
node24:
36+
- 'node24/**'
37+
38+
- name: Exit if no changes
39+
if: steps.changes.outputs.node24 != 'true' # use the output from paths-filter
40+
run: |
41+
echo "No changes in node24 directory, skipping build"
42+
exit 0
43+
44+
- name: Setup Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Log into Docker Hub
48+
uses: docker/login-action@v3
49+
with:
50+
registry: https://index.docker.io/v1/
51+
username: ${{ env.DOCKERHUB_USERNAME }}
52+
password: ${{ env.DOCKERHUB_PASSWORD }}
53+
54+
- name: Get latest version tag
55+
id: get_version
56+
run: |
57+
git fetch --tags
58+
# get the latest tag with regex pattern have vnode24 prefix
59+
latest_tag=$(git tag -l | grep -E '^vnode24' | sort -V | tail -n 1)
60+
echo "Latest tag: $latest_tag"
61+
echo "version=$latest_tag" >> $GITHUB_OUTPUT
62+
63+
- name: Increment version number
64+
id: inc_version
65+
run: |
66+
version=${{ steps.get_version.outputs.version }}
67+
version=${version#"v"}
68+
if [ -z "$version" ]; then
69+
major=0
70+
minor=0
71+
patch=0
72+
else
73+
IFS='.' read -r -a parts <<< "$version"
74+
major=${parts[0]:-0}
75+
minor=${parts[1]:-0}
76+
patch=${parts[2]:-0}
77+
fi
78+
patch=$((patch+1))
79+
if [ "$patch" -ge 100 ]; then
80+
patch=0
81+
minor=$((minor+1))
82+
fi
83+
if [ "$minor" -ge 10 ]; then
84+
minor=0
85+
major=$((major+1))
86+
fi
87+
new_version="v$major.$minor.$patch"
88+
echo "New version: $new_version"
89+
echo "new_version=$new_version" >> $GITHUB_OUTPUT
90+
91+
- name: Set new version tag
92+
run: |
93+
git tag ${{ steps.inc_version.outputs.new_version }}
94+
git push origin ${{ steps.inc_version.outputs.new_version }}
95+
96+
- name: Extract Docker metadata
97+
id: meta
98+
uses: docker/metadata-action@v5
99+
with:
100+
images: ${{ env.DOCKERHUB_ID }}/${{ env.IMAGE_NAME }}
101+
tags: |
102+
type=ref,event=branch
103+
type=ref,event=tag
104+
type=semver,pattern={{version}}
105+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
106+
type=raw,value=${{ steps.inc_version.outputs.new_version }}
107+
108+
- name: Build and push Node.js 24 image
109+
id: build-and-push
110+
uses: docker/build-push-action@v6
111+
with:
112+
context: node24
113+
push: true
114+
tags: |
115+
${{ env.DOCKERHUB_ID }}/${{ env.IMAGE_NAME }}:latest
116+
${{ env.DOCKERHUB_ID }}/${{ env.IMAGE_NAME }}:${{ steps.inc_version.outputs.new_version }}
117+
labels: ${{ steps.meta.outputs.labels }}
118+
build-args: |
119+
USER_ID=1000
120+
GROUP_ID=1000

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ In this docker repository, we have built the following images:
2020
- [cslant/dev-mysql](https://hub.docker.com/r/cslant/dev-mysql)
2121
- [cslant/dev-mysql9](https://hub.docker.com/r/cslant/dev-mysql9)
2222
- [cslant/dev-node22](https://hub.docker.com/r/cslant/dev-node22)
23+
- [cslant/dev-node24](https://hub.docker.com/r/cslant/dev-node24)
2324
- [cslant/dev-nginx](https://hub.docker.com/r/cslant/dev-nginx)
2425
- [cslant/dev-postgres](https://hub.docker.com/r/cslant/dev-postgres)
2526
- [cslant/dev-mailhog](https://hub.docker.com/r/cslant/dev-mailhog)

node24/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM node:24.6.0-alpine
2+
LABEL maintainer="Tan Nguyen <[email protected]>"
3+
LABEL authors="cslant"
4+
LABEL description="Node.js 24 image for CSlant development"
5+
6+
ARG USER_ID=1000
7+
ARG GROUP_ID=1000
8+
9+
## Set Environment
10+
ENV USER_ID=$USER_ID
11+
ENV GROUP_ID=$GROUP_ID
12+
13+
RUN apk add --no-cache \
14+
git \
15+
xdg-utils
16+
17+
RUN deluser node
18+
19+
## Add user
20+
RUN addgroup -g ${USER_ID} csdev; \
21+
adduser -D -u ${USER_ID} -G csdev csdev
22+
23+
## Enable Yarn 4
24+
RUN corepack enable
25+
26+
USER csdev
27+
28+
RUN echo Y | yarn -v
29+
RUN corepack prepare [email protected] --activate
30+
31+
WORKDIR /var/dev
32+
33+
CMD ["ash", "-l"]

0 commit comments

Comments
 (0)