Dockerfile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. FROM golang:1.22-alpine as builder
  2. ARG VERSION=unknown
  3. # copy project
  4. COPY . /app
  5. # set working directory
  6. WORKDIR /app
  7. # using goproxy if you have network issues
  8. # ENV GOPROXY=https://goproxy.cn,direct
  9. # build
  10. RUN go build \
  11. -ldflags "\
  12. -X 'github.com/langgenius/dify-plugin-daemon/internal/manifest.VersionX=${VERSION}' \
  13. -X 'github.com/langgenius/dify-plugin-daemon/internal/manifest.BuildTimeX=$(date -u +%Y-%m-%dT%H:%M:%S%z)'" \
  14. -o /app/main cmd/server/main.go
  15. # copy entrypoint.sh
  16. COPY entrypoint.sh /app/entrypoint.sh
  17. RUN chmod +x /app/entrypoint.sh
  18. FROM ubuntu:24.04
  19. COPY --from=builder /app/main /app/main
  20. COPY --from=builder /app/entrypoint.sh /app/entrypoint.sh
  21. WORKDIR /app
  22. # check build args
  23. ARG PLATFORM=local
  24. # Install python3.12 if PLATFORM is local
  25. RUN if [ "$PLATFORM" = "local" ]; then \
  26. apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y python3.12 python3.12-venv python3.12-dev \
  27. && apt-get clean \
  28. && rm -rf /var/lib/apt/lists/* \
  29. && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1; \
  30. fi
  31. ENV PLATFORM=$PLATFORM
  32. ENV GIN_MODE=release
  33. # run the server, using sh as the entrypoint to avoid process being the root process
  34. # and using bash to recycle resources
  35. CMD ["/bin/bash", "-c", "/app/entrypoint.sh"]