From e042a655e7ed05c65e51b6ee4d968bb9c3b7aa04 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 12 Oct 2024 09:46:39 -0700 Subject: [PATCH 01/21] Try to get Dockerfile building --- comp/swerve100/Dockerfile | 34 +++++++++++++++++++++++++ comp/swerve100/build.gradle | 11 ++++++++ comp/swerve100/swerve100.code-workspace | 2 +- 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 comp/swerve100/Dockerfile diff --git a/comp/swerve100/Dockerfile b/comp/swerve100/Dockerfile new file mode 100644 index 000000000..c25911706 --- /dev/null +++ b/comp/swerve100/Dockerfile @@ -0,0 +1,34 @@ +# Use an official OpenJDK runtime as a parent image +FROM eclipse-temurin:17-jdk + +# Install necessary tools +RUN apt-get update && apt-get install -y \ + curl \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# Set the working directory in the container +WORKDIR /app + +# Copy just the build.gradle and gradle files +COPY build.gradle settings.gradle gradle.properties ./ +COPY gradle ./gradle +COPY gradlew ./ + +# Make the gradlew script executable +RUN chmod +x ./gradlew + +# Download dependencies +RUN ./gradlew downloadDependencies + +# Now copy the rest of your code +COPY . . + +# Build the project +RUN ./gradlew build + +# Expose the JMX port +EXPOSE 1099 + +# Run the Java application +CMD ["./gradlew", "run"] diff --git a/comp/swerve100/build.gradle b/comp/swerve100/build.gradle index ac85b2003..f09538c9b 100644 --- a/comp/swerve100/build.gradle +++ b/comp/swerve100/build.gradle @@ -218,3 +218,14 @@ wpi.java.configureTestTasks(test) tasks.withType(JavaCompile) { options.compilerArgs.add '-XDstringConcat=inline' } + +// Add this at the end of your build.gradle file +task downloadDependencies() { + doLast { + configurations.all { c -> + if (c.canBeResolved) { + c.resolve() + } + } + } +} diff --git a/comp/swerve100/swerve100.code-workspace b/comp/swerve100/swerve100.code-workspace index da6075ce1..c1b05f9c7 100644 --- a/comp/swerve100/swerve100.code-workspace +++ b/comp/swerve100/swerve100.code-workspace @@ -11,7 +11,7 @@ "java.configuration.updateBuildConfiguration": "automatic", "java.server.launchMode": "Standard", "terminal.integrated.scrollback": 100000, - "workbench.colorTheme": "Default Light+", + "workbench.colorTheme": "Anysphere", "files.autoSave": "afterDelay", "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx32G -Xms100m -Xlog:disable", "workbench.editor.revealIfOpen": true, From bc29f3ab70f6854942599c13793d1b39529064ca Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 12 Oct 2024 10:10:07 -0700 Subject: [PATCH 02/21] Try to get the build working --- comp/swerve100/Dockerfile | 6 ++++-- comp/swerve100/build.gradle | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/comp/swerve100/Dockerfile b/comp/swerve100/Dockerfile index c25911706..058b213ac 100644 --- a/comp/swerve100/Dockerfile +++ b/comp/swerve100/Dockerfile @@ -18,15 +18,17 @@ COPY gradlew ./ # Make the gradlew script executable RUN chmod +x ./gradlew -# Download dependencies -RUN ./gradlew downloadDependencies +# Download dependencies without running the full configuration +RUN ./gradlew dependencies --dry-run # Now copy the rest of your code COPY . . # Build the project +# RUN ./gradlew build --offline RUN ./gradlew build + # Expose the JMX port EXPOSE 1099 diff --git a/comp/swerve100/build.gradle b/comp/swerve100/build.gradle index f09538c9b..13aa1eff9 100644 --- a/comp/swerve100/build.gradle +++ b/comp/swerve100/build.gradle @@ -42,7 +42,10 @@ deploy { // or from command line. If not found an exception will be thrown. // You can use getTeamOrDefault(team) instead of getTeamNumber if you // want to store a team number in this file. - team = project.frc.getTeamNumber() + // team = project.frc.getTeamNumber() + // TODO(dmontauk): a better approach would be to have build dependencies pulled separately + // from the actual build. + team = project.frc.getTeamOrDefault(100) debug = project.frc.getDebugOrDefault(false) artifacts { From abac928d76e710eb1386adba55cda1a25a9796e9 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 12 Oct 2024 10:17:37 -0700 Subject: [PATCH 03/21] Keep iterating on Dockerfile to support caching --- comp/swerve100/Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/comp/swerve100/Dockerfile b/comp/swerve100/Dockerfile index 058b213ac..6e31dabde 100644 --- a/comp/swerve100/Dockerfile +++ b/comp/swerve100/Dockerfile @@ -18,16 +18,14 @@ COPY gradlew ./ # Make the gradlew script executable RUN chmod +x ./gradlew -# Download dependencies without running the full configuration -RUN ./gradlew dependencies --dry-run +# Download dependencies +RUN --mount=type=cache,target=/root/.gradle ./gradlew --build-cache dependencies # Now copy the rest of your code COPY . . # Build the project -# RUN ./gradlew build --offline -RUN ./gradlew build - +RUN --mount=type=cache,target=/root/.gradle ./gradlew --build-cache build --offline # Expose the JMX port EXPOSE 1099 From 68f0e2a6254962bb055e95e4116f1ad86526c37a Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 19 Oct 2024 09:59:40 -0700 Subject: [PATCH 04/21] First try --- raspberry_pi/.devcontainer/Dockerfile | 1 + raspberry_pi/.devcontainer/devcontainer.json | 1 + raspberry_pi/.vscode/launch.json | 20 +++++++ raspberry_pi/.vscode/settings.json | 2 +- raspberry_pi/Dockerfile | 55 ++++++++++++++++++++ raspberry_pi/app/fake_display.py | 12 +++++ raspberry_pi/requirements.txt | 6 +++ 7 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 raspberry_pi/.devcontainer/Dockerfile create mode 100644 raspberry_pi/.devcontainer/devcontainer.json create mode 100644 raspberry_pi/.vscode/launch.json create mode 100644 raspberry_pi/Dockerfile create mode 100644 raspberry_pi/app/fake_display.py create mode 100644 raspberry_pi/requirements.txt diff --git a/raspberry_pi/.devcontainer/Dockerfile b/raspberry_pi/.devcontainer/Dockerfile new file mode 100644 index 000000000..0519ecba6 --- /dev/null +++ b/raspberry_pi/.devcontainer/Dockerfile @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/raspberry_pi/.devcontainer/devcontainer.json b/raspberry_pi/.devcontainer/devcontainer.json new file mode 100644 index 000000000..0519ecba6 --- /dev/null +++ b/raspberry_pi/.devcontainer/devcontainer.json @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/raspberry_pi/.vscode/launch.json b/raspberry_pi/.vscode/launch.json new file mode 100644 index 000000000..8858414db --- /dev/null +++ b/raspberry_pi/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Docker: Attach to Vision App", + "type": "debugpy", + "request": "attach", + "connect": { + "host": "localhost", + "port": 5678 + }, + "pathMappings": [ + { + "localRoot": "${workspaceFolder}", + "remoteRoot": "/team100" + } + ], + }, + ] +} \ No newline at end of file diff --git a/raspberry_pi/.vscode/settings.json b/raspberry_pi/.vscode/settings.json index c6d4db8f2..ececd0038 100644 --- a/raspberry_pi/.vscode/settings.json +++ b/raspberry_pi/.vscode/settings.json @@ -9,7 +9,7 @@ ], "python.testing.pytestEnabled": false, "python.testing.unittestEnabled": true, - "workbench.colorTheme": "Default Light Modern", + "workbench.colorTheme": "Default Dark Modern", "editor.minimap.enabled": false, "python.analysis.typeCheckingMode": "standard", "mypy-type-checker.reportingScope": "workspace", diff --git a/raspberry_pi/Dockerfile b/raspberry_pi/Dockerfile new file mode 100644 index 000000000..414fa766c --- /dev/null +++ b/raspberry_pi/Dockerfile @@ -0,0 +1,55 @@ +# Use the official Raspberry Pi OS image as a base +FROM dtcooper/raspberrypi-os:bookworm + +# Install system dependencies +RUN apt-get update +RUN apt-get install -y python3-pip +RUN apt-get install -y python3-setuptools +RUN apt-get install -y python3-wheel +RUN apt-get install -y python3-numpy +RUN apt-get install -y libcamera-dev +RUN apt-get install -y python3-aiohttp +RUN apt-get install -y python3-opencv +RUN apt-get install -y python3-venv + +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install Python dependencies +# Create a virtual environment +RUN python3 -m venv /team100/venv + +# Activate the virtual environment +ENV PATH="/team100/venv/bin:$PATH" + +# Copy requirements file +COPY requirements.txt /tmp/requirements.txt + +# Install dependencies in the virtual environment +# RUN pip3 install --no-cache-dir -r /tmp/requirements.txt +RUN pip3 install hidapi +RUN pip3 install adafruit-blinka +RUN pip3 install adafruit-circuitpython-lsm6ds +RUN pip3 install debugpy +RUN pip3 install numpy +RUN pip3 install aiohttp +RUN pip3 install opencv-python +# RUN pip3 install robotpy --prefer-binary +# RUN pip3 install robotpy-cscore --prefer-binary +# RUN pip3 install robotpy-apriltag --prefer-binary + +# Create app directory +WORKDIR /team100 + +# Copy the app files +COPY app /team100/app +COPY app/config /team100/app/config + +# Copy the runapp.py script +COPY runapp.py /team100/runapp.py + +# Remove any __pycache__ directories +#RUN find /team100 -type d -name "__pycache__" -exec rm -rf {} + +EXPOSE 5678 + +# Set the entrypoint to run the app with debugger +#ENTRYPOINT ["python3", "-m", "debugpy", "--listen", "0.0.0.0:5678", "runapp.py"] diff --git a/raspberry_pi/app/fake_display.py b/raspberry_pi/app/fake_display.py new file mode 100644 index 000000000..64f9bf126 --- /dev/null +++ b/raspberry_pi/app/fake_display.py @@ -0,0 +1,12 @@ +class Display: + def __init__(self, width, height, camera_num) -> None: + pass + + def draw_result(self, image, result_item, pose) -> None: + pass + + def draw_text(self, image, msg, loc) -> None: + pass + + def put_frame(self, img) -> None: + pass diff --git a/raspberry_pi/requirements.txt b/raspberry_pi/requirements.txt new file mode 100644 index 000000000..a9e6e3f6e --- /dev/null +++ b/raspberry_pi/requirements.txt @@ -0,0 +1,6 @@ +hidapi +adafruit-blinka +adafruit-circuitpython-lsm6ds +robotpy +robotpy-cscore +robotpy-apriltag \ No newline at end of file From a7d9eab11af4cf01638efdad0987b2011671465f Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 9 Nov 2024 10:45:22 -0800 Subject: [PATCH 05/21] WIP --- .../swerve100/.wpilib/wpilib_preferences.json | 2 +- comp/swerve100/Dockerfile | 25 ++++++++++++++----- comp/swerve100/README.md | 10 ++++++++ comp/swerve100/setup_dev_container.sh | 1 + 4 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 comp/swerve100/setup_dev_container.sh diff --git a/comp/swerve100/.wpilib/wpilib_preferences.json b/comp/swerve100/.wpilib/wpilib_preferences.json index 652e4a8a8..37f3c653c 100644 --- a/comp/swerve100/.wpilib/wpilib_preferences.json +++ b/comp/swerve100/.wpilib/wpilib_preferences.json @@ -3,4 +3,4 @@ "currentLanguage": "java", "projectYear": "2024beta", "teamNumber": 100 -} +} \ No newline at end of file diff --git a/comp/swerve100/Dockerfile b/comp/swerve100/Dockerfile index 6e31dabde..2f3b43540 100644 --- a/comp/swerve100/Dockerfile +++ b/comp/swerve100/Dockerfile @@ -5,30 +5,43 @@ FROM eclipse-temurin:17-jdk RUN apt-get update && apt-get install -y \ curl \ unzip \ + vim \ && rm -rf /var/lib/apt/lists/* # Set the working directory in the container WORKDIR /app +# Install Gradle +ENV GRADLE_VERSION=8.4 +RUN curl -L https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip -o gradle.zip \ + && unzip gradle.zip \ + && rm gradle.zip \ + && mv gradle-${GRADLE_VERSION} /opt/gradle \ + && ln -s /opt/gradle/bin/gradle /usr/bin/gradle + +# Set Gradle environment variables +ENV GRADLE_HOME=/opt/gradle +ENV PATH=$PATH:$GRADLE_HOME/bin + # Copy just the build.gradle and gradle files COPY build.gradle settings.gradle gradle.properties ./ COPY gradle ./gradle -COPY gradlew ./ +# COPY gradlew ./ # Make the gradlew script executable -RUN chmod +x ./gradlew +# RUN chmod +x ./gradlew # Download dependencies -RUN --mount=type=cache,target=/root/.gradle ./gradlew --build-cache dependencies +RUN --mount=type=cache,target=/root/.gradle gradle --build-cache dependencies # Now copy the rest of your code COPY . . # Build the project -RUN --mount=type=cache,target=/root/.gradle ./gradlew --build-cache build --offline +# RUN --mount=type=cache,target=/root/.gradle gradle --build-cache build --offline # Expose the JMX port -EXPOSE 1099 +# EXPOSE 1099 # Run the Java application -CMD ["./gradlew", "run"] +# CMD ["gradle", "run"] diff --git a/comp/swerve100/README.md b/comp/swerve100/README.md index c1cb0f4b9..793d704e1 100644 --- a/comp/swerve100/README.md +++ b/comp/swerve100/README.md @@ -4,3 +4,13 @@ This is the main comp bot repo. Part of the code here was (somewhat distantly) derived from 254 code, and other parts were inspired by Roadrunner. +# Starting Development + +1. Make sure you have Java installed. Download it [here](https://www.oracle.com/java/technologies/downloads/). +1. From your command line you should be able to run: + `./gradlew build` . This should start downloading all the relevant libraries and install them. +1. Visit the WPILib installation instructions [here](https://docs.wpilib.org/en/stable/docs/zero-to-robot/step-2/offline-installation-preparations.html). This is a big file and will take a while to download + install. +1. Once installed, + +# Misc +https://docs.wpilib.org/en/stable/docs/software/vscode-overview/deploying-robot-code.html \ No newline at end of file diff --git a/comp/swerve100/setup_dev_container.sh b/comp/swerve100/setup_dev_container.sh new file mode 100644 index 000000000..0519ecba6 --- /dev/null +++ b/comp/swerve100/setup_dev_container.sh @@ -0,0 +1 @@ + \ No newline at end of file From 5c58c1cc55edf19bc31304d06d05949669c29bac Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 16 Nov 2024 14:41:27 -0800 Subject: [PATCH 06/21] Also add Github Action for this --- .../.github/workflows/pr-docker-build.yml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 raspberry_pi/.github/workflows/pr-docker-build.yml diff --git a/raspberry_pi/.github/workflows/pr-docker-build.yml b/raspberry_pi/.github/workflows/pr-docker-build.yml new file mode 100644 index 000000000..6c7215be4 --- /dev/null +++ b/raspberry_pi/.github/workflows/pr-docker-build.yml @@ -0,0 +1,42 @@ +name: PR Docker Build Check + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: 'arm64,arm' + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build Docker image + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/arm64,linux/arm/v7 + push: false + tags: team100-pi:${{ github.sha }} + # This will show the build progress in the GitHub UI + outputs: type=docker,dest=/tmp/image.tar + + - name: Add PR Comment on Failure + if: failure() + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '❌ Docker build failed! Please check the workflow logs for details.' + }) \ No newline at end of file From 8ab697e1dfa832aa41e5d5d5a3ef8e082eff7668 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 16 Nov 2024 14:44:21 -0800 Subject: [PATCH 07/21] Move Docker build --- {raspberry_pi/.github => .github}/workflows/pr-docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {raspberry_pi/.github => .github}/workflows/pr-docker-build.yml (95%) diff --git a/raspberry_pi/.github/workflows/pr-docker-build.yml b/.github/workflows/pr-docker-build.yml similarity index 95% rename from raspberry_pi/.github/workflows/pr-docker-build.yml rename to .github/workflows/pr-docker-build.yml index 6c7215be4..d066a8278 100644 --- a/raspberry_pi/.github/workflows/pr-docker-build.yml +++ b/.github/workflows/pr-docker-build.yml @@ -2,7 +2,7 @@ name: PR Docker Build Check on: pull_request: - types: [opened, synchronize, reopened] + types: [opened, synchronize, reopened, draft] jobs: build: From 834aae3b08be6f02ffb20f2ac48af55a94dda614 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 16 Nov 2024 14:47:48 -0800 Subject: [PATCH 08/21] Try to get it to run --- .github/workflows/pr-docker-build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pr-docker-build.yml b/.github/workflows/pr-docker-build.yml index d066a8278..5b826b516 100644 --- a/.github/workflows/pr-docker-build.yml +++ b/.github/workflows/pr-docker-build.yml @@ -1,8 +1,6 @@ name: PR Docker Build Check -on: - pull_request: - types: [opened, synchronize, reopened, draft] +on: [push] jobs: build: From 64d03bf6019d34e7cdfd6bc169791a1e65cbf0b9 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 16 Nov 2024 14:50:44 -0800 Subject: [PATCH 09/21] Keep fixing --- .github/workflows/pr-docker-build.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr-docker-build.yml b/.github/workflows/pr-docker-build.yml index 5b826b516..b69938d1f 100644 --- a/.github/workflows/pr-docker-build.yml +++ b/.github/workflows/pr-docker-build.yml @@ -24,17 +24,17 @@ jobs: platforms: linux/arm64,linux/arm/v7 push: false tags: team100-pi:${{ github.sha }} - # This will show the build progress in the GitHub UI - outputs: type=docker,dest=/tmp/image.tar + # Change the output format to OCI + outputs: type=oci,dest=/tmp/image.tar - - name: Add PR Comment on Failure - if: failure() - uses: actions/github-script@v7 - with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: '❌ Docker build failed! Please check the workflow logs for details.' - }) \ No newline at end of file + # - name: Add PR Comment on Failure + # if: failure() + # uses: actions/github-script@v7 + # with: + # script: | + # github.rest.issues.createComment({ + # issue_number: context.issue.number, + # owner: context.repo.owner, + # repo: context.repo.repo, + # body: '❌ Docker build failed! Please check the workflow logs for details.' + # }) \ No newline at end of file From 4d6066bf1ea56fb1154a18a047366677b93f9ad9 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 16 Nov 2024 14:52:57 -0800 Subject: [PATCH 10/21] Try to fix context --- .github/workflows/pr-docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-docker-build.yml b/.github/workflows/pr-docker-build.yml index b69938d1f..02a7ccdc3 100644 --- a/.github/workflows/pr-docker-build.yml +++ b/.github/workflows/pr-docker-build.yml @@ -20,7 +20,7 @@ jobs: - name: Build Docker image uses: docker/build-push-action@v5 with: - context: . + context: .raspberry_pi platforms: linux/arm64,linux/arm/v7 push: false tags: team100-pi:${{ github.sha }} From 18854e8e2ba0864f0be944bc3b8fb48ae9949376 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 16 Nov 2024 14:54:23 -0800 Subject: [PATCH 11/21] Typo --- .github/workflows/pr-docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-docker-build.yml b/.github/workflows/pr-docker-build.yml index 02a7ccdc3..4cd346f0a 100644 --- a/.github/workflows/pr-docker-build.yml +++ b/.github/workflows/pr-docker-build.yml @@ -20,7 +20,7 @@ jobs: - name: Build Docker image uses: docker/build-push-action@v5 with: - context: .raspberry_pi + context: ./raspberry_pi platforms: linux/arm64,linux/arm/v7 push: false tags: team100-pi:${{ github.sha }} From c69fec2c169abdb34199e24f45bbc77fb91a3320 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 16 Nov 2024 18:07:09 -0800 Subject: [PATCH 12/21] Try to get builds more reliable --- .github/workflows/pr-docker-build.yml | 19 ++++++++++++++++--- raspberry_pi/Dockerfile | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-docker-build.yml b/.github/workflows/pr-docker-build.yml index 4cd346f0a..2e92005f1 100644 --- a/.github/workflows/pr-docker-build.yml +++ b/.github/workflows/pr-docker-build.yml @@ -16,16 +16,29 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + # Enable docker layer caching + buildkitd-flags: --debug + + # Add cache steps before build + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - name: Build Docker image uses: docker/build-push-action@v5 + timeout-minutes: 30 with: context: ./raspberry_pi + cache-from: type=gha + cache-to: type=gha,mode=max` platforms: linux/arm64,linux/arm/v7 - push: false + push: true tags: team100-pi:${{ github.sha }} - # Change the output format to OCI - outputs: type=oci,dest=/tmp/image.tar # - name: Add PR Comment on Failure # if: failure() diff --git a/raspberry_pi/Dockerfile b/raspberry_pi/Dockerfile index 414fa766c..988c24819 100644 --- a/raspberry_pi/Dockerfile +++ b/raspberry_pi/Dockerfile @@ -2,6 +2,7 @@ FROM dtcooper/raspberrypi-os:bookworm # Install system dependencies +RUN echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries RUN apt-get update RUN apt-get install -y python3-pip RUN apt-get install -y python3-setuptools From e6e2086e1c38d907eb70fec122171036559dbcf3 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 16 Nov 2024 18:50:05 -0800 Subject: [PATCH 13/21] more cycles --- .github/workflows/pr-docker-build.yml | 9 --------- raspberry_pi/Dockerfile | 8 ++++---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr-docker-build.yml b/.github/workflows/pr-docker-build.yml index 2e92005f1..9cf94e9e2 100644 --- a/.github/workflows/pr-docker-build.yml +++ b/.github/workflows/pr-docker-build.yml @@ -20,15 +20,6 @@ jobs: # Enable docker layer caching buildkitd-flags: --debug - # Add cache steps before build - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: Build Docker image uses: docker/build-push-action@v5 timeout-minutes: 30 diff --git a/raspberry_pi/Dockerfile b/raspberry_pi/Dockerfile index 988c24819..0447a960d 100644 --- a/raspberry_pi/Dockerfile +++ b/raspberry_pi/Dockerfile @@ -33,10 +33,10 @@ RUN pip3 install adafruit-circuitpython-lsm6ds RUN pip3 install debugpy RUN pip3 install numpy RUN pip3 install aiohttp -RUN pip3 install opencv-python -# RUN pip3 install robotpy --prefer-binary -# RUN pip3 install robotpy-cscore --prefer-binary -# RUN pip3 install robotpy-apriltag --prefer-binary +# RUN pip3 install opencv-python +RUN pip3 install robotpy --prefer-binary +RUN pip3 install robotpy-cscore --prefer-binary +RUN pip3 install robotpy-apriltag --prefer-binary # Create app directory WORKDIR /team100 From 3dae4180dc1c4ad6ecd5cdc4a28cee66a494ae72 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 16 Nov 2024 19:33:15 -0800 Subject: [PATCH 14/21] Another change --- raspberry_pi/Dockerfile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/raspberry_pi/Dockerfile b/raspberry_pi/Dockerfile index 0447a960d..75382b585 100644 --- a/raspberry_pi/Dockerfile +++ b/raspberry_pi/Dockerfile @@ -34,9 +34,16 @@ RUN pip3 install debugpy RUN pip3 install numpy RUN pip3 install aiohttp # RUN pip3 install opencv-python -RUN pip3 install robotpy --prefer-binary -RUN pip3 install robotpy-cscore --prefer-binary -RUN pip3 install robotpy-apriltag --prefer-binary +RUN pip3 install --prefer-binary robotpy-wpiutil +RUN pip3 install --prefer-binary robotpy-wpimath +RUN pip3 install --prefer-binary robotpy-wpinet +RUN pip3 install --prefer-binary robotpy-hal +RUN pip3 install --prefer-binary robotpy-halsim +RUN pip3 install --prefer-binary robotpy-commands-v2 +RUN pip3 install --prefer-binary robotpy +# Then install the additional robotpy packages +RUN pip3 install robotpy-cscore +RUN pip3 install robotpy-apriltag # Create app directory WORKDIR /team100 From bef2506c867bedbe1c6a5054ce6b76198e7b7ed3 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 16 Nov 2024 19:48:35 -0800 Subject: [PATCH 15/21] One more try --- raspberry_pi/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/raspberry_pi/Dockerfile b/raspberry_pi/Dockerfile index 75382b585..2cad37820 100644 --- a/raspberry_pi/Dockerfile +++ b/raspberry_pi/Dockerfile @@ -12,6 +12,8 @@ RUN apt-get install -y libcamera-dev RUN apt-get install -y python3-aiohttp RUN apt-get install -y python3-opencv RUN apt-get install -y python3-venv +RUN apt-get install -y build-essential +RUN apt-get install -y python3-dev RUN apt-get clean && rm -rf /var/lib/apt/lists/* From f46188c5515e1e4ca9829239ef1bfc40c129aa02 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sun, 17 Nov 2024 11:10:39 -0800 Subject: [PATCH 16/21] Remove Apriltag support --- raspberry_pi/Dockerfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/raspberry_pi/Dockerfile b/raspberry_pi/Dockerfile index 2cad37820..b290a28a3 100644 --- a/raspberry_pi/Dockerfile +++ b/raspberry_pi/Dockerfile @@ -36,16 +36,16 @@ RUN pip3 install debugpy RUN pip3 install numpy RUN pip3 install aiohttp # RUN pip3 install opencv-python -RUN pip3 install --prefer-binary robotpy-wpiutil -RUN pip3 install --prefer-binary robotpy-wpimath -RUN pip3 install --prefer-binary robotpy-wpinet -RUN pip3 install --prefer-binary robotpy-hal -RUN pip3 install --prefer-binary robotpy-halsim -RUN pip3 install --prefer-binary robotpy-commands-v2 -RUN pip3 install --prefer-binary robotpy -# Then install the additional robotpy packages -RUN pip3 install robotpy-cscore -RUN pip3 install robotpy-apriltag +# RUN pip3 install --prefer-binary robotpy-wpiutil +# RUN pip3 install --prefer-binary robotpy-wpimath +# RUN pip3 install --prefer-binary robotpy-wpinet +# RUN pip3 install --prefer-binary robotpy-hal +# RUN pip3 install --prefer-binary robotpy-halsim +# RUN pip3 install --prefer-binary robotpy-commands-v2 +# RUN pip3 install --prefer-binary robotpy +# # Then install the additional robotpy packages +# RUN pip3 install robotpy-cscore +# RUN pip3 install robotpy-apriltag # Create app directory WORKDIR /team100 From abd34335f5eb827f3c2fda0ea78c8b8eb11b3833 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 7 Dec 2024 09:22:56 -0800 Subject: [PATCH 17/21] Don't push the image --- .github/workflows/pr-docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-docker-build.yml b/.github/workflows/pr-docker-build.yml index 9cf94e9e2..742677dee 100644 --- a/.github/workflows/pr-docker-build.yml +++ b/.github/workflows/pr-docker-build.yml @@ -28,7 +28,7 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max` platforms: linux/arm64,linux/arm/v7 - push: true + push: false tags: team100-pi:${{ github.sha }} # - name: Add PR Comment on Failure From 4f2362dc6c93ebf7ca63b9404beacde9fada6168 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 7 Dec 2024 10:58:25 -0800 Subject: [PATCH 18/21] Try to get swerve build workingn again --- .github/workflows/swerve-100-build.yml | 44 +++++++++++++++++++ Dockerfile | 24 ++++++++++ Dockerfile copy | 31 +++++++++++++ .../swerve100/{Dockerfile => Dockerfile.orig} | 1 - 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/swerve-100-build.yml create mode 100644 Dockerfile create mode 100644 Dockerfile copy rename comp/swerve100/{Dockerfile => Dockerfile.orig} (95%) diff --git a/.github/workflows/swerve-100-build.yml b/.github/workflows/swerve-100-build.yml new file mode 100644 index 000000000..4e9d7f595 --- /dev/null +++ b/.github/workflows/swerve-100-build.yml @@ -0,0 +1,44 @@ +name: PR Docker Build Check + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # - name: Set up QEMU + # uses: docker/setup-qemu-action@v3 + # with: + # platforms: 'arm64,arm' + + # - name: Set up Docker Buildx + # uses: docker/setup-buildx-action@v3 + # with: + # # Enable docker layer caching + # buildkitd-flags: --debug + + - name: Build Docker image + uses: docker/build-push-action@v5 + timeout-minutes: 30 + with: + context: . + # cache-from: type=gha + # cache-to: type=gha,mode=max` + # platforms: linux/arm64,linux/arm/v7 + push: false + tags: team100-pi:${{ github.sha }} + + # - name: Add PR Comment on Failure + # if: failure() + # uses: actions/github-script@v7 + # with: + # script: | + # github.rest.issues.createComment({ + # issue_number: context.issue.number, + # owner: context.repo.owner, + # repo: context.repo.repo, + # body: '❌ Docker build failed! Please check the workflow logs for details.' + # }) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..dbe25c8bf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# Use the same WPILib container as the GitHub Action +FROM wpilib/roborio-cross-ubuntu:2024-22.04 + +# Set working directory +WORKDIR /team100/comp/swerve100 + +# Copy only wrapper files first +COPY comp/swerve100/gradle ./gradle +COPY comp/swerve100/gradlew comp/swerve100/gradlew.bat ./ + +# Make gradlew executable (same as in GitHub Action) +RUN chmod +x gradlew + +# Copy build configuration +COPY comp/swerve100/*.gradle comp/swerve100/gradle.properties ./ + +# Download dependencies using wrapper +RUN ./gradlew + +# Now copy the rest of your code +COPY comp/swerve100/src ./src + +# Build and test (same command as in GitHub Action) +RUN ./gradlew build \ No newline at end of file diff --git a/Dockerfile copy b/Dockerfile copy new file mode 100644 index 000000000..e9cfd0a40 --- /dev/null +++ b/Dockerfile copy @@ -0,0 +1,31 @@ +FROM wpilib/roborio-cross-ubuntu:2024-22.04 + +WORKDIR /app + +# Copy only wrapper files first +COPY gradle ./gradle +COPY gradlew gradlew.bat ./ + +# Make gradlew executable +RUN chmod +x gradlew + +# Copy build configuration +COPY *.gradle gradle.properties ./ + + +# Download dependencies using wrapper +RUN --mount=type=cache,target=/root/.gradle ./gradlew --build-cache dependencies +RUN ./gradlew + +# Create a custom gradle.properties to override desktop/simulation settings +RUN echo "includeDesktopSupport=false" > gradle.properties + +# Now copy the rest of your code +COPY src ./src + +# Build with specific options, focusing only on robot code +RUN ./gradlew build --no-daemon \ + -PskipTests \ + -x simulateJava \ + -x test + diff --git a/comp/swerve100/Dockerfile b/comp/swerve100/Dockerfile.orig similarity index 95% rename from comp/swerve100/Dockerfile rename to comp/swerve100/Dockerfile.orig index 2f3b43540..61a34d6bb 100644 --- a/comp/swerve100/Dockerfile +++ b/comp/swerve100/Dockerfile.orig @@ -1,4 +1,3 @@ -# Use an official OpenJDK runtime as a parent image FROM eclipse-temurin:17-jdk # Install necessary tools From 3d48b5512e97c31201d2336f3bca65aae4d880c9 Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 7 Dec 2024 11:55:05 -0800 Subject: [PATCH 19/21] Try again --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index dbe25c8bf..d7cc26104 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,12 @@ COPY comp/swerve100/*.gradle comp/swerve100/gradle.properties ./ # Download dependencies using wrapper RUN ./gradlew +# Lib doesn't change often; copy before the other code +WORKDIR /team100 +COPY lib ./ + # Now copy the rest of your code +WORKDIR /team100/comp/swerve100 COPY comp/swerve100/src ./src # Build and test (same command as in GitHub Action) From 04d6f0a3d579617f5d35973a3cd2fda5345a4f8b Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 7 Dec 2024 12:11:02 -0800 Subject: [PATCH 20/21] Fix lib dir --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d7cc26104..0ac9c3c3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,11 +19,11 @@ RUN ./gradlew # Lib doesn't change often; copy before the other code WORKDIR /team100 -COPY lib ./ +COPY lib ./lib # Now copy the rest of your code WORKDIR /team100/comp/swerve100 COPY comp/swerve100/src ./src # Build and test (same command as in GitHub Action) -RUN ./gradlew build \ No newline at end of file +# RUN ./gradlew build \ No newline at end of file From edffe2345b48e7958b908d5dfd7eeb5976610d0a Mon Sep 17 00:00:00 2001 From: Dobromir Montauk Date: Sat, 7 Dec 2024 12:12:50 -0800 Subject: [PATCH 21/21] Try the end-to-end build --- .github/workflows/swerve-100-build.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swerve-100-build.yml b/.github/workflows/swerve-100-build.yml index 4e9d7f595..3fbe7967b 100644 --- a/.github/workflows/swerve-100-build.yml +++ b/.github/workflows/swerve-100-build.yml @@ -1,4 +1,4 @@ -name: PR Docker Build Check +name: Swerve100 Docker Build on: [push] diff --git a/Dockerfile b/Dockerfile index 0ac9c3c3e..c9f00eae2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,4 +26,4 @@ WORKDIR /team100/comp/swerve100 COPY comp/swerve100/src ./src # Build and test (same command as in GitHub Action) -# RUN ./gradlew build \ No newline at end of file +RUN ./gradlew build \ No newline at end of file