Dockerfile 1.8 KB

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