Skip to content

Commit

Permalink
Merge pull request #14 from ubcuas/add-versioning
Browse files Browse the repository at this point in the history
Add versioning
  • Loading branch information
rrhan0 authored Oct 2, 2023
2 parents ce71ad1 + 7f0bcf2 commit 296abcf
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 29 deletions.
38 changes: 29 additions & 9 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ on:
branches: [ "master" ]
merge_group:
branches: [ "master" ]
workflow_dispatch:
inputs:
copter:
description: 'Copter Version (#.#.#): [Releases](https://github.com/ArduPilot/ardupilot/tags)'
required: true
type: string
plane:
description: 'Plane Version (#.#.#): [Releases](https://github.com/ArduPilot/ardupilot/tags)'
required: true
type: string

env:
COPTER_VERSION: '4.3.7'
PLANE_VERSION: '4.3.4'

jobs:
Copter-x86:
Expand Down Expand Up @@ -35,7 +49,8 @@ jobs:
context: x86/
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ubcuas/uasitl:copter
tags: ubcuas/uasitl:copter-${{ inputs.copter || env.COPTER_VERSION }}
build-args: VERSION=${{ inputs.copter || env.COPTER_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max

Expand All @@ -62,14 +77,15 @@ jobs:
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Build and Push
uses: docker/build-push-action@v4
with:
context: arm/
platforms: linux/arm/v7,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ubcuas/uasitl:copter-arm
tags: ubcuas/uasitl:copter-arm-${{ inputs.copter || env.COPTER_VERSION }}
build-args: VERSION=${{ inputs.copter || env.COPTER_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max

Expand All @@ -93,15 +109,17 @@ jobs:
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Build and Push
uses: docker/build-push-action@v4
with:
context: x86/
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ubcuas/uasitl:plane
build-args: VEHICLE_TYPE=1
tags: ubcuas/uasitl:plane-${{ inputs.plane || env.PLANE_VERSION }}
build-args: |
VEHICLE_TYPE=1
VERSION=${{ inputs.plane || env.PLANE_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max

Expand All @@ -128,14 +146,16 @@ jobs:
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Build and Push
uses: docker/build-push-action@v4
with:
context: arm/
platforms: linux/arm/v7,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ubcuas/uasitl:plane-arm
build-args: VEHICLE_TYPE=1
tags: ubcuas/uasitl:plane-arm-${{ inputs.plane || env.PLANE_VERSION }}
build-args: |
VEHICLE_TYPE=1
VERSION=${{ inputs.plane || env.PLANE_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,39 @@

## Installation
The images can be directly pulled from DockerHub:
> **Note**
> Replace X.X.X with version number

**ArduPlane (VTOL):**
```
FOR x86: docker pull ubcuas/uasitl:plane
FOR arm: docker pull ubcuas/uasitl:plane-arm
FOR x86: docker pull ubcuas/uasitl:plane-X.X.X
FOR arm: docker pull ubcuas/uasitl:plane-arm-X.X.X
```

**ArduCopter (Quadcopter):**
```
FOR x86: docker pull ubcuas/uasitl:copter
FOR arm: docker pull ubcuas/uasitl:copter-arm
FOR x86: docker pull ubcuas/uasitl:copter-X.X.X
FOR arm: docker pull ubcuas/uasitl:copter-arm-X.X.X
```

The images can also be built locally:
> **Note**
> To build for ArduPlane, add `--build-arg VEHICLE_TYPE=1` to the build command. Also change the tag to `plane` or `plane-arm` depending on the architecture.
```
./configure.sh
FOR x86: docker build --tag ubcuas/uasitl:copter x86/ --platform "linux/amd64"
FOR armv7: docker build --tag ubcuas/uasitl:copter-arm arm/ --platform "linux/arm/v7"
FOR arm64: docker build --tag ubcuas/uasitl:copter-arm arm/ --platform "linux/arm64"
FOR x86: docker build --tag ubcuas/uasitl:copter-X.X.X --build-arg VERSION=X.X.X x86/ --platform "linux/amd64"
FOR armv7: docker build --tag ubcuas/uasitl:copter-arm-X.X.X --build-arg VERSION=X.X.X arm/ --platform "linux/arm/v7"
FOR arm64: docker build --tag ubcuas/uasitl:copter-arm-X.X.X --build-arg VERSION=X.X.X arm/ --platform "linux/arm64"
```
> **Note**
> If you get an error akin to `./configure.sh: line 2: $'\r': command not found` then run `sed -i 's/\r$//' configure.sh` to fix the line endings.
To build the armv7 and arm64 images on x86, you need to run the following commands:
```
./configure.sh
ArduCopter: ./crossBuild.sh copter
ArduPlane: ./crossBuild.sh plane
ArduCopter: ./crossBuild.sh copter X.X.X
ArduPlane: ./crossBuild.sh plane X.X.X
```


Expand All @@ -65,24 +68,24 @@ Please note the bash variable `$SSH_PRIVATE_KEY` needs to be a valid ssh private
## Usage
To launch a single ArduCopter SITL on host TCP port 5760, with the ability for the rest of our services to connect:
```
docker run --rm -p 5760-5780:5760-5780 -it --network=gcom-x_uasnet --name=uasitl ubcuas/uasitl:copter
docker run --rm -p 5760-5780:5760-5780 -it --network=gcom-x_uasnet --name=uasitl ubcuas/uasitl:copter-X.X.X
```

To launch a single ArduCopter SITL on host TCP port 5760, with the ability for the rest of our services to connect, and with a custom parameter file located in the current directory:
> **Note**
> Docker volume mounts (-v option) needs absolute paths. `${PWD}` is a Windows Powershell variable that expands to the current working directory. For Linux, use `$(pwd)` and for Command Prompt use `%cd%`.
```
docker run --rm -p 5760-5780:5760-5780 -it --network=gcom-x_uasnet --name=uasitl -v ${PWD}/custom-copter.param:/custom-copter.param --env PARAM_FILE=/custom-copter.param ubcuas/uasitl:copter --defaults=/ardupilot/Tools/autotest/default_params/copter.parm
docker run --rm -p 5760-5780:5760-5780 -it --network=gcom-x_uasnet --name=uasitl -v ${PWD}/custom-copter.param:/custom-copter.param --env PARAM_FILE=/custom-copter.param ubcuas/uasitl:copter-X.X.X --defaults=/ardupilot/Tools/autotest/default_params/copter.parm
```

To launch a single ArduCopter SITL on host TCP port 5760:
```
docker run --rm -p 5760-5780:5760-5780 -it --name=uasitl ubcuas/uasitl:copter
docker run --rm -p 5760-5780:5760-5780 -it --name=uasitl ubcuas/uasitl:copter-X.X.X
```

To start 3 ArduCopter SITLs on host TCP ports 5760, 5770 and 5780:
```
docker run --rm -p 5760-5780:5760-5780 --env NUMCOPTERS=3 -it --name=uasitl ubcuas/uasitl:copter
docker run --rm -p 5760-5780:5760-5780 --env NUMCOPTERS=3 -it --name=uasitl ubcuas/uasitl:copter-X.X.X
```


Expand Down
8 changes: 6 additions & 2 deletions arm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ RUN [ -z "$SSH_PRIVATE_KEY" ] || \
# Take in a parameter for the vehicle type
ARG VEHICLE_TYPE

# Get parameter for ardupilot release, fail if empty
ARG VERSION
RUN test -n "$VERSION" || (echo "VERSION not set" && false)

# if --build-arg VEHICLE_TYPE=1, set ARDUPILOT_TAG to 'Plane-X.X.X' or set to null otherwise.
ENV ARDUPILOT_TAG=${VEHICLE_TYPE:+Plane-4.3.4}
ENV ARDUPILOT_TAG=${VEHICLE_TYPE:+Plane-${VERSION}}
# if ARDUPILOT_TAG is null, set it to 'Copter-X.X.X' (or leave as is otherwise).
ENV ARDUPILOT_TAG=${ARDUPILOT_TAG:-Copter-4.3.7}
ENV ARDUPILOT_TAG=${ARDUPILOT_TAG:-Copter-${VERSION}}

# The ARDUPILOT repo and ref to use for the build
ENV ARDUPILOT_REPO=https://github.com/ArduPilot/ardupilot.git
Expand Down
7 changes: 4 additions & 3 deletions crossBuild.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
vehicleType=$1
buildArgs=""
version=$2
buildArgs="--build-arg ${version}"

if [[ "$vehicleType" == "" || "$vehicleType" == "copter" ]]; then
echo "Building ArduCopter"
vehicleType="copter"
elif [[ "$vehicleType" == "plane" || "$vehicleType" == "ArduPlane" ]]; then
echo "Building ArduPlane"
vehicleType="plane"
buildArgs="--build-arg VEHICLE_TYPE=1"
buildArgs="${buildArgs} --build-arg VEHICLE_TYPE=1"
else
echo "Invalid vehicle type, using ArduCopter"
vehicleType="copter"
Expand All @@ -22,7 +23,7 @@ docker buildx use mubuilder
docker buildx inspect --bootstrap

# Build and push images
docker buildx build $buildArgs --tag ubcuas/uasitl:${vehicleType}-arm --output type=image arm/ --platform "linux/arm64,linux/arm/v7"
docker buildx build ${buildArgs} --tag ubcuas/uasitl:${vehicleType}-arm-${version} --output type=image arm/ --platform "linux/arm64,linux/arm/v7"

# Cleanup
docker buildx rm mubuilder
8 changes: 6 additions & 2 deletions x86/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ RUN [ -z "$SSH_PRIVATE_KEY" ] || \
# Take in a parameter for the vehicle type
ARG VEHICLE_TYPE

# Get parameter for ardupilot release, fail if empty
ARG VERSION
RUN test -n "$VERSION" || (echo "VERSION not set" && false)

# if --build-arg VEHICLE_TYPE=1, set ARDUPILOT_TAG to 'Plane-X.X.X' or set to null otherwise.
ENV ARDUPILOT_TAG=${VEHICLE_TYPE:+Plane-4.3.4}
ENV ARDUPILOT_TAG=${VEHICLE_TYPE:+Plane-${VERSION}}
# if ARDUPILOT_TAG is null, set it to 'Copter-X.X.X' (or leave as is otherwise).
ENV ARDUPILOT_TAG=${ARDUPILOT_TAG:-Copter-4.3.7}
ENV ARDUPILOT_TAG=${ARDUPILOT_TAG:-Copter-${VERSION}}

# The ARDUPILOT repo and ref to use for the build
ENV ARDUPILOT_REPO=https://github.com/ArduPilot/ardupilot.git
Expand Down

0 comments on commit 296abcf

Please sign in to comment.