Skip to content
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
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This top-level .env file under AirStack/ defines variables that are propagated through docker-compose.yaml
PROJECT_NAME="airstack"
PROJECT_VERSION="0.13.1"
# auto-generated from git commit hash
DOCKER_IMAGE_TAG="3f238b1"
# can replace with your docker hub username
PROJECT_DOCKER_REGISTRY="airlab-storage.andrew.cmu.edu:5001/shared"
DEFAULT_ISAAC_SCENE="omniverse://airlab-storage.andrew.cmu.edu:8443/Projects/AirStack/AFCA/fire_academy_faro_with_sky.scene.usd"
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# top-level docker-compose file for the autonomy stack
# This file includes all component docker-compose files
# Each component has its own docker-compose.yaml file
# Components are organized by functionality
# This allows for modular development and deployment
include:
- simulation/isaac-sim/docker/docker-compose.yaml
- robot/docker/docker-compose.yaml
Expand Down
2 changes: 1 addition & 1 deletion docs/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
- ""
- sitl
- hitl
image: &image_tag ${PROJECT_DOCKER_REGISTRY}/${PROJECT_NAME}:v${PROJECT_VERSION}_mkdocs
image: &image_tag ${PROJECT_DOCKER_REGISTRY}/${PROJECT_NAME}:v${DOCKER_IMAGE_TAG}_mkdocs
build:
dockerfile: ./Dockerfile
tags:
Expand Down
33 changes: 33 additions & 0 deletions git-hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Git Hooks

This directory contains git hooks used in the AirStack repository.

## Available Hooks

### Docker Versioning Hook

The `update-docker-image-tag.pre-commit` hook automatically updates the `DOCKER_IMAGE_TAG` in the `.env` file with the current git commit hash whenever Docker-related files (Dockerfile or docker-compose.yaml) are modified. It also adds a comment above the variable indicating that the value is auto-generated from the git commit hash.

This ensures that Docker images are always tagged with the exact commit they were built from, eliminating version conflicts between parallel branches.

### Installation

To install the hooks:

1. Copy the hook to your local .git/hooks directory:
```bash
cp git-hooks/docker-versioning/update-docker-image-tag.pre-commit .git/hooks/pre-commit
```

2. Make sure the hook file is executable:
```bash
chmod +x .git/hooks/pre-commit
```

## How the Docker Versioning Hook Works

1. When you commit changes, the hook checks if any Dockerfile or docker-compose.yaml files are being committed
2. If Docker-related files are detected, it updates the DOCKER_IMAGE_TAG in the .env file with the current git commit hash and adds a comment above the variable
3. The modified .env file is automatically added to the commit

This approach eliminates version conflicts between parallel branches by ensuring Docker images are tagged with the exact commit they were built from.
35 changes: 35 additions & 0 deletions git-hooks/docker-versioning/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Docker Versioning Git Hook

This directory contains a git hook that automatically updates the Docker image tag with the current git commit hash.

## Hook: update-docker-image-tag.pre-commit

This pre-commit hook automatically updates the `DOCKER_IMAGE_TAG` in the `.env` file with the current git commit hash whenever Docker-related files (Dockerfile or docker-compose.yaml) are modified.

### Features

- Automatically updates `DOCKER_IMAGE_TAG` with the git commit hash
- Adds a comment above the variable indicating it's auto-generated
- Only triggers when Docker-related files are modified
- Automatically stages the modified .env file for commit

### Installation

To install the hook:

1. Copy the hook to your local .git/hooks directory:
```bash
cp update-docker-image-tag.pre-commit ../../.git/hooks/pre-commit
```

2. Make sure the hook file is executable:
```bash
chmod +x ../../.git/hooks/pre-commit
```

### Benefits

- Eliminates version conflicts between parallel branches
- Ensures Docker images are tagged with the exact commit they were built from
- Simplifies tracking which version of the code is running in Docker containers
- Provides a consistent and automated versioning system for Docker images
40 changes: 40 additions & 0 deletions git-hooks/docker-versioning/update-docker-image-tag.pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Pre-commit hook to update DOCKER_IMAGE_TAG in .env file with git commit hash
# when Dockerfile or docker-compose.yaml files are modified

# Check if any Dockerfile or docker-compose.yaml files are staged for commit
DOCKER_FILES_CHANGED=$(git diff --cached --name-only | grep -E 'Dockerfile|docker-compose\.yaml$')

if [ -n "$DOCKER_FILES_CHANGED" ]; then
echo "Docker-related files changed. Updating DOCKER_IMAGE_TAG in .env file..."

# Get the current commit hash (short version)
COMMIT_HASH=$(git rev-parse --short HEAD)

# Update the DOCKER_IMAGE_TAG in .env file
if [ -f ".env" ]; then
# Check if DOCKER_IMAGE_TAG line exists
if grep -q "^DOCKER_IMAGE_TAG=" .env; then
# Replace the existing DOCKER_IMAGE_TAG line and ensure comment is above it
# First, remove any existing auto-generated comment
sed -i '/^# auto-generated from git commit hash$/d' .env
# Add the comment above the DOCKER_IMAGE_TAG line
sed -i '/^DOCKER_IMAGE_TAG=/i\# auto-generated from git commit hash' .env
# Update the DOCKER_IMAGE_TAG value
sed -i "s/^DOCKER_IMAGE_TAG=.*$/DOCKER_IMAGE_TAG=\"$COMMIT_HASH\"/" .env
echo "Updated DOCKER_IMAGE_TAG to $COMMIT_HASH in .env file"

# Stage the modified .env file for commit
git add .env
else
echo "Error: DOCKER_IMAGE_TAG line not found in .env file"
exit 1
fi
else
echo "Error: .env file not found"
exit 1
fi
fi

exit 0
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# docker compose file
services:
ground-control-station-base:
image: &gcs_image ${PROJECT_DOCKER_REGISTRY}/${PROJECT_NAME}:v${PROJECT_VERSION}_gcs
image: &gcs_image ${PROJECT_DOCKER_REGISTRY}/${PROJECT_NAME}:v${DOCKER_IMAGE_TAG}_gcs
build:
context: ../
dockerfile: docker/Dockerfile.gcs
Expand Down
4 changes: 2 additions & 2 deletions robot/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
extends:
file: ./robot-base-docker-compose.yaml
service: robot_base
image: &desktop_image ${PROJECT_DOCKER_REGISTRY}/${PROJECT_NAME}:v${PROJECT_VERSION}_robot-x86-64
image: &desktop_image ${PROJECT_DOCKER_REGISTRY}/${PROJECT_NAME}:v${DOCKER_IMAGE_TAG}_robot-x86-64
build:
dockerfile: ./Dockerfile.robot
args:
Expand Down Expand Up @@ -42,7 +42,7 @@ services:
extends:
file: ./robot-base-docker-compose.yaml
service: robot_base
image: &l4t_image ${PROJECT_DOCKER_REGISTRY}/${PROJECT_NAME}:v${PROJECT_VERSION}_robot-l4t
image: &l4t_image ${PROJECT_DOCKER_REGISTRY}/${PROJECT_NAME}:v${DOCKER_IMAGE_TAG}_robot-l4t
build:
dockerfile: ./Dockerfile.robot
args:
Expand Down
4 changes: 2 additions & 2 deletions simulation/isaac-sim/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
isaac-sim:
image: &image_tag ${PROJECT_DOCKER_REGISTRY}/${PROJECT_NAME}:v${PROJECT_VERSION}_isaac-sim
image: &image_tag ${PROJECT_DOCKER_REGISTRY}/${PROJECT_NAME}:v${DOCKER_IMAGE_TAG}_isaac-sim
build:
context: ../
dockerfile: docker/Dockerfile.isaac-ros
Expand Down Expand Up @@ -58,7 +58,7 @@ services:
# developer stuff
- .dev:/root/.dev:rw # developer config
- .bashrc:/root/.bashrc:rw # bash config
- ../../common/inputrc:/etc/inputrc:rw # for using page up/down to search through command history
- ../../common/inputrc:/etc/inputrc:rw # for using page up/down to search through command history
# code
- ../sitl_integration/kit-app-template/source/extensions/:/root/Documents/Kit/shared/exts/
- ../sitl_integration:/sitl_integration:rw
Expand Down