Skip to content

Commit

Permalink
image add docker
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRunfola committed Dec 10, 2024
1 parent cb5896a commit 4f9b551
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
11 changes: 11 additions & 0 deletions geoBoundaryBuilder/images/geoBoundariesBase.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
zlib1g-dev \
libcairo2-dev \
libpq-dev \
curl \
apt-transport-https \
ca-certificates \
gnupg \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Install Docker CLI
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list && \
apt-get update && apt-get install -y --no-install-recommends \
docker-ce-cli && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Upgrade pip and install Python dependencies
RUN pip install --upgrade pip && \
pip install prefect==3.1.5 kubernetes==25.3.0
Expand Down
4 changes: 2 additions & 2 deletions geoBoundaryBuilder/k8s_manifests/dev.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: gB-dev
name: gbdev
namespace: geoboundaries
spec:
securityContext:
runAsUser: 71032
runAsGroup: 9915
containers:
- name: gb-dev-container
image: ghcr.io/your-custom-image:latest # Replace with your custom image name
image: ghcr.io/wmgeolab/gb-base:latest # Replace with your custom image name
command: ["/bin/sh", "-c"] # Keep the container running
args:
- |
Expand Down
32 changes: 20 additions & 12 deletions geoBoundaryBuilder/test.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import os
import subprocess
from prefect import flow, task

# Step 1: Set Prefect API URL dynamically
# Configure Prefect home directory and API URL
os.environ["PREFECT_HOME"] = "/tmp/.prefect" # Ensure this path is writable
PREFECT_API_URL = "http://prefect-server-service.geoboundaries.svc.cluster.local:4200/api"
os.environ["PREFECT_API_URL"] = PREFECT_API_URL # Directly set in environment
print(f"Using PREFECT_API_URL: {PREFECT_API_URL}")
subprocess.run(["prefect", "config", "set", f"PREFECT_API_URL={PREFECT_API_URL}"], check=True)

# Step 2: Define a task to process individual numbers

from prefect import flow, task


# Define a task to process numbers
@task
def multiply_by_20(number):
return number * 20

# Step 3: Define the main flow to process a list of numbers
# Define the main flow
@flow
def process_numbers_flow(numbers):
results = []
Expand All @@ -19,16 +26,17 @@ def process_numbers_flow(numbers):
results.append(result)
return [r.result() for r in results] # Gather the results

# Step 4: Main script to deploy and run the flow
if __name__ == "__main__":
# Define the list of numbers
numbers = list(range(1, 11))

# Deploy the flow (if needed)
# Deploy the flow
print("Deploying the flow...")
process_numbers_flow.deploy(name="process-numbers-deployment", work_pool_name="k8s-gB")

# Run the flow locally
process_numbers_flow.deploy(
name="process-numbers-deployment",
work_pool_name="k8s-gB",
image="ghcr.io/wmgeolab/gb-base:latest" # Ensure this matches your Kubernetes work pool
)

# Run the flow locally for testing
print("Running the flow locally...")
numbers = list(range(1, 11))
results = process_numbers_flow(numbers)
print("Results:", results)

0 comments on commit 4f9b551

Please sign in to comment.