You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
5.6 KiB

  1. FROM python:2-alpine3.11 as common
  2. CMD ["/bin/sh"]
  3. RUN apk --no-cache --update add git bash yaml sed lsof findutils diffutils
  4. RUN apk --no-cache --update add libxslt
  5. FROM common as builder
  6. RUN apk --update add curl
  7. ## would love to use args... but I need it as an environment variable
  8. ENV KAL_SHLIB_ARRAY_VERSION="0.2.0" \
  9. KAL_SHLIB_CACHE_VERSION="0.0.1" \
  10. KAL_SHLIB_CHARM_VERSION="0.5.3" \
  11. KAL_SHLIB_CMDLINE_VERSION="0.0.5" \
  12. KAL_SHLIB_COMMON_VERSION="0.4.22" \
  13. KAL_SHLIB_CONFIG_VERSION="0.0.2" \
  14. KAL_SHLIB_CORE_VERSION="0.7.0" \
  15. KAL_SHLIB_FIREWALL_VERSION="0.2.0" \
  16. KAL_SHLIB_DOCKER_VERSION="0.0.9" \
  17. KAL_SHLIB_OTHER_VERSION="0.2.2" \
  18. KAL_SHLIB_PRETTY_VERSION="0.4.3"
  19. ARG DOCKER_CLI_VERSION="17.06.2-ce"
  20. ARG DOCKER_COMPOSE_VERSION="1.24.0"
  21. ## install docker
  22. ENV DOCKER_DOWNLOAD_URL="https://download.docker.com/linux/static/stable/x86_64/docker-$DOCKER_CLI_VERSION.tgz"
  23. RUN mkdir -p /tmp/docker \
  24. && curl -L "$DOCKER_DOWNLOAD_URL" | tar -xz -C /tmp/docker \
  25. && mv /tmp/docker/docker/docker /usr/local/bin/ \
  26. && rm -rf /tmp/docker
  27. ## install docker-compose
  28. # ENV DOCKER_COMPOSE_DOWNLOAD_URL="https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-Linux-x86_64"
  29. # RUN curl -L "$DOCKER_COMPOSE_DOWNLOAD_URL" > /usr/local/bin/docker-compose \
  30. # && chmod +x /usr/local/bin/docker-compose
  31. ## install kal-shlibs
  32. RUN apk --update add binutils && \
  33. mkdir /tmp/kal-shlibs && cd /tmp/kal-shlibs && \
  34. export pkg && \
  35. for pkg in core common array cache charm cmdline config firewall other pretty docker; do \
  36. echo "Installing kal-shlib-$pkg" ; \
  37. bash -c -- 'eval curl -L http://deb.kalysto.org/pool/no-dist/kal-alpha/kal-shlib-${pkg}_\${KAL_SHLIB_${pkg^^}_VERSION}-1_all.deb' > pkg.deb || exit 1 ; \
  38. ar x pkg.deb || exit 1; \
  39. tar xf /tmp/kal-shlibs/data.tar.* -C / || exit 1; \
  40. rm /tmp/kal-shlibs/data.tar.* ; \
  41. done
  42. ## install shyaml
  43. RUN apk add python-dev build-base
  44. RUN apk add yaml-dev cython cython-dev && \
  45. pip install "cython<3.0.0" wheel && \
  46. pip install pyyaml==5.4.1 --no-build-isolation && \
  47. pip install shyaml
  48. RUN pip install crudini
  49. RUN apk add libffi-dev openssl-dev && \
  50. pip install pip==19.3.1 cffi==1.12.3 pyrsistent==0.16.0 docker==4.3.0 cryptography==3.0 \
  51. git+https://github.com/0k/compose@run_ignore_orphans
  52. # docker-compose==$DOCKER_COMPOSE_VERSION
  53. # pip install git+https://github.com/vaab/colour@master
  54. ENV SCRIPT_CHARM_SHA="2da0d3f" \
  55. SCRIPT_GIT_SUB_SHA="9c1c88b" \
  56. SCRIPT_DUPD_SHA="08c71ec" \
  57. SCRIPT_XPATH_SHA="0.4.5"
  58. RUN export pkg ; \
  59. for pkg in charm git-sub dupd xpath; do \
  60. echo "Getting $pkg..." ; \
  61. bash -c -- 'varname=${pkg^^} ; varname=${varname//-/_} ; \
  62. eval curl https://docker.0k.io/downloads/$pkg-\${SCRIPT_${varname^^}_SHA}' > \
  63. /usr/local/bin/"$pkg" || exit 1 ; \
  64. chmod +x /usr/local/bin/"$pkg" ; \
  65. done
  66. RUN curl http://docker.0k.io/get/ca.0k.io.pem > /usr/local/share/ca-certificates/ca.0k.io.pem
  67. ##force install pyyaml with libyaml
  68. RUN cd /tmp && \
  69. wget https://github.com/yaml/pyyaml/archive/5.4.1.tar.gz && \
  70. tar xvzf 5.4.1.tar.gz && \
  71. cd pyyaml-5.4.1 && \
  72. pip install cython==0.29.32 && \
  73. PYTHONPATH=/usr/lib/python2.7/site-packages python setup.py --with-libyaml install
  74. ## needed by 'xpath' script from kal-scripts for parsing html output
  75. RUN apk add libxslt-dev && \
  76. pip install lxml==4.5.2 html5lib==1.1 webencodings==0.5.1
  77. FROM common
  78. COPY --from=builder /etc/shlib /etc/shlib
  79. COPY --from=builder /usr/bin/bash-shlib /usr/bin/bash-shlib
  80. COPY --from=builder /usr/lib/shlib /usr/lib/shlib
  81. COPY --from=builder /usr/local /usr/local
  82. RUN cp /usr/local/share/ca-certificates/ca.0k.io.pem /etc/ssl/ca.0k.io.pem && \
  83. apk add ca-certificates && update-ca-certificates && \
  84. mkdir -p /etc/docker/certs.d/docker.0k.io && \
  85. ln -sfn /etc/ssl/ca.0k.io.pem /etc/docker/certs.d/docker.0k.io/ca.crt
  86. ## requiring ``stdbuf`` for actions
  87. RUN apk add coreutils
  88. ## requiring ``openssl`` command for certificate generation in charms
  89. RUN apk add openssl
  90. ## requiring ``htpasswd`` command for BCrypt encryption
  91. RUN apk add apache2-utils
  92. ## requiring ``jq`` command for json querying/modifying in charms
  93. RUN apk add jq
  94. ## requiring ``getfacl/setfacl`` command for allowing to setup some permissions in charms
  95. RUN apk add acl
  96. ## required by git through ssh (for host-resources for instance)
  97. RUN apk add openssh-client
  98. ## handy in some charms to poke at some services
  99. RUN apk add curl wget
  100. ## handy in some charms or action to recode some output
  101. RUN apk add recode
  102. ## handy yaml2json converter for charm
  103. RUN wget https://github.com/bronze1man/yaml2json/releases/download/v1.3/yaml2json_linux_amd64 \
  104. -O /usr/local/bin/yaml2json && \
  105. chmod +x /usr/local/bin/yaml2json
  106. ## ``yq`` will probably replace shyaml
  107. RUN wget https://github.com/mikefarah/yq/releases/download/v4.34.2/yq_linux_amd64 \
  108. -O /usr/local/bin/yq && \
  109. chmod +x /usr/local/bin/yq
  110. ## handy in some charms or action to recode some output
  111. RUN apk add patch
  112. ## Fixing Let's encrypt CA issue from 2021-10-01, probably can remove
  113. ## with newer alpine version (was added with alpine 3.7.1)
  114. RUN sed -ri 's%^(mozilla/DST_Root_CA_X3.crt)%!\\1%g' /etc/ca-certificates.conf && \
  115. update-ca-certificates
  116. ## install compose
  117. COPY ./bin/ /usr/local/bin/
  118. ## Fixes Ctrl-C handling:
  119. ## see https://github.com/moby/moby/issues/2838#issuecomment-402491110
  120. RUN apk add --no-cache tini
  121. # Tini is now available at /sbin/tini
  122. ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/compose-core"]