-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2d067f
commit 8c045fd
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: 'Build node images' | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: | ||
- 16 | ||
- 18 | ||
- 20 | ||
- 22 | ||
yarn: | ||
- 1 | ||
- 2 | ||
- 3 | ||
- 4 | ||
env: | ||
NODE_LATEST: 22 | ||
YARN_LATEST: 4 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/login-ghcr | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: ./.github/actions/build-push | ||
with: | ||
registry: ghcr.io | ||
cache-mode: 'min' | ||
context: images/node | ||
image: myparcelnl/node | ||
latest: ${{ matrix.node == env.NODE_LATEST }} && ${{ matrix.yarn == env.YARN_LATEST }} | ||
suffix: ${{ matrix.node }}-yarn${{ matrix.yarn }} | ||
build-args: | | ||
NODE_VERSION=${{ matrix.node }} | ||
YARN_VERSION=${{ matrix.yarn }} | ||
notify-on-failure: | ||
needs: | ||
- build | ||
if: always() && contains(needs.*.result, 'failure') | ||
uses: myparcelnl/actions/.github/workflows/notify-on-failure.yml@v4 | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ jobs: | |
strategy: | ||
matrix: | ||
image: | ||
- node | ||
- prestashop | ||
- shopware | ||
- wordpress | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
ARG NODE_VERSION="20" | ||
|
||
########## | ||
# Node | ||
########## | ||
FROM node:${NODE_VERSION}-alpine AS node | ||
|
||
ARG YARN_VERSION="4" | ||
|
||
ENV NODE_VERSION=${NODE_VERSION} | ||
ENV YARN_VERSION=${YARN_VERSION} | ||
ENV YARN_CACHE_FOLDER=/tmp/.cache/yarn | ||
ENV YARN_IGNORE_NODE=1 | ||
|
||
WORKDIR /app | ||
|
||
RUN NODE_MAJOR_VERSION=$(echo $NODE_VERSION | cut -d. -f1) && \ | ||
NODE_MINOR_VERSION=$(echo $NODE_VERSION | cut -d. -f2) && \ | ||
# if node version is 18 and up, use corepack | ||
if [ "$NODE_MAJOR_VERSION" -lt 18 ]; then \ | ||
# expand YARN_VERSION to the full version number with #.x \ | ||
if [[ ! "$YARN_VERSION" =~ ^1 ]]; then \ | ||
if [[ "$YARN_VERSION" =~ ^[0-9]+$ ]]; then \ | ||
YARN_VERSION="${YARN_VERSION}.x"; \ | ||
fi && \ | ||
yarn policies set-version stable && \ | ||
yarn set version $YARN_VERSION; \ | ||
fi && \ | ||
chmod +x ./.yarn/releases/yarn-*.cjs && \ | ||
# replace the default yarn in bin with the new version in .yarn/releases/yarn-x.x.x.cjs \ | ||
cp ./.yarn/releases/yarn-*.cjs "$(which yarn)"; \ | ||
else \ | ||
# If node version is 18 and up, use corepack | ||
corepack enable && \ | ||
corepack prepare "yarn@${YARN_VERSION}" --activate; \ | ||
fi && \ | ||
if [[ "$YARN_VERSION" =~ ^1 ]]; then \ | ||
# Yarn 1.x | ||
yarn config set cache-folder "$YARN_CACHE_FOLDER"; \ | ||
else \ | ||
# Yarn 2+ | ||
yarn config set --home enableTelemetry 0 && \ | ||
yarn config set --home enableGlobalCache false && \ | ||
yarn config set --home cacheFolder "$YARN_CACHE_FOLDER"; \ | ||
fi | ||
|
||
LABEL org.opencontainers.image.description="Node.js ${NODE_VERSION} with Yarn ${YARN_VERSION} installed" | ||
|
||
CMD ["node"] |