Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(node): upgrade to node v20.11.0 and related dependency #1195

Merged
merged 3 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ jobs:
run: |
poetry install

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 8

- name: Setup Yarn install
uses: borales/actions-yarn@v4
with:
cmd: install
node-version: '20.x'

- name: install via yarn2
run: |
yarn install --immutable

- name: Run ruff on src
run: |
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/carbon
lts/iron
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# [Node Stage to get node_modolues and node dependencies]
FROM node:8.16.0-buster-slim as node_base
FROM node:20.11.0-bullseye-slim as node_base
# [Python Stage for Django web server]
FROM python:3.10.14-slim-bullseye as python_base

FROM node_base as node_deps
COPY ./yarn.lock yarn.lock
COPY ./package.json package.json

RUN apt-get update
RUN apt-get install python-pip -y

RUN npm install -g yarn
RUN yarn install --dev --frozen-lockfile && yarn cache clean
RUN corepack enable
RUN yarn install --immutable
mattwang44 marked this conversation as resolved.
Show resolved Hide resolved

FROM python_base as python_deps
ENV APP_DIR /usr/local/app

# make nodejs accessible and executable globally
ENV NODE_PATH $APP_DIR/node_modules/
ENV PATH /usr/local/bin:$PATH

# Add bin directory used by `pip install --user`
ENV PATH /home/docker/.local/bin:$PATH

mattwang44 marked this conversation as resolved.
Show resolved Hide resolved
# Infrastructure tools
# gettext is used for django to compile .po to .mo files.
RUN apt-get update
Expand Down
49 changes: 49 additions & 0 deletions dev.Dockerfile
mattwang44 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# [Node Stage to get node_modolues and node dependencies]
FROM node:20.11.0-bullseye as node_stage

COPY ./yarn.lock yarn.lock
COPY ./package.json package.json

RUN corepack enable
RUN yarn install --immutable

# [Python Stage for Django web server]
FROM python:3.10.14-slim-bullseye as python_stage

WORKDIR /app

ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1

# Infrastructure tools
# gettext is used for django to compile .po to .mo files.
RUN apt-get update
RUN apt-get install -y \
libpq-dev \
gcc \
zlib1g-dev \
libjpeg62-turbo-dev \
mime-support \
gettext \
libxml2-dev \
libxslt-dev

# Install Poetry
RUN pip install --no-cache-dir pip==23.3.2 && \
pip install --no-cache-dir poetry==1.8.2

# Install Python dependencies
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-root && \
yes | poetry cache clear --all pypi

# Add poetry bin directory to PATH
ENV PATH="${WORKDIR}/.venv/bin:$PATH"

COPY --from=node_stage /node_modules ./node_modules
COPY --from=node_stage /usr/local/bin/node /usr/local/bin/node
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/plugin-transform-class-properties": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"autoprefixer": "^8.0.0",
"autoprefixer": "^10.4.19",
"babelify": "^10.0.0",
"browserify": "^16.1.0",
"node-sass": "^4.9.0",
"postcss-cli": "^5.0.0"
"browserify": "^17.0.0",
"node-sass": "^9.0.0",
"postcss": "^8.4.38",
mattwang44 marked this conversation as resolved.
Show resolved Hide resolved
"postcss-cli": "^11.0.0"
},
"dependencies": {
"blueimp-gallery": "^2.44.0",
Expand Down
2 changes: 1 addition & 1 deletion src/pycontw2016/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def node_bin(name):
COMPRESS_SCSS_COMPILER_CMD = (
'{node_sass_bin} --include --output-style expanded {paths} '
'--include-path="{node_modules}" "{infile}" "{outfile}" && '
'{postcss_bin} --use "{node_modules}/autoprefixer" '
'{postcss_bin} --use "{node_modules}/autoprefixer/lib/autoprefixer.js" '
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原本文件中的command 會抓不到其他套件,所以改用這樣的方式處理

'--autoprefixer.browsers "{autoprefixer_browsers}" -r "{outfile}"'
)

Expand Down
Loading
Loading