浏览代码

Merge branch 'master' of github.com:Python3WebSpider/ProxyPool

Germey 3 年之前
父节点
当前提交
0686527740
共有 5 个文件被更改,包括 65 次插入26 次删除
  1. 3 1
      .dockerignore
  2. 35 14
      .github/workflows/build.yml
  3. 2 1
      .gitignore
  4. 14 10
      Dockerfile
  5. 11 0
      supervisord.conf

+ 3 - 1
.dockerignore

@@ -130,4 +130,6 @@ dmypy.json
 # Pyre type checker
 .pyre/
 
-proxypool/.env
+proxypool/.env
+.DS_Store
+.vscode

+ 35 - 14
.github/workflows/build.yml

@@ -2,22 +2,43 @@ name: build
 on:
   push:
     branches: 
-    - master
+      - master
     paths-ignore:
-    - .gitignore
-    - README.md
-    - '.github/ISSUE_TEMPLATE/**'
+      - .gitignore
+      - README.md
+      - '.github/ISSUE_TEMPLATE/**'
+    release:
+      types: [published]
+
 jobs:
   build:
     runs-on: ubuntu-latest
     steps:
-    - name: Checkout Source
-      uses: actions/checkout@v1
-    - name: Docker Login
-      run: docker login -u germey -p ${{ secrets.DOCKERHUB_LOGIN_PASSWORD }}
-    - name: Build the Docker Image
-      run: docker-compose -f build.yaml build
-    - name: Tag and Push Master Version
-      run: |
-        docker push germey/proxypool:master
-      
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v1
+
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v1
+
+      - name: Login to DockerHub
+        uses: docker/login-action@v1
+        with:
+          username: germey
+          password: ${{ secrets.DOCKERHUB_LOGIN_PASSWORD }}
+
+      - name: Extract branch name
+        id: branch
+        shell: bash
+        run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF##*/} | sed 's/master/latest/')"
+
+      - name: Build and push
+        uses: docker/build-push-action@v2
+        with:
+          context: .
+          push: true
+          platforms: linux/amd64
+          tags: |
+            germey/proxypool:${{ steps.branch.outputs.tag }}

+ 2 - 1
.gitignore

@@ -3,4 +3,5 @@
 *.db
 venv
 /.idea
-*.log
+*.log
+.DS_Store

+ 14 - 10
Dockerfile

@@ -1,13 +1,17 @@
-FROM alpine:3.7
-WORKDIR /app
-RUN apk add --no-cache --virtual .build-deps g++ python3-dev libffi-dev \
-    openssl-dev libxml2-dev libxslt-dev gcc musl-dev py3-pip && \
-    apk add --no-cache --update python3 && \
-    pip3 install --upgrade pip setuptools
+FROM python:3.7-alpine AS build
 COPY requirements.txt .
-RUN pip3 install -r requirements.txt && \
-apk del g++ gcc musl-dev libxml2-dev
+RUN apk update &&\
+    apk add --no-cache gcc g++ libffi-dev openssl-dev libxml2-dev libxslt-dev &&\
+    pip install --timeout 30 --user --no-cache-dir --no-warn-script-location -r requirements.txt
+
+FROM python:3.7-alpine
+ENV APP_ENV=prod
+ENV LOCAL_PKG="/root/.local"
+COPY --from=build ${LOCAL_PKG} ${LOCAL_PKG}
+RUN apk update && apk add --no-cache libffi-dev openssl-dev libxslt-dev &&\
+    ln -sf ${LOCAL_PKG}/bin/* /usr/local/bin/
+WORKDIR /app
 COPY . .
-# RUN pip install -r requirements.txt  -i https://pypi.douban.com/simple
+EXPOSE 5555
 VOLUME ["/app/proxypool/crawlers/private"]
-CMD ["supervisord", "-c", "supervisord.conf"]
+ENTRYPOINT ["supervisord", "-c", "supervisord.conf"]

+ 11 - 0
supervisord.conf

@@ -1,6 +1,17 @@
+[unix_http_server]
+file=/run/supervisor.sock
+chmod=0700
+
 [supervisord]
+pidfile=/run/supervisord.pid
 nodaemon=true
 
+[supervisorctl]
+serverurl=unix:///run/supervisor.sock
+
+[rpcinterface:supervisor]
+supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
+
 [program:tester]
 process_name=tester
 command=python3 run.py --processor tester