mirror of https://github.com/Bunsly/JobSpy
add docker workflow
parent
9eb14a74a3
commit
893894c41c
|
@ -0,0 +1,47 @@
|
||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- docker_workflow
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Login to GitHub Docker Registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and Push Image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ghcr.io/${{ github.repository }}/jobspy_api:latest
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.sha }}
|
||||||
|
release_name: Release ${{ github.sha }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
|
- name: Attach Docker Image to Release
|
||||||
|
run: |
|
||||||
|
echo "Image ghcr.io/${{ github.repository }}/jobspy_api:latest is available under assets in the release."
|
|
@ -0,0 +1,15 @@
|
||||||
|
FROM python:3.10-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y jq && \
|
||||||
|
pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
ENV PORT=8000
|
||||||
|
|
||||||
|
CMD sh -c "uvicorn main:app --host 0.0.0.0 --port $PORT"
|
|
@ -1,10 +1,12 @@
|
||||||
import gspread
|
import json
|
||||||
from oauth2client.service_account import ServiceAccountCredentials
|
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
|
import gspread
|
||||||
|
from google.oauth2.service_account import Credentials
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
from ...jobs import *
|
from ...jobs import *
|
||||||
from ...scrapers import *
|
from ...scrapers import *
|
||||||
from settings import *
|
from settings import *
|
||||||
|
@ -19,9 +21,13 @@ class CSVFormatter:
|
||||||
"https://www.googleapis.com/auth/drive.file",
|
"https://www.googleapis.com/auth/drive.file",
|
||||||
"https://www.googleapis.com/auth/drive",
|
"https://www.googleapis.com/auth/drive",
|
||||||
]
|
]
|
||||||
credentials = ServiceAccountCredentials.from_json_keyfile_name(
|
if not GSHEET_SECRET_JSON:
|
||||||
GSHEET_JSON_KEY_PATH, scope
|
raise ValueError("GSHEET_SECRET_JSON not provided!")
|
||||||
)
|
|
||||||
|
secret_dict = json.loads(GSHEET_SECRET_JSON)
|
||||||
|
|
||||||
|
credentials = Credentials.from_service_account_info(secret_dict, scopes=scope)
|
||||||
|
|
||||||
gc = gspread.authorize(credentials)
|
gc = gspread.authorize(credentials)
|
||||||
sh = gc.open(GSHEET_NAME)
|
sh = gc.open(GSHEET_NAME)
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,11 @@ from dotenv import load_dotenv
|
||||||
import os
|
import os
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
# gsheets (template to copy at https://docs.google.com/spreadsheets/d/1HAnn-aPv-BO4QTEzfIWc-5iw50duyMoTgX8o3RsEOWs/edit?usp=sharing)
|
# Google sheets output_format
|
||||||
GSHEET_JSON_KEY_PATH = "client_secret.json"
|
GSHEET_NAME = os.environ.get("GSHEET_NAME", "JobSpy")
|
||||||
GSHEET_NAME = "JobSpy"
|
GSHEET_SECRET_JSON = os.environ.get("GSHEET_SECRET_JSON")
|
||||||
|
|
||||||
# optional autha
|
# optional auth
|
||||||
AUTH_REQUIRED = False
|
AUTH_REQUIRED = False
|
||||||
SUPABASE_URL = os.environ.get("SUPABASE_URL")
|
SUPABASE_URL = os.environ.get("SUPABASE_URL")
|
||||||
SUPABASE_KEY = os.environ.get("SUPABASE_KEY")
|
SUPABASE_KEY = os.environ.get("SUPABASE_KEY")
|
||||||
|
|
Loading…
Reference in New Issue