Skip to content

Commit b2f2726

Browse files
committed
pull target node version for docker builds from .nvmrc
1 parent ffce85d commit b2f2726

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.github/workflows/build-docker.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ jobs:
3232
with:
3333
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
3434

35+
- name: Get target Node version from .nvmrc
36+
id: node-version
37+
# https://stackoverflow.com/a/62059571
38+
run: echo "version=$(cat .nvmrc | tr -cd '[:digit:].')" >> $GITHUB_OUTPUT
39+
3540
- name: Build and push Docker image
3641
uses: docker/build-push-action@v4
3742
with:
@@ -40,5 +45,6 @@ jobs:
4045
tags: ${{ steps.meta.outputs.tags }}
4146
labels: ${{ steps.meta.outputs.labels }}
4247
build-args: |
48+
NODE_VERSION=${{ steps.node-version.outputs.version }}
4349
GIT_COMMIT_HASH=${{ github.sha }}
4450
GIT_REPO_URI=${{ github.repostitoryUrl }}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# https://nodejs.org/en/docs/guides/nodejs-docker-webapp
2-
FROM node:22-alpine
1+
ARG NODE_VERSION
2+
FROM node:${NODE_VERSION:-lts}-alpine
33
WORKDIR /usr/src/app
44

55
# copy package.json/package-lock.json and install dependencies

0 commit comments

Comments
 (0)