Skip to content

Commit

Permalink
Merge pull request #40 from Datawheel/tesseract-python
Browse files Browse the repository at this point in the history
Tesseract python
  • Loading branch information
hermosillajelmy authored Jul 10, 2024
2 parents 705481c + bbb56c9 commit d581ecb
Show file tree
Hide file tree
Showing 6 changed files with 1,666 additions and 15 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/google-registry-gke-playground.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ name: "[GCP][DEV] Build API to Registry and Deploy via Helm"

on:
push:
branches: [ "main" ]
branches: [ "tesseract-python" ]
paths:
- .github/workflows/google-registry-gke-playground.yaml
- helm/playground.yaml
- requirements.txt
- poetry.lock
- schema/**
- app/**
- Dockerfile

env:
GCP_PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}
Expand All @@ -86,7 +88,7 @@ jobs:
if: ${{ !contains(github.event.head_commit.message, '#update') }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# Authentication via credentials json
- name: Google Auth
Expand All @@ -95,12 +97,20 @@ jobs:
with:
project_id: ${{ env.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }}

# Install Cloud SDK
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
install_components: beta

# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Build image on Google Cloud Artifact Registry
- name: Build Docker Image
Expand All @@ -127,14 +137,14 @@ jobs:
with:
project_id: ${{ env.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }}

# Get google kubernetes engine credentials
- name: Get GKE Credentials
uses: google-github-actions/get-gke-credentials@v2
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}

# Transform GitHub secrets to base64 encoded
- name: Set encoded secret values
run: |
Expand All @@ -155,7 +165,7 @@ jobs:
--set fullnameOverride=${{ env.GKE_APP_NAME }} \
--set secrets.TESSERACT_BACKEND=$ENCODED_TESSERACT_BACKEND \
${{ env.GKE_APP_NAME }} --values=./helm/playground.yaml ./helm
update:
runs-on: ubuntu-latest
environment: playground
Expand All @@ -172,14 +182,14 @@ jobs:
with:
project_id: ${{ env.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }}

# Get google kubernetes engine credentials
- name: Get GKE Credentials
uses: google-github-actions/get-gke-credentials@v2
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}

# Transform GitHub secrets to base64 encoded
- name: Set encoded secret values
run: |
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ node_modules/

# environment variables
.env.*

poetry.lock
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ FROM python:3.10-slim-buster as runtime
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"

# create runtime user; install required dependencies
RUN useradd --system --uid 1001 tesseract

WORKDIR /app

# create runtime user; install required dependencies
RUN useradd --system --uid 1001 tesseract &&\
chown -R tesseract:tesseract /app

COPY --chown=tesseract --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}

COPY --chown=tesseract . /app
Expand Down
2 changes: 2 additions & 0 deletions cloudbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ steps:
"--cache-from", "${_GCP_ARTIFACT_REGISTRY_LOCATION}-docker.pkg.dev/${_GCP_PROJECT_ID}/${_GCP_ARTIFACT_REGISTRY_NAME}/${_GCP_IMAGE_NAME}:${_GCP_IMAGE_ENVIRONMENT}",
"."
]
env:
- "DOCKER_BUILDKIT=1"
# [END cloudbuild_image_yaml]
images:
- "${_GCP_ARTIFACT_REGISTRY_LOCATION}-docker.pkg.dev/${_GCP_PROJECT_ID}/${_GCP_ARTIFACT_REGISTRY_NAME}/${_GCP_IMAGE_NAME}:${_GCP_IMAGE_TAG}"
Expand Down
2 changes: 1 addition & 1 deletion helm/playground.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ ingress:
tls:
- secretName: tesseract-api-ingress-tls
hosts:
- playground.api.datawheel.us
- playground.api.datawheel.us
Loading

0 comments on commit d581ecb

Please sign in to comment.