Dockerfile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # not using python:3.*-alpine cause glib-dev package depends on python3
  2. # https://pkgs.alpinelinux.org/package/v3.11/main/aarch64/glib-dev
  3. ARG BASE_IMAGE=alpine:3.11
  4. ARG SOURCE_DIR_PATH=/systemctl-mqtt
  5. # hadolint ignore=DL3006
  6. FROM $BASE_IMAGE as build
  7. RUN apk add --no-cache \
  8. cairo-dev `# PyGObject > pycairo` \
  9. dbus-dev \
  10. gcc \
  11. git `# setuptools_scm` \
  12. glib-dev `# dbus-python` \
  13. gobject-introspection-dev `# PyGObject` \
  14. make `# dbus-python` \
  15. musl-dev `# dbus-python` \
  16. py3-certifi `# pipenv` \
  17. py3-virtualenv `# pipenv` \
  18. python3-dev `# dbus-python` \
  19. && adduser -S build
  20. USER build
  21. RUN pip3 install --user --no-cache-dir pipenv==2020.6.2
  22. ARG SOURCE_DIR_PATH
  23. COPY --chown=build:1234 . $SOURCE_DIR_PATH
  24. WORKDIR $SOURCE_DIR_PATH
  25. ENV PIPENV_CACHE_DIR=/tmp/pipenv-cache \
  26. PIPENV_VENV_IN_PROJECT=yes-please \
  27. PATH=/home/build/.local/bin:$PATH
  28. RUN pipenv install --deploy --verbose \
  29. && pipenv graph \
  30. && pipenv run pip freeze \
  31. && rm -r .git/ $PIPENV_CACHE_DIR
  32. # workaround for broken multi-stage copy
  33. # > failed to copy files: failed to copy directory: Error processing tar file(exit status 1): Container ID ... cannot be mapped to a host ID
  34. USER 0
  35. RUN chown -R 0:0 $SOURCE_DIR_PATH
  36. USER build
  37. # hadolint ignore=DL3006
  38. FROM $BASE_IMAGE
  39. RUN apk add --no-cache \
  40. ca-certificates \
  41. dbus-libs \
  42. glib `# PyGObject` \
  43. gobject-introspection `# PyGObject` \
  44. python3 \
  45. tini \
  46. && find / -xdev -type f -perm /u+s -exec chmod -c u-s {} \; \
  47. && find / -xdev -type f -perm /g+s -exec chmod -c g-s {} \;
  48. USER nobody
  49. ARG SOURCE_DIR_PATH
  50. COPY --from=build $SOURCE_DIR_PATH $SOURCE_DIR_PATH
  51. ARG VIRTUALENV_PATH=$SOURCE_DIR_PATH/.venv
  52. ENV PATH=$VIRTUALENV_PATH/bin:$PATH
  53. ENTRYPOINT ["tini", "--"]
  54. CMD ["systemctl-mqtt", "--help"]