Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianshu Cheng authored and Tianshu Cheng committed Nov 27, 2024
1 parent 91f4ad9 commit 1bb5400
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 0 deletions.
Empty file.
20 changes: 20 additions & 0 deletions truss/tests/test_data/test_custom_server_truss/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
base_image:
image: baseten/fastapi-test:0.1.2
docker_server:
start_command: python main.py
readiness_endpoint: /health
liveness_endpoint: /health
predict_endpoint: /predict
server_port: 8000
resources:
accelerator: null
cpu: '1'
memory: 2Gi
use_gpu: false
model_name: Test Docker Server Truss
secrets:
hf_access_token: null
environment_variables:
HF_TOKEN: 123456
runtime:
predict_concurrency: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.11-slim

# Update package lists and install curl
RUN apt-get update && apt-get install -y curl

# Install pip dependencies
RUN pip install fastapi[standard]

# Copy the FastAPI application code
COPY app.py /home/app.py
COPY main.py /home/main.py

# Set the working directory
WORKDIR /home

# Command to run FastAPI directly
ENTRYPOINT ["python", "main.py"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
We built this minimal fastapi docker image to be used in integration test `test_custom_server_truss.py::test_custom_server_truss`

Steps to update testing docker image

1. run `docker login`
2. cd into this directory
3. update version number in VERSION file
(before running the next step, make sure you meet with the [prerequisites](https://docs.docker.com/build/building/multi-platform/#prerequisites) here)
4. run `sh build_upload_new_image.sh`
5. update image tag to latest version in config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os

from fastapi import FastAPI

app = FastAPI()


@app.get("/health")
async def health():
return {"message": "OK"}


@app.post("/predict")
async def root():
return {
"message": "Hello World",
"is_env_var_passed": os.environ.get("HF_TOKEN") is not None,
"is_secret_mounted": os.path.exists("/secrets/hf_access_token"),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Read the version from the VERSION file
VERSION=$(cat VERSION)

docker buildx build --platform linux/amd64,linux/arm64 -f ./Dockerfile -t fastapi-test:$VERSION . || { echo "Failed to build the Docker image"; exit 1; }
docker tag fastapi-test:$VERSION baseten/fastapi-test:$VERSION || { echo "Failed to tag the Docker image."; exit 1; }
docker push baseten/fastapi-test:$VERSION || { echo "Failed to push the Docker image."; exit 1; }

0 comments on commit 1bb5400

Please sign in to comment.