From 978c0ecd19276550797fdd64b169cde6f732eb69 Mon Sep 17 00:00:00 2001 From: Pablo Aramburo Date: Sat, 17 Sep 2022 19:57:58 -0600 Subject: [PATCH] [add] Forcing proxy refresh on container run --- .dockerignore | 2 ++ Dockerfile | 18 +++++++++++++++++- docker-compose.yml | 4 +--- entrypoint.sh | 5 +++++ 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100755 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..32c556b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +proxies.txt +.git/ diff --git a/Dockerfile b/Dockerfile index 20a9c78..2d7f03c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# Build stage FROM golang:1.15-alpine AS build ARG VERSION @@ -13,8 +14,23 @@ RUN go mod download RUN go build -ldflags "-s -w -X ktbs.dev/mubeng/common.Version=${VERSION}" \ -o ./bin/mubeng ./cmd/mubeng +# Production build FROM python:3.10-alpine3.16 COPY --from=build /app/bin/mubeng /bin/mubeng + +# Installing the python scripts +WORKDIR /app + +COPY requirements.txt /app +RUN pip install --no-cache-dir -r requirements.txt + +COPY scrape_proxies.py /app + +COPY entrypoint.sh /app + ENV HOME / -ENTRYPOINT ["/bin/mubeng"] + +VOLUME /mubeng/ + +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index 656bb23..04bdae7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,4 @@ services: restart: always ports: - "8080:8080" - volumes: - - .:/mubeng - command: '--check --address 0.0.0.0:8080 --rotate 1 --method random --file /mubeng/proxies.txt --watch --timeout 10s' + # command: '--check --address 0.0.0.0:8080 --rotate 1 --method random --file /mubeng/proxies.txt --watch --timeout 10s' diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..4ea600a --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +python3 /app/scrape_proxies.py | tee /mubeng/proxies.txt + +/bin/mubeng --check --address 0.0.0.0:8080 --rotate 1 --method random --file /mubeng/proxies.txt --watch --timeout 10s