Refactor Scraper Dockerfile and Add Entrypoint Script

- Replaced inline entrypoint script creation in the Dockerfile with a separate entrypoint.sh file for better maintainability and clarity.
- The new entrypoint script handles one-time scraping with date range support, improving the scraper's functionality and usability.
This commit is contained in:
Nima Nakhostin
2025-11-23 13:48:27 +03:30
parent 1f6d3fd1cb
commit f1bdacdc98
2 changed files with 12 additions and 9 deletions
+3 -9
View File
@@ -17,15 +17,9 @@ WORKDIR /app
COPY --from=go-builder /app/scraper-build . COPY --from=go-builder /app/scraper-build .
# Create entrypoint script # Copy and set up entrypoint script
RUN echo '#!/bin/bash' > /app/entrypoint.sh && \ COPY cmd/scraper/entrypoint.sh /app/entrypoint.sh
echo 'set -e' >> /app/entrypoint.sh && \ RUN chmod +x /app/entrypoint.sh
echo 'if [ "$SCRAPER_ONETIME" = "true" ] && [ -n "$FROM_DATE" ] && [ -n "$TO_DATE" ]; then' >> /app/entrypoint.sh && \
echo ' exec /app/scraper-build -onetime -from "$FROM_DATE" -to "$TO_DATE"' >> /app/entrypoint.sh && \
echo 'else' >> /app/entrypoint.sh && \
echo ' exec /app/scraper-build' >> /app/entrypoint.sh && \
echo 'fi' >> /app/entrypoint.sh && \
chmod +x /app/entrypoint.sh
EXPOSE 80 EXPOSE 80
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
set -e
if [ "$SCRAPER_ONETIME" = "true" ] && [ -n "$FROM_DATE" ] && [ -n "$TO_DATE" ]; then
exec /app/scraper-build -onetime -from "$FROM_DATE" -to "$TO_DATE"
else
exec /app/scraper-build
fi