Skip to content

Commit

Permalink
chore: add additional projects to compose stack, make 80 default port…
Browse files Browse the repository at this point in the history
… and other clean-up of build
  • Loading branch information
danellecline committed Aug 28, 2024
1 parent 5f0c861 commit daca868
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 25 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ jobs:
export RELEASE_VERSION=$(echo ${{ steps.semantic.outputs.tag }} | cut -c 2-)-cuda124
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
docker buildx create --name mybuilder --platform linux/amd64 --use
docker buildx build --push --platform linux/amd64 -t mbari/fastapi-vss:$RELEASE_VERSION --build-arg IMAGE_URI=mbari/fastapi-vss:$RELEASE_VERSION -f Dockerfile.cuda .
docker buildx build --push --platform linux/amd64 \
-t mbari/fastapi-vss:$RELEASE_VERSION \
--build-arg IMAGE_URI=mbari/fastapi-vss:$RELEASE_VERSION \
--build-arg GH_TOKEN=$GH_TOKEN \
-f Dockerfile.cuda .
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN apt-get update && apt-get install -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ENV APP_HOME /app
ENV APP_HOME=/app
WORKDIR ${APP_HOME}
ADD . ${APP_HOME}
ENV PYTHONPATH=${APP_HOME}/src:${APP_HOME}/src/submodules/aidata
Expand All @@ -40,5 +40,6 @@ RUN chmod a+rwx -R /app

# run the FastAPI server
WORKDIR $APP_HOME/src/app
EXPOSE 80
ENTRYPOINT ["sh", "-c", "exec uvicorn main:app --host 0.0.0.0 --port 80 "]

8 changes: 2 additions & 6 deletions Dockerfile.cuda
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ LABEL vendor="MBARI"
LABEL maintainer="[email protected]"
LABEL license="Apache License 2.0"

ARG PORT=80
ARG GH_TOKEN
ARG GIT_VERSION=latest
ARG IMAGE_URI=mbari/fastapi-vss:${GIT_VERSION}
Expand All @@ -25,10 +24,7 @@ RUN apt-get update && apt-get install -y \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

## setup virtualenv
ENV APP_HOME=/app
RUN pip install virtualenv
RUN virtualenv $APP_DIR/env -p python3
ENV VIRTUAL_ENV $APP_HOME/env
ENV PATH $APP_HOME/env/bin:$PATH
ENV PYTHONPATH=${APP_HOME}/src:${APP_HOME}/src/submodules/aidata
Expand All @@ -48,7 +44,7 @@ RUN python3 -m pip install --upgrade pip && \

# run the FastAPI server
WORKDIR $APP_HOME/src/app
EXPOSE ${PORT}
ENTRYPOINT ["sh", "-c", "exec uvicorn main:app --host 0.0.0.0 --port ${PORT} "]
EXPOSE 80
ENTRYPOINT ["sh", "-c", "exec uvicorn main:app --host 0.0.0.0 --port 80 "]


44 changes: 40 additions & 4 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,65 @@ services:
user: "$MLDEVOPS_GID:$MLDEVOPS_UID"
restart: always
redis-uav:
image: redis
image: redis/redis-stack-server
container_name: redis-uav
ports:
- "6380:6379"
- "6379:6379"
volumes:
- redis-uav-data:/data
restart: always
command: redis-server --appendonly yes
networks:
- vss
redis-i2map:
image: redis/redis-stack-server
container_name: redis-i2map
ports:
- "6380:6379"
volumes:
- redis-i2map-data:/data
restart: always
command: redis-server --appendonly yes
networks:
- vss
redis-bio:
image: redis/redis-stack-server
container_name: redis-bio
ports:
- "6381:6379"
volumes:
- redis-bio-data:/data
restart: always
command: redis-server --appendonly yes
networks:
- vss
redis-cfe:
image: redis
image: redis/redis-stack-server
container_name: redis-cfe
ports:
- "6381:6379"
- "6382:6379"
volumes:
- redis-cfe-data:/data
restart: always
command: redis-server --appendonly yes
networks:
- vss
redis-compas:
image: redis/redis-stack-server
container_name: redis-compas
ports:
- "6383:6379"
volumes:
- redis-compas-data:/data
restart: always
command: redis-server --appendonly yes
networks:
- vss
volumes:
scratch:
redis-uav-data:
redis-cfe-data:
redis-bio-data:
redis-i2map-data:
redis-compas-data:

25 changes: 12 additions & 13 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ list:
# Setup the environment
install:
conda env create -f environment.yml
python -m pip install --upgrade pip
git submodule update --init --recursive
python -m pip install -r src/submodules/requirements.txt
python -m pip install -r src/submodules/aidata/requirements.txt
python -m pip install https://github.com/redis/redis-py/archive/refs/tags/v5.0.9.zip

# Update the conda environment. Run this command after checking out any code changes
update:
git submodule update --init --recursive
conda env update --file environment.yml --prune
python -m pip install -r src/submodules/aidata/requirements.txt
conda env update --file environment.yml --prune
python -m pip install https://github.com/redis/redis-py/archive/refs/tags/v5.0.9.zip

# Kill existing uvicorn processes
kill-uvicorn:
Expand All @@ -39,28 +39,27 @@ run-server: kill-uvicorn
cd src/app && conda run -n fastapi-vss --no-capture-output uvicorn main:app --port 8002 --reload
run-server-prod:
gitver=$(git describe --tags --always)
GIT_VERSION=$gitver COMPOSE_PROJECT_NAME=fastapi-vss \
docker-compose -f compose.yml up -d \
#!/usr/bin/env bash
tag=$(git describe --tags --always)
GIT_VERSION=$tag COMPOSE_PROJECT_NAME=fastapi-vss \
docker-compose -f compose.yml up \
--build \
--force-recreate \
--runtime nvidia \
--gpus all \
--no-deps -f Dockerfile.cuda .
--no-deps
# Build the Docker image
build-docker:
docker build --build-arg GH_TOKEN=$GH_TOKEN -t fastapi-app .
docker build --build-arg GH_TOKEN=$GH_TOKEN -t mbari/fastapi-app .

build-docker-no-cache:
docker build --build-arg GH_TOKEN=$GH_TOKEN --no-cache -t fastapi-app .
docker build --build-arg GH_TOKEN=$GH_TOKEN --no-cache -t mbari/fastapi-app .

build-cuda-docker:
docker build --build-arg GH_TOKEN=$GH_TOKEN -f Dockerfile.cuda -t fastapi-app .
docker build --build-arg GH_TOKEN=$GH_TOKEN -f Dockerfile.cuda -t mbari/fastapi-app .

run-docker:
echo "FastAPI server running at http://localhost:8001"
docker run -p "8001:80" fastapi-app
docker run -p "8001:80" mbari/fastapi-app

# Default recipe
default:
Expand Down

0 comments on commit daca868

Please sign in to comment.