Dockerfile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #
  2. # Step 1: Build sydent and install dependencies
  3. #
  4. FROM docker.io/python:3.8-slim as builder
  5. # Install dev packages
  6. RUN apt-get update && apt-get install -y \
  7. build-essential
  8. # Add user sydent
  9. RUN addgroup --system --gid 993 sydent \
  10. && adduser --disabled-password --home /sydent --system --uid 993 --gecos sydent sydent \
  11. && echo "sydent:$(dd if=/dev/random bs=32 count=1 | base64)" | chpasswd
  12. # Copy resources
  13. COPY --chown=sydent:sydent ["res", "/sydent/res"]
  14. COPY --chown=sydent:sydent ["scripts", "/sydent/scripts"]
  15. COPY --chown=sydent:sydent ["sydent", "/sydent/sydent"]
  16. COPY --chown=sydent:sydent ["README.rst", "setup.cfg", "setup.py", "/sydent/"]
  17. # Install dependencies
  18. USER sydent
  19. WORKDIR /sydent
  20. RUN pip install --user --upgrade pip setuptools sentry-sdk prometheus_client \
  21. && pip install --user . \
  22. && rm -rf /sydent/.cache \
  23. && find /sydent -name '*.pyc' -delete
  24. #
  25. # Step 2: Reduce image size and layers
  26. #
  27. FROM docker.io/python:3.8-slim
  28. # Add user sydent and create /data directory
  29. RUN addgroup --system --gid 993 sydent \
  30. && adduser --disabled-password --home /sydent --system --uid 993 --gecos sydent sydent \
  31. && echo "sydent:$(dd if=/dev/random bs=32 count=1 | base64)" | chpasswd \
  32. && mkdir /data \
  33. && chown sydent:sydent /data
  34. # Copy sydent
  35. COPY --from=builder ["/sydent", "/sydent"]
  36. ENV SYDENT_CONF=/data/sydent.conf
  37. ENV SYDENT_PID_FILE=/data/sydent.pid
  38. ENV SYDENT_DB_PATH=/data/sydent.db
  39. WORKDIR /sydent
  40. USER sydent:sydent
  41. VOLUME ["/data"]
  42. EXPOSE 8090/tcp
  43. CMD [ "python", "-m", "sydent.sydent" ]