Dockerfile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Dockerfile for hyperledger cello ansible agent
  2. #
  3. # @see https://github.com/hyperledger/cello/blob/master/docs/worker_ansible_howto.md
  4. #
  5. FROM alpine/git AS BUILD
  6. RUN cd /tmp && git init cello && cd cello && \
  7. git remote add origin https://github.com/hyperledger/cello.git && \
  8. git config core.sparsecheckout true && \
  9. echo "src/agent/ansible/*" >> .git/info/sparse-checkout && \
  10. git pull --depth=1 origin master
  11. FROM ubuntu:xenial
  12. MAINTAINER Tong Li <litong01@us.ibm.com>
  13. ARG user=ubuntu
  14. ARG uid=1000
  15. ARG gid=1000
  16. RUN apt-get update && \
  17. apt-get install -y bash sshpass python-pip openssh-client sudo && \
  18. pip install --upgrade pip ansible boto boto3 shade \
  19. pyyaml && \
  20. groupadd -g ${gid} ${user} && \
  21. useradd -d /opt/agent -u ${uid} -g ${user} ${user} && \
  22. usermod -a -G root ${user} && \
  23. echo "${user} ALL=(ALL) NOPASSWD: ALL"|tee /etc/sudoers.d/${user} && \
  24. mkdir -p /opt/agent/.ssh && \
  25. cd /opt/agent/.ssh && \
  26. echo "host *" > config && \
  27. echo " StrictHostKeyChecking no" >> config && \
  28. echo " UserKnownHostsFile /dev/null" >> config
  29. COPY --from=build /tmp/cello/src/agent/ansible /opt/agent
  30. RUN ssh-keygen -q -t rsa -N '' -f /opt/agent/vars/fd && \
  31. chown -R ${uid}:${gid} /opt/agent && \
  32. chmod 755 /opt/agent/entrypoint.sh
  33. ENV HOME /opt/agent
  34. ENV WORKDIR /opt/agent
  35. WORKDIR /opt/agent
  36. USER ${user}
  37. ENTRYPOINT ["/opt/agent/entrypoint.sh"]
  38. CMD [ "ansible-playbook", "--version" ]