openwrt编译Dockerfile

发布于:2024-08-08 ⋅ 阅读:(196) ⋅ 点赞:(0)

一、Dockerfile

FROM ubuntu:20.04


ENV TZ=Asia/Shanghai

RUN apt-get update && \
    apt-get install -y --no-install-recommends tzdata && \
    ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
    dpkg-reconfigure --frontend noninteractive tzdata && \
    apt-get install -y --no-install-recommends \
        ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
        bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib \
        git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libfuse-dev libglib2.0-dev libgmp3-dev \
        libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libpython3-dev libreadline-dev \
        libssl-dev libtool lrzsz mkisofs msmtp ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 \
        python3-pyelftools python3-setuptools qemu-utils rsync scons squashfs-tools subversion swig texinfo \
        uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev sudo && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# RUN groupadd -r openwrt && useradd -r -g openwrt -m -d /home/openwrt openwrt

# RUN chown -R openwrt:openwrt /home/openwrt

# 创建非root用户并设置密码
ARG USERNAME=openwrt
ARG PASSWORD=1
RUN useradd  -m -s /bin/bash $USERNAME \
    && echo "$USERNAME:$PASSWORD" | chpasswd \
    && usermod -aG sudo $USERNAME

# 设置root用户密码
ARG ROOT_PASSWORD=1
RUN echo "root:$ROOT_PASSWORD" | chpasswd

RUN echo "alias ls='ls --color=auto'" >> /etc/bash.bashrc \
    && echo "PS1='\[\e[32m\]\u@\h:\w$\[\e[m\] '" >> /etc/bash.bashrc

USER $USERNAME
WORKDIR /home/$USERNAME
    

ENV FORCE_UNSAFE_CONFIGURE=1

CMD ["/bin/bash"]

二、Build

docker build -t openwrt_compile:1.0.0 .

三、Run

docker run -ti --name "led" -v $(pwd):/home/openwrt  openwrt_compile:1.0.0

网站公告

今日签到

点亮在社区的每一天
去签到