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:
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
Reference in New Issue
Block a user