[fix]增加使用Dockerfile变量定义用户

This commit is contained in:
2020-09-10 09:40:19 +08:00
parent def535c123
commit 22fe2fbfce
3 changed files with 7 additions and 3 deletions
+2
View File
@@ -5,6 +5,8 @@ FROM debian:buster-slim
# APT源配置:default / tencent / ustc / aliyun / huawei
ARG apt_source=tencent
ENV APP_USER=builder
LABEL \
"Version"="v10" \
"Description"="Docker image for Builder based on Debian." \
+2
View File
@@ -8,6 +8,8 @@ FROM alpine:3.12
# APK源配置:default / tencent / ustc / aliyun / huawei
ARG apt_source=tencent
ENV APP_USER=builder
LABEL \
"Version"="v3.12" \
"Description"="Docker image for Builder based on Alpine." \
+3 -3
View File
@@ -1,9 +1,9 @@
#!/bin/bash
# shell 执行参数,分别为 -e(命令执行错误则退出脚本) -u(变量未定义则报错) -x(打印实际待执行的命令行)
set -eux
groupadd --gid 998 --system builder
useradd --gid 998 --uid 999 --shell /bin/bash --home /srv/data --system builder
groupadd --gid 998 --system ${APP_USER}
useradd --gid 998 --uid 999 --shell /bin/bash --home /srv/data --system ${APP_USER}
# 如果需要 sudo 权限,需要安装 su 软件包:apk add sudo
sed -i -e 's/^\sDefaults\s*secure_path\s*=/# Defaults secure_path=/' /etc/sudoers
echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
echo "${APP_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers