Dockerfile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # sync with https://github.com/fphammerle/wireless-sensor-mqtt/blob/master/Dockerfile
  2. ARG BASE_IMAGE=python:3.8-alpine3.13
  3. ARG SOURCE_DIR_PATH=/intertechno-cc1101-mqtt
  4. # hadolint ignore=DL3006
  5. FROM $BASE_IMAGE as build
  6. RUN apk add --no-cache \
  7. gcc `# spidev build` \
  8. git `# setuptools_scm` \
  9. jq `# edit Pipfile.lock` \
  10. linux-headers `# spidev build linux/spi/spidev.h` \
  11. musl-dev `# spidev build` \
  12. && adduser -S build
  13. USER build
  14. RUN pip install --user --no-cache-dir pipenv==2020.6.2
  15. ARG SOURCE_DIR_PATH
  16. COPY --chown=build:nobody Pipfile Pipfile.lock $SOURCE_DIR_PATH/
  17. WORKDIR $SOURCE_DIR_PATH
  18. ENV PIPENV_CACHE_DIR=/tmp/pipenv-cache \
  19. PIPENV_VENV_IN_PROJECT=yes-please \
  20. PATH=/home/build/.local/bin:$PATH
  21. # `sponge` is not pre-installed
  22. RUN jq 'del(.default."intertechno-cc1101-mqtt")' Pipfile.lock > Pipfile.lock~ \
  23. && mv Pipfile.lock~ Pipfile.lock \
  24. && pipenv install --deploy --verbose
  25. COPY --chown=build:nobody . $SOURCE_DIR_PATH
  26. RUN pipenv install --deploy --verbose \
  27. && pipenv graph \
  28. && pipenv run pip freeze \
  29. && rm -r .git/ $PIPENV_CACHE_DIR \
  30. && chmod -cR a+rX .
  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. USER build
  36. # hadolint ignore=DL3006
  37. FROM $BASE_IMAGE
  38. RUN apk add --no-cache \
  39. ca-certificates \
  40. tini \
  41. && find / -xdev -type f -perm /u+s -exec chmod -c u-s {} \; \
  42. && find / -xdev -type f -perm /g+s -exec chmod -c g-s {} \;
  43. USER nobody
  44. ARG SOURCE_DIR_PATH
  45. COPY --from=build $SOURCE_DIR_PATH $SOURCE_DIR_PATH
  46. ARG VIRTUALENV_PATH=$SOURCE_DIR_PATH/.venv
  47. ENV PATH=$VIRTUALENV_PATH/bin:$PATH
  48. ENTRYPOINT ["tini", "--"]
  49. CMD ["intertechno-cc1101-mqtt", "--help"]