admin · 9月4日 · 2020年
#createrepo
FROM centos:7.8.2003
MAINTAINER dockerliu177 "luckinserver.cn"
CMD ["/bin/bash"]
RUN curl -o /etc/yum.repos.d/local.repo https://download.luckinserver.cn:90/repo/local.repo
RUN yum install -y createrepo inotify-tools nginx && yum clean all
RUN rm -f /etc/nginx/conf.d/default.conf
COPY createrepo.conf /etc/nginx/conf.d
RUN mkdir /repo
RUN chown root.root /repo
RUN chown 755 /repo
RUN mkdir /script
COPY start.sh /script
RUN chmod -R 755 /script
ENTRYPOINT ["/script/start.sh"]
---------------------------------------------------------------------------------------------------------------------------------
#start.sh
#!/bin/bash
/usr/sbin/nginx &
path=/repo
/usr/bin/inotifywait -mrq --format '%w%f' --exclude '^/repo/(repodata|.repodata|.olddata)' -e create,delete,moved_to,moved_from $path | while read line
do
createrepo --update $path > /dev/null 2>&1
echo "update $line successful"
done
EOF
---------------------------------------------------------------------------------------------------------------------------------
#createrepo.conf
cat >createrepo.conf<<EOF
server {
listen 80;
server_name _;
charset utf-8,gbk;
root /repo;
autoindex on;
}
EOF