local.dockerfile 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y python3.12 python3.12-venv python3.12-dev \
  26. && apt-get clean \
  27. && rm -rf /var/lib/apt/lists/* \
  28. && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1;
  29. ENV PLATFORM=$PLATFORM
  30. ENV GIN_MODE=release
  31. # run the server, using sh as the entrypoint to avoid process being the root process
  32. # and using bash to recycle resources
  33. CMD ["/bin/bash", "-c", "/app/entrypoint.sh"]