Files
meta-unit-core/.devcontainer/Dockerfile
李东云 00e8d4811c init:完善项目文档并设置开发环境
- 新增贡献指南、开发指南和README的中文版本
- 创建Dev Container配置文件,包括Dockerfile、docker-compose.yml和devcontainer.json
- 初始化项目结构,创建必要的目录和文件
- 设置Rust开发环境,包括依赖和工具链
2025-06-05 13:59:19 +08:00

59 lines
2.6 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# meta-unit-core/.devcontainer/Dockerfile
# 使用一个包含 Rust 工具链的官方镜像作为基础
# 推荐使用 rustlang/rust:latest-bullseye 或其他稳定版本
# 也可以选择 slim 镜像以减小体积,但可能需要手动安装更多基础工具
FROM rust:bullseye
# 设置工作目录
WORKDIR /app
# 1. 安装系统依赖 (如果需要)
# 例如,如果你的 Rust 项目依赖于某些 C 库 (如 OpenSSL, SQLite), 则在此安装
# 对于 meta-unit-core 这样纯 Rust + WASM 的项目,初期可能不多
# RUN apt-get update && apt-get install -y \
# pkg-config \
# libssl-dev \
# build-essential \
# # ... 其他你项目可能需要的系统依赖
# && rm -rf /var/lib/apt/lists/*
# 2. 安装 Rustup 组件
# rust-analyzer 是 IDE 智能感知的核心clippy 用于 Lintingrustfmt 用于格式化
# 这些工具应该在容器内,而不是在宿主机上运行,以保证一致性
RUN rustup component add rust-analyzer clippy rustfmt
# 3. 添加 WASM 编译目标
# 这是 Yuan (Meta Unit) 的核心目标
RUN rustup target add wasm32-unknown-unknown
# 4. 安装 Protobuf 相关工具
# 编译 .proto 文件为 Rust 代码需要这些工具
# prost-build 是 Rust 的 Protobuf 代码生成库,我们通常在 Cargo.toml 中作为 build-dependency
# 这里我们指的是安装 protoc 编译器本身
# 方法一:通过 apt-get 安装 (如果源里有的话)
# RUN apt-get update && apt-get install -y protobuf-compiler
# 方法二:下载并安装 protoc (更通用且版本可控)
ARG PROTOC_VERSION="3.20.1"
# 可以根据 meta-unit-proto 的版本来调整
RUN apt-get update && apt-get install -y curl unzip \
&& curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip \
&& unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /usr/local \
&& rm protoc-${PROTOC_VERSION}-linux-x86_64.zip \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# 5. 安装其他可选的 Rust 工具 (如果需要)
# 例如wasm-pack 是用于 Rust 到 WASM 编译的工具,在开发 web-sys 或 node 环境下的 WASM 模块时很有用
# 对于 meta-unit-core可能不是必需的因为我们直接编译为 wasm32-unknown-unknown
# RUN cargo install wasm-pack
# 将 Cargo 的 bin 目录添加到 PATH (通常 rustlang/rust 基础镜像已完成)
# ENV PATH="/usr/local/cargo/bin:${PATH}"
# 设置默认用户,防止以 root 身份运行 (可选,但推荐用于安全)
# RUN useradd -ms /bin/bash developer
# USER developer
# 暴露端口 (如果你的项目需要监听端口,例如在集成测试中启动一个模拟服务)
# EXPOSE 8080