diff --git a/.env b/.env new file mode 100644 index 0000000..cc56610 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +UBUNTU_VERSION_LATEST=22.04 +UBUNTU_VERSION_PREVIOUS=20.04 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5cd88ca..25eedd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,12 @@ -FROM ripl/lcm:latest +# Parameters +ARG REPO_NAME="libbot2-docker" +ARG DESCRIPTION="Contains the libbot libraries and executables" +ARG MAINTAINER="Matthew Walter (mwalter@ttic.edu)" + +ARG UBUNTU_VERSION=20.04 + +# Base image +FROM ripl/lcm:$UBUNTU_VERSION # arguments ARG INSTALL_DIR=/usr/local @@ -16,6 +24,7 @@ RUN apt update && apt install -y \ freeglut3-dev \ libgtk-3-dev \ libxmu-dev \ + libjpeg8-dev \ python3-numpy \ python3-scipy \ && rm -rf /var/lib/apt/lists/* @@ -32,11 +41,13 @@ RUN mkdir -p /tmp/libbot2 && \ #./scripts/setup/linux/ubuntu/$UBUNTU_DISTRIB_CODENAME/install_prereqs && \ #rm -rf /var/lib/apt/lists/* && \ cd .. && \ - mkdir libbot2-build && \ - # build libbot2 - cd libbot2-build && \ - cmake -DCMAKE_INSTALL_PREFIX=$LIBBOT2_INSTALL_DIR ../libbot2-master && \ - make install && \ - # remove source code - cd / && \ - rm -rf /tmp/libbot2 \ No newline at end of file + mkdir libbot2-build + +# && \ +# # build libbot2 +# cd libbot2-build && \ +# cmake -DCMAKE_INSTALL_PREFIX=$LIBBOT2_INSTALL_DIR ../libbot2-master && \ +# make install && \ +# # remove source code +# cd / && \ +# rm -rf /tmp/libbot2 \ No newline at end of file diff --git a/Makefile b/Makefile index ab8e660..fb8b7ae 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,33 @@ REGISTRY_HOST=docker.io USERNAME=ripl -NAME=libbot2-docker +#NAME=$(shell basename $(CURDIR)) +NAME=libbot2 IMAGE=$(USERNAME)/$(NAME) -# Common variables -LCM_VERSION = "1.5.0" +# Ubuntu versions are stored in the .env file +include .env + +# Base environments +BASE_IMAGE_ENVIRONMENT_LATEST = ripl/lcm:${UBUNTU_VERSION_LATEST} +BASE_IMAGE_ENVIRONMENT_PREVIOUS = ripl/lcm:${UBUNTU_VERSION_PREVIOUS} + # Tag: latest -BASE_IMAGE_LATEST = "ripl/lcm:latest" -BUILD_IMAGE_LATEST = "${IMAGE}:latest" +BUILD_IMAGE_LATEST = $(IMAGE):${UBUNTU_VERSION_LATEST} +BUILD_IMAGE_PREVIOUS = $(IMAGE):${UBUNTU_VERSION_PREVIOUS} + .PHONY: pre-build docker-build build release showver \ - push cleanup + push cleanup build: pre-build docker-build ## builds a new version of the container image(s) pre-build: ## Update the base environment images - docker pull $(BASE_IMAGE_LATEST) + docker pull $(BASE_IMAGE_ENVIRONMENT_LATEST) + docker pull $(BASE_IMAGE_ENVIRONMENT_PREVIOUS) + post-build: @@ -32,20 +41,90 @@ post-push: docker-build: - # Build latest - docker buildx build --platform linux/arm64/v8,linux/amd64 --tag $(BUILD_IMAGE_LATEST) -f Dockerfile . + # Build latest with multiple tags + docker buildx build --build-arg="UBUNTU_VERSION=${UBUNTU_VERSION_LATEST}" --platform linux/arm64/v8,linux/amd64 --tag $(BUILD_IMAGE_LATEST) --tag $(IMAGE):latest -f Dockerfile . + + # Build previous + docker buildx build --build-arg="UBUNTU_VERSION=${UBUNTU_VERSION_PREVIOUS}" --platform linux/arm64/v8,linux/amd64 --tag $(BUILD_IMAGE_PREVIOUS) -f Dockerfile . -release: build push ## builds a new version of your container image(s), and pushes it/them to the registry -push: pre-push do-push post-push +release: build push ## builds a new version of your container image(s), and pushes it/them to the registry -do-push: + +push: pre-push do-push post-push ## pushes the images to dockerhub + +do-push: # Push lateset - docker buildx build --platform linux/arm64/v8,linux/amd64 --push --tag $(BUILD_IMAGE_LATEST) -f Dockerfile . + docker buildx build --build-arg="UBUNTU_VERSION=${UBUNTU_VERSION_LATEST}" --platform linux/arm64/v8,linux/amd64 --push --tag $(BUILD_IMAGE_LATEST) --tag $(IMAGE):latest -f Dockerfile . + + # Push previous + docker buildx build --build-arg="UBUNTU_VERSION=${UBUNTU_VERSION_PREVIOUS}" --platform linux/arm64/v8,linux/amd64 --push --tag $(BUILD_IMAGE_PREVIOUS) -f Dockerfile . + cleanup: ## Remove images pulled/generated as part of the build process - docker rmi $(BASE_IMAGE_LATEST) docker rmi $(BUILD_IMAGE_LATEST) + docker rmi $(IMAGE):latest + docker rmi $(BUILD_IMAGE_PREVIOUS) + docker rmi $(BASE_IMAGE_ENVIRONMENT_LATEST) + docker rmi $(BASE_IMAGE_ENVIRONMENT_PREVIOUS) + + +showver: ## shows the current release tag based on the workspace + echo "RELEASE_VERSION: $(RELEASE_VERSION)" + + +help: ## show this help. + @fgrep -h "##" $(MAKEFILE_LIST) | grep -v fgrep | sed -e 's/\([^:]*\):[^#]*##\(.*\)/printf '"'%-20s - %s\\\\n' '\1' '\2'"'/' |bash + + +# REGISTRY_HOST=docker.io +# USERNAME=ripl +# NAME=libbot2-docker + +# IMAGE=$(USERNAME)/$(NAME) + + +# # Common variables +# LCM_VERSION = "1.5.0" + +# # Tag: latest +# BASE_IMAGE_LATEST = "ripl/lcm:latest" +# BUILD_IMAGE_LATEST = "${IMAGE}:latest" + +# .PHONY: pre-build docker-build build release showver \ +# push cleanup + +# build: pre-build docker-build ## builds a new version of the container image(s) + +# pre-build: ## Update the base environment images +# docker pull $(BASE_IMAGE_LATEST) + + +# post-build: + + +# pre-push: + + +# post-push: + + +# docker-build: + +# # Build latest +# docker buildx build --platform linux/arm64/v8,linux/amd64 --tag $(BUILD_IMAGE_LATEST) -f Dockerfile . + +# release: build push ## builds a new version of your container image(s), and pushes it/them to the registry + +# push: pre-push do-push post-push + +# do-push: +# # Push lateset +# docker buildx build --platform linux/arm64/v8,linux/amd64 --push --tag $(BUILD_IMAGE_LATEST) -f Dockerfile . + +# cleanup: ## Remove images pulled/generated as part of the build process +# docker rmi $(BASE_IMAGE_LATEST) +# docker rmi $(BUILD_IMAGE_LATEST) -help: ## show this help. - @fgrep -h "##" $(MAKEFILE_LIST) | grep -v fgrep | sed -e 's/\([^:]*\):[^#]*##\(.*\)/printf '"'%-20s - %s\\\\n' '\1' '\2'"'/' |bash \ No newline at end of file +# help: ## show this help. +# @fgrep -h "##" $(MAKEFILE_LIST) | grep -v fgrep | sed -e 's/\([^:]*\):[^#]*##\(.*\)/printf '"'%-20s - %s\\\\n' '\1' '\2'"'/' |bash \ No newline at end of file