diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e256820 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,20 @@ +tmp/* +log/* +db/*.sqlite3 +.git +.github + +.env +.env.* + +/vendor/* +/test/* + +*.DS_Store +.vscode/ +*.swp +*~ +*.md + +run +build diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a6b2c49 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: + - package-ecosystem: "docker" # See documentation for possible values + directory: "/" # Location of package manifests + open-pull-requests-limit: 5 + schedule: + interval: "monthly" + reviewers: + - "apptweak/qawaii" diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..dd74694 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "enabledManagers": ["dockerfile"], + "labels": ["dependencies", "renovate", "docker"], + "prConcurrentLimit": 5, + "rangeStrategy": "bump", + "separateMinorPatch": true, + "packageRules": [ + { + "matchUpdateTypes": ["major"], + "enabled": false + } + ], + "dockerfile": { + "updateFiles": ["Dockerfile"], + "fileMatch": ["Dockerfile"] + } + } diff --git a/.github/workflows/hadolint.yml b/.github/workflows/hadolint.yml new file mode 100644 index 0000000..1d831fb --- /dev/null +++ b/.github/workflows/hadolint.yml @@ -0,0 +1,22 @@ +name: Hadolint + +on: + push: + branches: + - "main" + paths: + - "Dockerfile" + pull_request: + types: [opened, synchronize] + paths: + - "Dockerfile" + +jobs: + hadolint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: hadolint/hadolint-action@v1.6.0 + with: + dockerfile: Dockerfile + ignore: DL3018 diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml new file mode 100644 index 0000000..df86175 --- /dev/null +++ b/.github/workflows/publish-docker-image.yml @@ -0,0 +1,42 @@ +name: Build & Push Docker image + +on: + push: + paths-ignore: + - "README.md" + branches: + - "main" + tags: + - "v*" + +env: + REGISTRY: ghcr.io + USERNAME: apptweak + VERSION: stable + # Fullname of the repo in the style `owner/name` + # REF: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context + PROJECT: ${{ github.repository }} + +jobs: + build-stable: + runs-on: ubuntu-latest + steps: + - name: Checkout to branch + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.USERNAME }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push the container to GitHub Container Registry using tag + uses: docker/build-push-action@v5.3.0 + with: + context: . + platforms: linux/amd64 + tags: | + ${{ env.REGISTRY }}/${{ env.PROJECT }}:${{ env.VERSION }} + push: true + provenance: false diff --git a/Dockerfile b/Dockerfile index 5a6bca7..208bd9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,34 @@ -FROM alpine +ARG ALPINE_VERSION=3.20 +FROM alpine:${ALPINE_VERSION} + +ARG BUILD_DATE= +ARG CVS_REF= +LABEL org.opencontainers.image.title="Simple Proxy Rotator" +LABEL org.opencontainers.image.description="Simple http(s) forward Proxy Rotator using glider" +LABEL org.opencontainers.image.source="https://github.com/apptweak/simple-proxy-rotator" +LABEL org.opencontainers.image.url="https://github.com/apptweak/simple-proxy-rotator" +LABEL org.opencontainers.image.vendor="AppTweak" +LABEL org.opencontainers.image.version=${CVS_REF} +LABEL org.opencontainers.image.created=${BUILD_DATE} + RUN apk add --no-cache \ + openssl \ curl \ bash \ git \ - dumb-init \ - openssl + dumb-init + +# Make sure to use bash with pipefail in case something +# fails while being piped to another command in the docker-build +SHELL ["/bin/bash", "-o", "pipefail", "-c"] WORKDIR /app -ADD glider glider.conf entrypoint.sh ./ +COPY glider glider.conf entrypoint.sh ./ EXPOSE 15000 +HEALTHCHECK --interval=60s --timeout=30s --start-period=10s --retries=3 \ + CMD nc -z localhost 15000 || exit 1 + ENTRYPOINT ["/app/entrypoint.sh"] -CMD ["/app/glider", "-config", "/app/glider.conf"] \ No newline at end of file +CMD ["/app/glider", "-config", "/app/glider.conf"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3863b23 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +REGISTRY_HOST=ghcr.io +USERNAME=apptweak +PROJECT=simple-proxy-rotator +VERSION := $(shell cat VERSION) +IMAGE_NAME=$(REGISTRY_HOST)/$(USERNAME)/$(PROJECT) +IMAGE=$(IMAGE_NAME):$(VERSION) + +build: + docker build -f Dockerfile --platform "linux/x86_64" --tag "$(IMAGE)" --tag "$(IMAGE_NAME):stable" . + # read --local --silent --prompt "Docker account's password: " passwd + # echo "$passwd" | docker login --username apptweakci --password-stdin + # gh auth token | docker login --username apptweakci --password-stdin ${IMAGE} + docker push "$(IMAGE)" + docker push "$(IMAGE_NAME):stable" + diff --git a/README.md b/README.md index fa51c42..e99ebe8 100644 --- a/README.md +++ b/README.md @@ -25,28 +25,33 @@ The proxy list can be configured in two ways : The proxy list should have 1 proxy per line using the following format : `http://[username]:[password]@[host]:[port]`. Example -```` +``` http://user1:password1@12.34.56.78:1111 http://user2:password2@98.76.54.32:2222 ... -```` +``` ## Usage ### Start the container using a downloadable proxy list ```` -docker run -p 1234:15000 -e PROXY_LIST_URL=https://gist.githubusercontent.com/you/private-gist-hash/raw/proxy-list.txt almathie/simple-proxy-rotator -```` +docker build . -f Dockerfile -t apptweak/simplpe-proxy-rotator +``` + + +``` +docker run -p 1234:15000 -e PROXY_LIST_URL=https://gist.githubusercontent.com/you/private-gist-hash/raw/proxy-list.txt apptweak/simple-proxy-rotator +``` ### Start the container using a volume mounted proxy list -```` -docker run -p 1234:15000 -v /path/to/proxy-list.txt:/app/proxy-list.txt almathie/simple-proxy-rotator -```` +``` +docker run -p 1234:15000 -v /path/to/proxy-list.txt:/app/proxy-list.txt apptweak/simple-proxy-rotator +``` ### Use the rotator -```` +``` curl -x "http://127.0.0.1:1234" "https://google.com" -```` \ No newline at end of file +``` diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0