-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (49 loc) · 2.23 KB
/
Dockerfile
File metadata and controls
57 lines (49 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 使用官方 Arch Linux 基础镜像(最小化版本)
FROM archlinux:base-devel
# OCI 镜像元数据标签
LABEL org.opencontainers.image.title="Arch Linux Development Image"
LABEL org.opencontainers.image.description="Arch Linux base-devel with paru AUR helper"
LABEL org.opencontainers.image.authors="Akatsukiro <aka@bep.ink>"
LABEL org.opencontainers.image.vendor="Akatsukiro"
LABEL org.opencontainers.image.source="https://github.com/akass-org/archlinux"
# 控制是否使用国内镜像源(GitHub Actions 构建时设置为 false)
ARG USE_MIRROR_SOURCE=true
# 配置国内镜像源(提高下载速度)
RUN if [ "$USE_MIRROR_SOURCE" = "true" ]; then \
echo 'Server = https://mirrors.tencentyun.com/archlinux/$repo/os/$arch' > /etc/pacman.d/mirrorlist && \
echo 'Server = https://mirrors.aliyun.com/archlinux/$repo/os/$arch' >> /etc/pacman.d/mirrorlist && \
echo 'Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch' >> /etc/pacman.d/mirrorlist && \
echo 'Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch' >> /etc/pacman.d/mirrorlist; \
fi
# 配置 pacman 基本设置
RUN sed -i 's/#ParallelDownloads = 5/ParallelDownloads = 10/' /etc/pacman.conf && \
# 启用 Color 输出,方便调试
sed -i 's/#Color/Color/' /etc/pacman.conf && \
# 更新系统和软件包数据库
pacman -Syu --noconfirm && \
# 安装一些基础但必要的工具
pacman -S --noconfirm \
git \
sudo \
vim \
&& \
# 清理缓存,减小镜像体积
pacman -Scc --noconfirm && \
rm -rf /var/cache/pacman/pkg/*
# 创建构建用户并配置受限的 sudo 权限
RUN useradd --create-home -G wheel -s /bin/bash builder && \
echo 'builder ALL=(ALL) NOPASSWD: /usr/bin/pacman, /usr/bin/paru' >> /etc/sudoers.d/10-builder && \
chmod 0440 /etc/sudoers.d/10-builder
# 从 AUR 源码编译安装 paru
RUN pacman -S --noconfirm rust && \
cd /tmp && \
git clone https://aur.archlinux.org/paru.git && \
chown -R builder:builder paru && \
cd paru && \
sudo -u builder makepkg -si --noconfirm && \
cd / && rm -rf /tmp/paru && \
pacman -Scc --noconfirm
# 设置默认工作目录
WORKDIR /home/builder
# 默认命令
CMD ["/bin/bash"]