Dockerfile 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #
  2. # Step 1: Build sydent and install dependencies
  3. #
  4. FROM docker.io/python:3.8-alpine as builder
  5. # Install dev packages
  6. RUN apk add --no-cache \
  7. build-base \
  8. libressl-dev \
  9. libffi-dev
  10. # Add user sydent
  11. RUN addgroup -S -g 993 sydent \
  12. && adduser -D --home /sydent -S -u 993 -G sydent -s /bin/ash sydent \
  13. && echo "sydent:$(dd if=/dev/random bs=32 count=1 | base64)" | chpasswd
  14. # Copy resources
  15. COPY --chown=sydent:sydent ["res", "/sydent/res"]
  16. COPY --chown=sydent:sydent ["scripts", "/sydent/scripts"]
  17. COPY --chown=sydent:sydent ["sydent", "/sydent/sydent"]
  18. COPY --chown=sydent:sydent ["README.rst", "setup.cfg", "setup.py", "/sydent/"]
  19. # Install dependencies
  20. RUN cd /sydent \
  21. && su sydent -c 'pip install --user --upgrade pip setuptools sentry-sdk prometheus_client' \
  22. && su sydent -c 'pip install --user -e .' \
  23. && rm -rf /sydent/.cache \
  24. && find /sydent -name '*.pyc' -delete
  25. #
  26. # Step 2: Reduce image size and layers
  27. #
  28. FROM docker.io/python:3.8-alpine
  29. # Install packages
  30. RUN apk add --no-cache \
  31. libressl \
  32. libffi
  33. # Add user sydent and create /data directory
  34. RUN addgroup -S -g 993 sydent \
  35. && adduser -D --home /sydent -S -u 993 -G sydent -s /bin/ash sydent \
  36. && echo "sydent:$(dd if=/dev/random bs=32 count=1 | base64)" | chpasswd \
  37. && mkdir /data \
  38. && chown sydent:sydent /data
  39. # Copy sydent
  40. COPY --from=builder ["/sydent", "/sydent"]
  41. ENV SYDENT_CONF=/data/sydent.conf
  42. ENV SYDENT_PID_FILE=/data/sydent.pid
  43. ENV SYDENT_DB_PATH=/data/sydent.db
  44. WORKDIR /sydent
  45. USER sydent:sydent
  46. VOLUME ["/data"]
  47. EXPOSE 8090/tcp
  48. CMD [ "python", "-m", "sydent.sydent" ]