Skip to content

Commit 20c1088

Browse files
authored
add docker build system (#9)
* add docker build system * update secret * test scheduling * test schedule * test * Update build_base_images.yml * update * switch to single url * add manifest * sw to multi package * update syntax * fix variable name * update * update * remove PR triggers * add main docker build * update * change name * updates * remove obsolete script
1 parent 3ebd05a commit 20c1088

File tree

5 files changed

+238
-0
lines changed

5 files changed

+238
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: base docker images
2+
3+
# scheduled run every day at 00:00 GMT +03:00
4+
on:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: "0 21 * * *"
8+
9+
concurrency:
10+
group: base_images
11+
cancel-in-progress: true
12+
13+
env:
14+
BASE_IMAGE_TAG: ghcr.io/itu-auv/auv-software-base
15+
16+
jobs:
17+
build-and-push:
18+
runs-on: ubuntu-latest
19+
20+
strategy:
21+
matrix:
22+
host: [desktop, tegra]
23+
include:
24+
# configuration for desktop base image
25+
- base_image: ros:noetic-ros-base
26+
platform: linux/amd64
27+
architecture: amd64
28+
host: desktop
29+
# configuration for tegra base image
30+
- base_image: dustynv/ros:noetic-ros-base-l4t-r35.2.1
31+
platform: linux/arm64
32+
architecture: arm64
33+
host: tegra
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Set up QEMU
40+
uses: docker/setup-qemu-action@v3
41+
with:
42+
platforms: ${{ matrix.platform }}
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Login to Github Containter Registry
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Build and push base image
55+
uses: docker/build-push-action@v5
56+
with:
57+
context: .
58+
file: ./docker/Dockerfile.auv-base
59+
platforms: ${{ matrix.platform }}
60+
push: true
61+
build-args: |
62+
BASE_IMAGE=${{ matrix.base_image }}
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max
65+
provenance: false
66+
sbom: false
67+
tags: |
68+
${{ env.BASE_IMAGE_TAG }}:latest-${{ matrix.architecture }}
69+
${{ env.BASE_IMAGE_TAG }}:${{ github.sha }}-${{ matrix.architecture }}
70+
71+
create-manifests:
72+
runs-on: ubuntu-latest
73+
needs: [build-and-push]
74+
75+
steps:
76+
- uses: actions/checkout@v4
77+
78+
- name: Set up QEMU
79+
uses: docker/setup-qemu-action@v3
80+
81+
- name: Login to Github Containter Registry
82+
uses: docker/login-action@v3
83+
with:
84+
registry: ghcr.io
85+
username: ${{ github.actor }}
86+
password: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Create SHA manifest and push
89+
run: |
90+
docker manifest create \
91+
${{ env.BASE_IMAGE_TAG }}:${{ github.sha }} \
92+
--amend ${{ env.BASE_IMAGE_TAG }}:${{ github.sha }}-amd64 \
93+
--amend ${{ env.BASE_IMAGE_TAG }}:${{ github.sha }}-arm64
94+
docker manifest push ${{ env.BASE_IMAGE_TAG }}:${{ github.sha }}
95+
96+
- name: Create latest manifest and push
97+
run: |
98+
docker manifest create \
99+
${{ env.BASE_IMAGE_TAG }}:latest \
100+
--amend ${{ env.BASE_IMAGE_TAG }}:latest-amd64 \
101+
--amend ${{ env.BASE_IMAGE_TAG }}:latest-arm64
102+
docker manifest push ${{ env.BASE_IMAGE_TAG }}:latest
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: main docker images
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
push:
9+
branches:
10+
- main
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.pull_request.number) || github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
BASE_IMAGE_TAG: ghcr.io/itu-auv/auv-software-base
18+
IMAGE_TAG: ghcr.io/itu-auv/auv-software
19+
20+
jobs:
21+
build-and-push:
22+
runs-on: ubuntu-latest
23+
24+
strategy:
25+
matrix:
26+
host: [desktop, tegra]
27+
include:
28+
# configuration for desktop image
29+
- platform: linux/amd64
30+
architecture: amd64
31+
host: desktop
32+
# configuration for tegra image
33+
- platform: linux/arm64
34+
architecture: arm64
35+
host: tegra
36+
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
41+
- name: Set up QEMU
42+
uses: docker/setup-qemu-action@v3
43+
with:
44+
platforms: ${{ matrix.platform }}
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
49+
- name: Login to Github Containter Registry
50+
uses: docker/login-action@v3
51+
with:
52+
registry: ghcr.io
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Build and push main image
57+
uses: docker/build-push-action@v5
58+
with:
59+
context: .
60+
file: ./docker/Dockerfile.auv
61+
platforms: ${{ matrix.platform }}
62+
push: ${{ github.event_name == 'push' }}
63+
build-args: |
64+
BASE_IMAGE=${{ env.BASE_IMAGE_TAG }}:latest-${{ matrix.architecture }}
65+
cache-from: type=gha
66+
cache-to: type=gha,mode=max
67+
provenance: false
68+
sbom: false
69+
tags: |
70+
${{ env.IMAGE_TAG }}:latest-${{ matrix.architecture }}
71+
${{ env.IMAGE_TAG }}:${{ github.sha }}-${{ matrix.architecture }}
72+
73+
create-manifests:
74+
runs-on: ubuntu-latest
75+
needs: [build-and-push]
76+
if: github.event_name == 'push'
77+
steps:
78+
- uses: actions/checkout@v4
79+
80+
- name: Set up QEMU
81+
uses: docker/setup-qemu-action@v3
82+
83+
- name: Login to Github Containter Registry
84+
uses: docker/login-action@v3
85+
with:
86+
registry: ghcr.io
87+
username: ${{ github.actor }}
88+
password: ${{ secrets.GITHUB_TOKEN }}
89+
90+
- name: Create SHA manifest and push
91+
run: |
92+
docker manifest create \
93+
${{ env.IMAGE_TAG }}:${{ github.sha }} \
94+
--amend ${{ env.IMAGE_TAG }}:${{ github.sha }}-amd64 \
95+
--amend ${{ env.IMAGE_TAG }}:${{ github.sha }}-arm64
96+
docker manifest push ${{ env.IMAGE_TAG }}:${{ github.sha }}
97+
98+
- name: Create latest manifest and push
99+
run: |
100+
docker manifest create \
101+
${{ env.IMAGE_TAG }}:latest \
102+
--amend ${{ env.IMAGE_TAG }}:latest-amd64 \
103+
--amend ${{ env.IMAGE_TAG }}:latest-arm64
104+
docker manifest push ${{ env.IMAGE_TAG }}:latest

docker/Dockerfile.auv

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ARG BASE_IMAGE=ghcr.io/itu-auv/auv-software-jetson-base:latest
2+
3+
FROM ${BASE_IMAGE}
4+
5+
COPY . ./src/auv_software
6+
7+
# Install dependencies
8+
RUN apt-get update && \
9+
vcs import src/ < src/auv_software/third_party.repos && \
10+
rosdep install --from-paths src --ignore-src -r -y && \
11+
rm -rf /var/lib/apt/lists/*
12+
13+
# Build the workspace
14+
RUN . /opt/ros/noetic/setup.sh && \
15+
catkin build -- auv_software

docker/Dockerfile.auv-base

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ARG BASE_IMAGE=nvcr.io/nvidia/l4t-ml:r35.2.1-py3
2+
ARG BASE_IMAGE=dustynv/ros:noetic-ros-base-l4t-r35.2.1
3+
4+
FROM ${BASE_IMAGE}
5+
6+
WORKDIR /auv_ws
7+
8+
RUN apt-get update && \
9+
apt-get install -y \
10+
python3-vcstool \
11+
python3-catkin-tools && \
12+
# Install preliminary dependencies
13+
apt-get install -y \
14+
ros-noetic-robot-localization && \
15+
rm -rf /var/lib/apt/lists/*
16+

third_party.repos

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
repositories:

0 commit comments

Comments
 (0)