| 1 |
name: COLMAP (Docker) |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
- release/* |
| 8 |
pull_request: |
| 9 |
types: [ assigned, opened, synchronize, reopened ] |
| 10 |
release: |
| 11 |
types: [ published, edited ] |
| 12 |
|
| 13 |
env: |
| 14 |
IS_RELEASE: ${{ github.event_name == 'release' || startsWith(github.ref, 'refs/tags') }} |
| 15 |
CCACHE_DIR: build/.ccache |
| 16 |
CCACHE_MAXSIZE: 100M |
| 17 |
|
| 18 |
jobs: |
| 19 |
build: |
| 20 |
name: ubuntu-24.04 |
| 21 |
runs-on: ubuntu-24.04 |
| 22 |
steps: |
| 23 |
- name: Free disk space |
| 24 |
uses: jlumbroso/[email protected] |
| 25 |
with: |
| 26 |
tool-cache: false |
| 27 |
android: true |
| 28 |
dotnet: true |
| 29 |
haskell: true |
| 30 |
large-packages: true |
| 31 |
docker-images: true |
| 32 |
swap-storage: true |
| 33 |
|
| 34 |
- uses: actions/checkout@v7 |
| 35 |
|
| 36 |
- name: Restore compiler cache |
| 37 |
uses: ./.github/actions/compiler-cache |
| 38 |
id: cache-ccache |
| 39 |
with: |
| 40 |
mode: restore |
| 41 |
path: ${{ env.CCACHE_DIR }} |
| 42 |
key-suffix: docker-release_${{ env.IS_RELEASE }} |
| 43 |
|
| 44 |
- name: Set up QEMU |
| 45 |
uses: docker/setup-qemu-action@v4 |
| 46 |
|
| 47 |
- name: Set up Docker Buildx |
| 48 |
uses: docker/setup-buildx-action@v4 |
| 49 |
|
| 50 |
- name: Login to Docker Hub |
| 51 |
if: ${{ env.IS_RELEASE == 'true' }} |
| 52 |
uses: docker/login-action@v4 |
| 53 |
with: |
| 54 |
username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 55 |
password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 56 |
|
| 57 |
- name: Build and push |
| 58 |
run: | |
| 59 |
dockertag=$(date +%Y%m%d).${{ github.run_number }} |
| 60 |
if [[ "${{ env.IS_RELEASE }}" == "true" ]]; then |
| 61 |
cuda_archs="50;60;70;75;90" |
| 62 |
else |
| 63 |
cuda_archs="50" |
| 64 |
fi |
| 65 |
mkdir -p build/.ccache |
| 66 |
docker_args=( |
| 67 |
--file docker/Dockerfile |
| 68 |
--build-arg CUDA_ARCHITECTURES="$cuda_archs" |
| 69 |
--build-arg CCACHE_MAXSIZE="${CCACHE_MAXSIZE}" |
| 70 |
) |
| 71 |
docker build . \ |
| 72 |
"${docker_args[@]}" \ |
| 73 |
--tag colmap/colmap:$dockertag |
| 74 |
# Extract updated build caches from the builder stage. |
| 75 |
docker build . \ |
| 76 |
"${docker_args[@]}" \ |
| 77 |
--target cache-export \ |
| 78 |
--output type=local,dest=build/cache-export |
| 79 |
rm -rf build/.ccache |
| 80 |
mv build/cache-export/.ccache build/.ccache |
| 81 |
rm -rf build/cache-export |
| 82 |
if [[ "${{ env.IS_RELEASE }}" == "true" ]]; then |
| 83 |
docker tag colmap/colmap:$dockertag colmap/colmap:latest |
| 84 |
docker push colmap/colmap:$dockertag |
| 85 |
docker push colmap/colmap:latest |
| 86 |
fi |
| 87 |
|
| 88 |
- name: Cleanup compiler cache |
| 89 |
run: | |
| 90 |
set -x |
| 91 |
sudo apt-get install -y ccache |
| 92 |
ccache --cleanup |
| 93 |
ccache --show-stats --verbose |
| 94 |
|
| 95 |
- name: Save compiler cache |
| 96 |
uses: ./.github/actions/compiler-cache |
| 97 |
with: |
| 98 |
mode: save |
| 99 |
key: ${{ steps.cache-ccache.outputs.key }} |
| 100 |
path: ${{ env.CCACHE_DIR }} |
| 101 |
cache-hit: ${{ steps.cache-ccache.outputs.cache-hit }} |