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.

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