Skip to content

Commit

Permalink
Add Dockerfile for VLFM (#13)
Browse files Browse the repository at this point in the history
* Add Dockerfile to pre-build the various dependencies 
* Updated CI workflow use the new Docker image
  • Loading branch information
jiuguangw authored Oct 16, 2023
1 parent 4a84511 commit 3cc486e
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 24 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.

name: Docker - Build VLFM Docker

on:
pull_request:
paths:
- ".github/workflows/docker.yml"
- "docker/**"
push:
branches:
- 'main'
paths:
- ".github/workflows/docker.yml"
- "docker/**"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ghcr.io/bdaiinstitute/bdaii_vlfm


jobs:
build:
name: docker_vlfm

runs-on:
group: bdai-gh-large-runners
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: ./docker
file: ./docker/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
33 changes: 12 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
# Copyright [2023] Boston Dynamics AI Institute, Inc.

name: ZSOS - Main Build

name: VLFM CI
on:
push:
branches: [ main ]
pull_request:
push:
branches:
- main

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.9.16']
os: [ubuntu-latest]
vlfm_main_build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
container:
image: ghcr.io/bdaiinstitute/bdaii_vlfm:main
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
sudo apt-get install -y libgl1-mesa-dev
pip install -e .[habitat]
pip install -e .[dev]
- name: Pytest
run: |
pytest test
pytest
37 changes: 37 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install --no-install-recommends -qy curl apt-transport-https gnupg \
sudo ca-certificates git software-properties-common \
build-essential \
libgl1-mesa-dev libjpeg-dev libglm-dev libgl1-mesa-glx \
libegl1-mesa-dev mesa-utils xorg-dev freeglut3-dev \
python3.10-dev python3-pip python-is-python3 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean all

# Install the required Python packages
RUN pip install torch>=1.10.1 \
numpy>=1.22.4 \
flask>=2.3.2 \
seaborn>=0.12.2 \
open3d>=0.17.0 \
transformers==4.26.0 \
salesforce-lavis>=1.0.2 \
pre-commit>=3.1.1 \
pytest>=7.2.1 \
pytest-cov>=4.0.0 \
habitat-baselines==0.2.420230405 \
habitat-lab==0.2.420230405 \
bosdyn-client>=3.3.2 \
bosdyn-api>=3.3.2 \
six>=1.16.0

RUN pip install git+https://github.com/naokiyokoyama/frontier_exploration.git \
git+https://github.com/ChaoningZhang/MobileSAM.git \
git+https://github.com/naokiyokoyama/depth_camera_filtering \
git+https://github.com/facebookresearch/habitat-sim.git@v0.2.4 \
git+https://github.com/naokiyokoyama/bd_spot_wrapper.git \
git+https://github.com/IDEA-Research/GroundingDINO.git
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies = [
"frontier_exploration @ git+https://github.com/naokiyokoyama/frontier_exploration.git",
"mobile_sam @ git+https://github.com/ChaoningZhang/MobileSAM.git",
"depth_camera_filtering @ git+https://github.com/naokiyokoyama/depth_camera_filtering",
"groundingdino @ git+https://github.com/IDEA-Research/GroundingDINO.git",
]

[project.optional-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions test/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@


def test_load_and_save_config():
if not os.path.exists("build"):
os.makedirs("build")
if not os.path.exists("data"):
os.makedirs("data")

filename = "build/dummy_policy.pth"
filename = "data/dummy_policy.pth"
save_dummy_policy(filename)

# Get the file size of the output PDF
Expand Down

0 comments on commit 3cc486e

Please sign in to comment.