Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update main with docker changes #206

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ FROM stanfordnmbl/opensim-python:4.3
# RUN add-apt-repository ppa:jonathonf/ffmpeg-4 ; apt update
# RUN apt-get install ffmpeg -y --fix-missing

RUN apt update
RUN apt install ffmpeg -y
# Combine apt commands into a single layer to reduce image size
RUN apt update && apt install --no-install-recommends -y ffmpeg && rm -rf /var/lib/apt/lists/*

WORKDIR /workspace/
COPY requirements.txt /workspace/

RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt
# Upgrade pip and install Python dependencies in one layer to reduce intermediate image size
RUN pip3 install --upgrade pip --no-cache-dir && pip3 install -r requirements.txt --no-cache-dir

COPY . /workspace/

Expand Down
59 changes: 48 additions & 11 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
BASE_NAME := 660440363484.dkr.ecr.us-west-2.amazonaws.com
REPO_NAME := opencap
PROD_BRANCH := main
DEV_BRANCH := dev

# Determine the branch name
CURRENT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)

# Determine image tag based on branch
# Determine image tag and name based on branch
# If not 'main' or 'dev', then build local image
ifeq ($(CURRENT_BRANCH),$(PROD_BRANCH))
OPENCAP_IMAGE_TAG := opencap
OPENCAP_IMAGE_TAG := opencap
OPENPOSE_IMAGE_TAG := openpose
MMPOSE_IMAGE_TAG := mmpose
else
OPENCAP_IMAGE_TAG := opencap-dev

OPENCAP_IMAGE_NAME := $(BASE_NAME)/$(REPO_NAME)/$(OPENCAP_IMAGE_TAG)
OPENPOSE_IMAGE_NAME := $(BASE_NAME)/$(REPO_NAME)/$(OPENPOSE_IMAGE_TAG)
MMPOSE_IMAGE_NAME := $(BASE_NAME)/$(REPO_NAME)/$(MMPOSE_IMAGE_TAG)

else ifeq ($(CURRENT_BRANCH),$(DEV_BRANCH))
OPENCAP_IMAGE_TAG := opencap-dev
OPENPOSE_IMAGE_TAG := openpose-dev
MMPOSE_IMAGE_TAG := mmpose-dev

OPENCAP_IMAGE_NAME := $(BASE_NAME)/$(REPO_NAME)/$(OPENCAP_IMAGE_TAG)
OPENPOSE_IMAGE_NAME := $(BASE_NAME)/$(REPO_NAME)/$(OPENPOSE_IMAGE_TAG)
MMPOSE_IMAGE_NAME := $(BASE_NAME)/$(REPO_NAME)/$(MMPOSE_IMAGE_TAG)

else
OPENCAP_IMAGE_NAME := opencap-local
OPENPOSE_IMAGE_NAME := openpose-local
MMPOSE_IMAGE_NAME := mmpose-local

endif

# Get git commit hash info to pass it into container
Expand All @@ -24,19 +41,39 @@ build:
wget -c -O ../mmpose/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth https://mc-opencap-public.s3.us-west-2.amazonaws.com/mmpose_pth/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
wget -c -O ../mmpose/hrnet_w48_coco_wholebody_384x288_dark-f5726563_20200918.pth https://mc-opencap-public.s3.us-west-2.amazonaws.com/mmpose_pth/hrnet_w48_coco_wholebody_384x288_dark-f5726563_20200918.pth

docker build --build-arg GIT_COMMIT_HASH=$(GIT_COMMIT_HASH) -t $(BASE_NAME)/$(REPO_NAME)/$(OPENCAP_IMAGE_TAG) .. -f Dockerfile
docker build -t $(BASE_NAME)/$(REPO_NAME)/$(OPENPOSE_IMAGE_TAG) .. -f openpose/Dockerfile
docker build -t $(BASE_NAME)/$(REPO_NAME)/$(MMPOSE_IMAGE_TAG) .. -f mmpose/Dockerfile
docker build --build-arg GIT_COMMIT_HASH=$(GIT_COMMIT_HASH) -t $(OPENCAP_IMAGE_NAME) .. -f Dockerfile
docker build -t $(OPENPOSE_IMAGE_NAME) .. -f openpose/Dockerfile
docker build -t $(MMPOSE_IMAGE_NAME) .. -f mmpose/Dockerfile

.PHONY: push
push:
ifeq ($(CURRENT_BRANCH),$(PROD_BRANCH))
aws ecr get-login-password --region us-west-2 --profile opencap | docker login --username AWS --password-stdin 660440363484.dkr.ecr.us-west-2.amazonaws.com

docker push $(OPENCAP_IMAGE_NAME)
docker push $(OPENPOSE_IMAGE_NAME)
docker push $(MMPOSE_IMAGE_NAME)

else ifeq ($(CURRENT_BRANCH),$(DEV_BRANCH))
aws ecr get-login-password --region us-west-2 --profile opencap | docker login --username AWS --password-stdin 660440363484.dkr.ecr.us-west-2.amazonaws.com

docker push $(BASE_NAME)/$(REPO_NAME)/$(OPENCAP_IMAGE_TAG)
docker push $(BASE_NAME)/$(REPO_NAME)/$(OPENPOSE_IMAGE_TAG)
docker push $(BASE_NAME)/$(REPO_NAME)/$(MMPOSE_IMAGE_TAG)
docker push $(OPENCAP_IMAGE_NAME)
docker push $(OPENPOSE_IMAGE_NAME)
docker push $(MMPOSE_IMAGE_NAME)

else
@echo "Git branch is not 'main' or 'dev', skipping push step"

endif

.PHONY: run
run:
ifeq ($(CURRENT_BRANCH),$(PROD_BRANCH))
aws ecr get-login-password --region us-west-2 --profile opencap | docker login --username AWS --password-stdin 660440363484.dkr.ecr.us-west-2.amazonaws.com
docker-compose up

else ifeq ($(CURRENT_BRANCH),$(DEV_BRANCH))
aws ecr get-login-password --region us-west-2 --profile opencap | docker login --username AWS --password-stdin 660440363484.dkr.ecr.us-west-2.amazonaws.com

endif

OPENCAP_IMAGE_NAME=$(OPENCAP_IMAGE_NAME) OPENPOSE_IMAGE_NAME=$(OPENPOSE_IMAGE_NAME) MMPOSE_IMAGE_NAME=$(MMPOSE_IMAGE_NAME) docker-compose up
6 changes: 3 additions & 3 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.9"
services:
mobilecap:
image: 660440363484.dkr.ecr.us-west-2.amazonaws.com/opencap/opencap
image: ${OPENCAP_IMAGE_NAME}
volumes:
- data:/data
env_file:
Expand All @@ -16,7 +16,7 @@ services:
count: 1
capabilities: [gpu]
openpose:
image: 660440363484.dkr.ecr.us-west-2.amazonaws.com/opencap/openpose
image: ${OPENPOSE_IMAGE_NAME}
volumes:
- data:/openpose/data
deploy:
Expand All @@ -27,7 +27,7 @@ services:
count: 1
capabilities: [gpu]
mmpose:
image: 660440363484.dkr.ecr.us-west-2.amazonaws.com/opencap/mmpose
image: ${MMPOSE_IMAGE_NAME}
volumes:
- data:/mmpose/data
deploy:
Expand Down
Loading