构建hexo cli的docker镜像

  • 在有docker的环境,但是不想折腾安装hexo cli,就可以使用docker镜像操作。

构建镜像

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
FROM node:lts-alpine3.15 AS runner

ARG OS=linux
ARG ARCH=amd64

LABEL description="hexo cli image"
LABEL org.opencontainers.image.authors="Mardan1 M"

WORKDIR /hexo

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && apk add --no-cache git
RUN npm install -g hexo-cli

EXPOSE 4000

CMD "hexo" "version"

使用hexo-cli

1
2
3
4
5
[root@labs ~]# docker run --rm -it -p 4000:4000 -v $(pwd)/blog:/hexo -w /hexo hexo-cli sh
/hexo # hexo s
INFO Validating config
INFO Start processing
INFO Hexo is running at http://localhost:4000/ . Press Ctrl+C to stop.