-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathDockerfile-base
More file actions
80 lines (74 loc) · 3.76 KB
/
Copy pathDockerfile-base
File metadata and controls
80 lines (74 loc) · 3.76 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
FROM jlesage/baseimage-gui:ubuntu-22.04-v4
ENV LANG=zh_CN.UTF-8
# 替换 APT 源为清华镜像(兼容 amd64 的 archive 和 arm64 的 ports)
RUN sed -i 's@/archive.ubuntu.com/@/mirrors.tuna.tsinghua.edu.cn/@g' /etc/apt/sources.list \
&& sed -i 's@/security.ubuntu.com/@/mirrors.tuna.tsinghua.edu.cn/ubuntu/@g' /etc/apt/sources.list \
&& sed -i 's@/ports.ubuntu.com/ubuntu-ports/@/mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/@g' /etc/apt/sources.list
# ─── 安装微信运行时依赖 + 中文支持 ───
# jlesage 基础镜像将多个系统文件符号链接到 /tmp/ 或 /config/ 下,
# 由 s6 init 在容器启动时填充,构建阶段目标文件不存在:
# /etc/passwd -> /tmp/.passwd (悬空)
# /etc/group -> /tmp/.group (悬空)
# /etc/shadow -> /tmp/.shadow (悬空)
# /run -> /tmp/run (悬空)
# /var/log -> /config/log (悬空)
# 某些包的 postinst 脚本需要 adduser/addgroup,会因打不开 /etc/group 而失败。
# 策略:构建时临时删除悬空符号链接并替换为真实文件,安装完成后恢复符号链接,
# 保持运行时行为不变。
RUN set -e \
&& mkdir -p /tmp/run /config/log \
# 删除悬空符号链接,替换为标准系统文件
&& rm -f /etc/passwd /etc/group /etc/shadow \
&& printf '%s\n' \
'root:x:0:0:root:/root:/bin/sh' \
'daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin' \
'bin:x:2:2:bin:/bin:/usr/sbin/nologin' \
'sys:x:3:3:sys:/dev:/usr/sbin/nologin' \
'nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin' \
> /etc/passwd \
&& printf '%s\n' \
'root:x:0:' 'daemon:x:1:' 'bin:x:2:' 'sys:x:3:' 'adm:x:4:' \
'tty:x:5:' 'disk:x:6:' 'lp:x:7:' 'mail:x:8:' 'news:x:9:' \
'uucp:x:10:' 'man:x:12:' 'proxy:x:13:' 'kmem:x:15:' \
'dialout:x:20:' 'fax:x:21:' 'voice:x:22:' 'cdrom:x:24:' \
'floppy:x:25:' 'tape:x:26:' 'sudo:x:27:' 'audio:x:29:' \
'dip:x:30:' 'www-data:x:33:' 'backup:x:34:' 'operator:x:37:' \
'list:x:38:' 'irc:x:39:' 'src:x:40:' 'gnats:x:41:' \
'shadow:x:42:' 'utmp:x:43:' 'video:x:44:' 'sasl:x:45:' \
'plugdev:x:46:' 'staff:x:50:' 'games:x:60:' 'users:x:100:' \
'nogroup:x:65534:' \
> /etc/group \
&& printf '%s\n' \
'root:*:19448:0:99999:7:::' \
'daemon:*:19448:0:99999:7:::' \
'nobody:*:19448:0:99999:7:::' \
> /etc/shadow \
&& chmod 640 /etc/shadow \
# 安装依赖(--no-install-recommends 避免拉入 systemd 等不必要的包)
&& apt-get update \
&& apt-get install -y --no-install-recommends \
locales fonts-noto-cjk fonts-noto-color-emoji \
curl ca-certificates \
libgtk-3-0 libnss3 libnspr4 libgbm1 \
libxkbcommon0 libxkbcommon-x11-0 libx11-xcb1 \
libxcb-icccm4 libxcb-image0 libxcb-keysyms1 \
libxcb-randr0 libxcb-render-util0 libxcb-shape0 \
libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 \
libxcb-xkb1 libxcb-xinerama0 libxcb-glx0 \
libxtst6 libxss1 \
libasound2 libpulse0 libatomic1 \
# 生成中文 locale
&& sed -i 's/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen \
&& locale-gen \
# 清理
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 微信应用图标
RUN APP_ICON_URL=https://res.wx.qq.com/a/wx_fed/assets/res/NTI4MWU5.ico \
&& install_app_icon.sh "$APP_ICON_URL"
# 应用名称
RUN set-cont-env APP_NAME "Wechat" \
&& chmod -x /etc/cont-env.d/APP_NAME
# 注意:构建阶段保留 /etc/passwd, /etc/group, /etc/shadow 为真实文件,
# 以确保后续 Dockerfile 中的 dpkg 操作正常工作。
# 符号链接将在最终 Dockerfile 的最后一步恢复,供运行时 s6 init 使用。