forked from DevOps/deploy.stack
build(docker): 添加Ansible的Dockerfile配置
添加一个新的Dockerfile用于构建Ansible环境,包括安装必要的依赖、配置国内镜像源、创建非root用户以提高安全性,并设置默认入口点
This commit is contained in:
25
ansible/dockerfile
Normal file
25
ansible/dockerfile
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
FROM python:3.13.3-alpine
|
||||||
|
# 使用国内镜像源
|
||||||
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
||||||
|
|
||||||
|
# 安装必要的依赖
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
openssh-client \
|
||||||
|
sshpass \
|
||||||
|
git \
|
||||||
|
rsync
|
||||||
|
|
||||||
|
# 安装Ansible及相关工具
|
||||||
|
RUN pip install --no-cache-dir \
|
||||||
|
ansible \
|
||||||
|
ansible-lint \
|
||||||
|
jmespath
|
||||||
|
|
||||||
|
# 创建非root用户(安全建议)
|
||||||
|
RUN adduser -D ansible-user
|
||||||
|
USER ansible-user
|
||||||
|
WORKDIR /home/ansible-user
|
||||||
|
|
||||||
|
# 入口点配置
|
||||||
|
ENTRYPOINT ["ansible"]
|
||||||
|
CMD ["--version"]
|
||||||
Reference in New Issue
Block a user