bonus-edge-proxy/docker/dev/Dockerfile

72 lines
2.7 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.

# =================================================================
# Edge Proxy - Development Environment Dockerfile (V3 - Corrected)
# =================================================================
FROM arm64v8/ubuntu:22.04
# 1. 基础环境设置
# =================================
WORKDIR /app
ENV DEBIAN_FRONTEND=noninteractive
# 2. 用户和组创建
# 说明: 在这里创建所有需要的用户和组。
# 权限将在主机端设置而不是在Dockerfile中因为工作目录/app将被主机目录挂载覆盖。
# =================================
RUN groupadd -r developers && \
# 创建 forlinx 用户,用于管理主机上的目录所有权
useradd -ms /bin/bash -G developers,sudo forlinx && \
# 为开发者创建各自的主组
groupadd gyk && \
groupadd zql && \
# 创建开发者独立用户,并加入共享的 developers 组
useradd -ms /bin/bash -g gyk -G developers gyk && \
useradd -ms /bin/bash -g zql -G developers zql
# 3. 复制构建上下文并安装依赖
# 说明: 将整个项目复制到临时目录,用于编译 paho 等库。
# =================================
COPY . /tmp/build-context
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
gdb \
vim \
libssl-dev \
# spdlog 开发库
libspdlog-dev \
# Boost C++ 开发库 (元数据包)
libboost-all-dev && \
\
# --- 从源码编译并安装 Paho MQTT C 库 ---
echo "--- Building and installing Paho MQTT C Library ---" && \
cd /tmp/build-context/external/paho.mqtt.c && \
cmake -Bbuild -H. \
-DPAHO_WITH_SSL=ON \
-DPAHO_BUILD_SAMPLES=OFF \
-DPAHO_BUILD_DOCUMENTATION=OFF && \
cmake --build build --target install && \
\
# --- 从源码编译并安装 Paho MQTT C++ 库 ---
echo "--- Building and installing Paho MQTT C++ Library ---" && \
cd /tmp/build-context/external/paho.mqtt.cpp && \
cmake -Bbuild -H. -DPAHO_WITH_SSL=ON -DPAHO_BUILD_SAMPLES=OFF -DPAHO_BUILD_DOCUMENTATION=OFF && \
cmake --build build --target install && \
\
# --- 清理工作 ---
# 刷新动态链接库缓存
ldconfig && \
# 删除临时的构建上下文,减小镜像体积
rm -rf /tmp/build-context && \
# 清理apt缓存减小镜像体积
rm -rf /var/lib/apt/lists/*
# 4. (可选) 设置默认用户
# 说明: 如果不设置,默认是 root。如果希望容器启动后默认是某个用户可以取消下面的注释。
# 但对于 VSCode attach 来说,它会使用 devcontainer.json 中指定的 remoteUser所以此项不是必须的。
# USER forlinx
# CMD ["sleep", "infinity"]