From f2237f48778d2bf31e48789416cae106eaf25ed5 Mon Sep 17 00:00:00 2001 From: anian Date: Sun, 15 Mar 2026 22:43:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=BC=80=E5=8F=91=E7=8E=AF?= =?UTF-8?q?=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 6 +++++ Dockerfile | 66 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 9 +++++++ docker-compose.yml | 21 +++++++++++++++ 4 files changed, 102 insertions(+) create mode 100755 .gitignore create mode 100755 Dockerfile create mode 100755 README.md create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..8c88b66 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +* + +!Dockerfile +!docker-compose.yml +!README.md +!.gitignore diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..0617dd0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,66 @@ +# 使用 Debian slim +FROM debian:12-slim + +ENV LANG=C.UTF-8 \ + LC_ALL=C.UTF-8 \ + LANGUAGE=C.UTF-8 \ + TERM=xterm-256color + +LABEL maintainer="anian " + +ENV NODE_VERSION=20.20.0 +ENV PNPM_VERSION=latest +ENV PATH="/root/.local/share/pnpm:/usr/local/node/bin:${PATH}" + +# 安装基础工具 +RUN apt-get update && apt-get install -y \ + curl \ + wget \ + git \ + unzip \ + xz-utils \ + ca-certificates \ + bash \ + && rm -rf /var/lib/apt/lists/* + +# 创建 Java 目录 +RUN mkdir -p /opt/java + +# 安装 Java 17 +RUN curl -L https://api.adoptium.net/v3/binary/latest/17/ga/linux/x64/jdk/hotspot/normal/eclipse \ + | tar -xz -C /opt/java \ + && mv /opt/java/jdk-17* /opt/java/java17 + +# 安装 Java 21 +RUN curl -L https://api.adoptium.net/v3/binary/latest/21/ga/linux/x64/jdk/hotspot/normal/eclipse \ + | tar -xz -C /opt/java \ + && mv /opt/java/jdk-21* /opt/java/java21 + +# 注册 Java +RUN update-alternatives --install /usr/bin/java java /opt/java/java17/bin/java 1 \ + && update-alternatives --install /usr/bin/java java /opt/java/java21/bin/java 2 \ + && update-alternatives --install /usr/bin/javac javac /opt/java/java17/bin/javac 1 \ + && update-alternatives --install /usr/bin/javac javac /opt/java/java21/bin/javac 2 + +# 默认 Java17 +RUN update-alternatives --set java /opt/java/java17/bin/java \ + && update-alternatives --set javac /opt/java/java17/bin/javac + +# 安装 Node.js +RUN mkdir -p /usr/local/node \ + && curl -fsSL https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz \ + | tar -xJ -C /usr/local/node --strip-components=1 + +# 安装 pnpm +RUN npm install -g pnpm@${PNPM_VERSION} + +# 添加 Java 切换命令 +RUN echo '#!/bin/bash\nupdate-alternatives --set java /opt/java/java17/bin/java\nupdate-alternatives --set javac /opt/java/java17/bin/javac\necho "Switched to Java 17"' > /usr/local/bin/use-java17 \ + && chmod +x /usr/local/bin/use-java17 + +RUN echo '#!/bin/bash\nupdate-alternatives --set java /opt/java/java21/bin/java\nupdate-alternatives --set javac /opt/java/java21/bin/javac\necho "Switched to Java 21"' > /usr/local/bin/use-java21 \ + && chmod +x /usr/local/bin/use-java21 + +WORKDIR /app + +CMD ["/bin/bash"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100755 index 0000000..9a58c1b --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# halo-plugin-dever + +> 为halo插件开发提供容器环境 + +#### v260315 +1. 新增Java17、Java21(使用 `use-java17`、`use-java21` 切换) +2. 新增node v20.20.0 +3. 新增pnpm v10.32.1 +4. 新增常用软件 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..55c3a2e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +services: + halo-plugin-build: + image: halo-plugin-dever:260315 + container_name: halo-plugin-dever + volumes: + - ./app:/app + - ./cache/gradle:/root/.gradle + - ./cache/pnpm:/root/.pnpm-store + - ./cache/npm:/root/.npm + - ./cache/node:/root/.cache + working_dir: /app + command: /bin/bash + tty: true + stdin_open: true + restart: always + networks: + - 1panel-network + +networks: + 1panel-network: + external: true \ No newline at end of file