I have a long running project in Hexo, and recently I wanted to update it to the newest version (6.3.0). Once done, the project works properly with no problems locally on macOS
and builds properly with Docker
locally, but when running it on GitLab CI I receive the following error:
Error: EISDIR: illegal operation on a directory, open '<directory>'
Dockerfile
for testing:
FROM node:18.15.0-alpine3.16
WORKDIR /app
COPY . .
RUN apk update && apk add --no-cache yarn
CMD ["sh", "-c", "yarn install && yarn run generate && ls -l public"]
package.json
used:
{
"name": "my-project",
"version": "1.0.0",
"private": true,
"hexo": {
"version": "6.3.0"
},
"scripts": {
"server": "./node_modules/hexo/bin/hexo server --draft",
"generate": "./node_modules/hexo/bin/hexo generate"
},
"dependencies": {
"hexo": "6.3.0",
"hexo-generator-archive": "2.0.0",
"hexo-generator-category": "2.0.0",
"hexo-generator-feed": "3.0.0",
"hexo-generator-index": "3.0.0",
"hexo-generator-tag": "2.0.0",
"hexo-renderer-ejs": "2.0.0",
"hexo-renderer-marked": "6.0.0",
"hexo-renderer-stylus": "2.1.0",
"hexo-server": "3.0.0"
}
}
Run locally:
docker build -t my-project .
docker run -it -rm my-project
All is working as expected. Project is generated just fine.
But when I execute this Dockerfile
in GitLab CI I get the errors.
My .gitlab-ci.yml
:
image: docker:20.10.23
variables:
DOCKER_TLS_CERTDIR: ""
services:
- docker:20.10.23-dind
before_script:
- docker info
deploy:
stage: deploy
only:
- master
script:
- docker build -t my-project .
- docker run my-project
I assume this has something to do with permissions or Node.js setup in the container, but I can't find what it can be.
I tried thousands of different things to solve the issue, went through multiple SO questions, docs and I am stuck:
Node.js
runtime, tried with npm
and yarn
Update:
This is definitely issue with Hexo and Node.js runtime. With Node.js 12 all is working fine. Upgrading Node.js to 14 (and later) causes the build to fail. Tested with Hexo 3, 5, 6 and 7.
FATAL {
68 err: [Error: EISDIR: illegal operation on a directory, open 'some-path'] {
69 errno: -21,
70 code: 'EISDIR',
71 syscall: 'open',
72 path: 'some-path'
73 }
74} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html
So it seems the only option for now is to stick to Node.js 12, but then there are no options to update Hexo as newer packages require Node.js 14 or later.
After further investigation and reporting this to Hexo GitHub I finally found the solution that fixed the issue.
It was related to the permalink
property in meta of the blog post entry.
I modified permalink
property for each blog post and I appended /index.html
to it:
Before:
permalink: selenium/selenium-manager
After:
permalink: selenium/selenium-manager/index.html
Once this was done, all started to work like a charm.
The original comment that helped me in finding the solution: https://github.com/hexojs/hexo/issues/4682#issuecomment-1149868769