1
0

Dockerfile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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=/switchbot-mqtt
  5. ARG VIRTUALENV_PATH=$SOURCE_DIR_PATH/.venv
  6. FROM $BASE_IMAGE as build
  7. RUN apk add --no-cache \
  8. gcc \
  9. git `# setuptools_scm` \
  10. glib-dev \
  11. make \
  12. musl-dev \
  13. py3-virtualenv
  14. ARG SOURCE_DIR_PATH
  15. RUN mkdir $SOURCE_DIR_PATH \
  16. && chown nobody $SOURCE_DIR_PATH
  17. USER nobody
  18. ARG VIRTUALENV_PATH
  19. RUN virtualenv --no-site-packages $VIRTUALENV_PATH
  20. ENV PATH=$VIRTUALENV_PATH/bin:$PATH
  21. WORKDIR $SOURCE_DIR_PATH
  22. RUN pip install --no-cache-dir pipenv
  23. COPY --chown=nobody . $SOURCE_DIR_PATH
  24. RUN pipenv install --deploy --verbose \
  25. && rm -r .git/
  26. # workaround for broken multi-stage copy
  27. # > failed to copy files: failed to copy directory: Error processing tar file(exit status 1): Container ID ... cannot be mapped to a host ID
  28. USER 0
  29. RUN chown -R 0:0 $SOURCE_DIR_PATH
  30. FROM $BASE_IMAGE
  31. RUN apk add --no-cache \
  32. glib \
  33. python3 \
  34. tini \
  35. && find / -xdev -type f -perm /u+s -exec chmod -c u-s {} \; \
  36. && find / -xdev -type f -perm /g+s -exec chmod -c g-s {} \;
  37. #RUN apk add bluez-deprecated `# hcitool`
  38. USER nobody
  39. ARG SOURCE_DIR_PATH
  40. COPY --from=build $SOURCE_DIR_PATH $SOURCE_DIR_PATH
  41. ARG VIRTUALENV_PATH
  42. ENV PATH=$VIRTUALENV_PATH/bin:$PATH
  43. ENTRYPOINT ["tini", "--"]
  44. CMD ["switchbot-mqtt", "--help"]