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.

157 lines
5.5 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 shyaml
  46. RUN pip install crudini
  47. RUN apk add libffi-dev openssl-dev && \
  48. pip install pip==19.3.1 cffi==1.12.3 pyrsistent==0.16.0 docker==4.3.0 cryptography==3.0 \
  49. git+https://github.com/0k/compose@run_ignore_orphans
  50. # docker-compose==$DOCKER_COMPOSE_VERSION
  51. # pip install git+https://github.com/vaab/colour@master
  52. ENV SCRIPT_CHARM_SHA="2da0d3f" \
  53. SCRIPT_GIT_SUB_SHA="9c1c88b" \
  54. SCRIPT_DUPD_SHA="08c71ec" \
  55. SCRIPT_XPATH_SHA="0.4.5"
  56. RUN export pkg ; \
  57. for pkg in charm git-sub dupd xpath; do \
  58. echo "Getting $pkg..." ; \
  59. bash -c -- 'varname=${pkg^^} ; varname=${varname//-/_} ; \
  60. eval curl https://docker.0k.io/downloads/$pkg-\${SCRIPT_${varname^^}_SHA}' > \
  61. /usr/local/bin/"$pkg" || exit 1 ; \
  62. chmod +x /usr/local/bin/"$pkg" ; \
  63. done
  64. RUN curl http://docker.0k.io/get/ca.0k.io.pem > /usr/local/share/ca-certificates/ca.0k.io.pem
  65. ##force install pyyaml with libyaml
  66. RUN cd /tmp && \
  67. wget https://github.com/yaml/pyyaml/archive/5.4.1.tar.gz && \
  68. tar xvzf 5.4.1.tar.gz && \
  69. cd pyyaml-5.4.1 && \
  70. pip install cython==0.29.32 && \
  71. PYTHONPATH=/usr/lib/python2.7/site-packages python setup.py --with-libyaml install
  72. ## needed by 'xpath' script from kal-scripts for parsing html output
  73. RUN apk add libxslt-dev && \
  74. pip install lxml==4.5.2 html5lib==1.1 webencodings==0.5.1
  75. FROM common
  76. COPY --from=builder /etc/shlib /etc/shlib
  77. COPY --from=builder /usr/bin/bash-shlib /usr/bin/bash-shlib
  78. COPY --from=builder /usr/lib/shlib /usr/lib/shlib
  79. COPY --from=builder /usr/local /usr/local
  80. RUN cp /usr/local/share/ca-certificates/ca.0k.io.pem /etc/ssl/ca.0k.io.pem && \
  81. apk add ca-certificates && update-ca-certificates && \
  82. mkdir -p /etc/docker/certs.d/docker.0k.io && \
  83. ln -sfn /etc/ssl/ca.0k.io.pem /etc/docker/certs.d/docker.0k.io/ca.crt
  84. ## requiring ``stdbuf`` for actions
  85. RUN apk add coreutils
  86. ## requiring ``openssl`` command for certificate generation in charms
  87. RUN apk add openssl
  88. ## requiring ``htpasswd`` command for BCrypt encryption
  89. RUN apk add apache2-utils
  90. ## requiring ``jq`` command for json querying/modifying in charms
  91. RUN apk add jq
  92. ## requiring ``getfacl/setfacl`` command for allowing to setup some permissions in charms
  93. RUN apk add acl
  94. ## required by git through ssh (for host-resources for instance)
  95. RUN apk add openssh-client
  96. ## handy in some charms to poke at some services
  97. RUN apk add curl wget
  98. ## handy in some charms or action to recode some output
  99. RUN apk add recode
  100. ## handy yaml2json converter for charm
  101. RUN wget https://github.com/bronze1man/yaml2json/releases/download/v1.3/yaml2json_linux_amd64 \
  102. -O /usr/local/bin/yaml2json && \
  103. chmod +x /usr/local/bin/yaml2json
  104. ## ``yq`` will probably replace shyaml
  105. RUN wget https://github.com/mikefarah/yq/releases/download/v4.34.2/yq_linux_amd64 \
  106. -O /usr/local/bin/yq && \
  107. chmod +x /usr/local/bin/yq
  108. ## handy in some charms or action to recode some output
  109. RUN apk add patch
  110. ## Fixing Let's encrypt CA issue from 2021-10-01, probably can remove
  111. ## with newer alpine version (was added with alpine 3.7.1)
  112. RUN sed -ri 's%^(mozilla/DST_Root_CA_X3.crt)%!\\1%g' /etc/ca-certificates.conf && \
  113. update-ca-certificates
  114. ## install compose
  115. COPY ./bin/ /usr/local/bin/
  116. ## Fixes Ctrl-C handling:
  117. ## see https://github.com/moby/moby/issues/2838#issuecomment-402491110
  118. RUN apk add --no-cache tini
  119. # Tini is now available at /sbin/tini
  120. ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/compose-core"]