diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml new file mode 100644 index 0000000..5149372 --- /dev/null +++ b/.github/workflows/dev-build.yml @@ -0,0 +1,81 @@ +name: Development Build + +on: + pull_request: + branches: + - main + types: + - opened + - synchronize + +jobs: + dev-build: + runs-on: ubuntu-latest + + permissions: + packages: write + contents: read + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Extract Version for Dev Build + id: versioning + run: | + branch_name=${{ github.head_ref }} + if [[ "$branch_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + version=${branch_name#v} + echo "version=$version" >> $GITHUB_OUTPUT + echo "ghcr_tag=ghcr.io/thunderatz/stm32cubemx:${version}-dev" >> $GITHUB_OUTPUT + else + echo "Error: Branch name must follow 'vx.y.z' pattern." >&2 + exit 1 + fi + shell: bash + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push Dev Docker Image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.versioning.outputs.ghcr_tag }} + cache-from: type=registry,ref=ghcr.io/thunderatz/stm32cubemx:${{ steps.versioning.outputs.version }} + cache-to: type=inline + + - name: Build and Push Dev Docker Image for G4 MCU + uses: docker/build-push-action@v3 + with: + context: . + build-args: MCU=G4 + push: true + tags: ${{ steps.versioning.outputs.ghcr_tag }}-g4 + cache-from: type=registry,ref=ghcr.io/thunderatz/stm32cubemx:${{ steps.versioning.outputs.version }}-g4 + cache-to: type=inline + + - name: Build and Push Dev Docker Image for F4 MCU + uses: docker/build-push-action@v3 + with: + context: . + build-args: MCU=F4 + push: true + tags: ${{ steps.versioning.outputs.ghcr_tag }}-f4 + cache-from: type=registry,ref=ghcr.io/thunderatz/stm32cubemx:${{ steps.versioning.outputs.version }}-f4 + cache-to: type=inline + + - name: Build and Push Dev Docker Image for F1 MCU + uses: docker/build-push-action@v3 + with: + context: . + build-args: MCU=F1 + push: true + tags: ${{ steps.versioning.outputs.ghcr_tag }}-f1 + cache-from: type=registry,ref=ghcr.io/thunderatz/stm32cubemx:${{ steps.versioning.outputs.version }}-f1 + cache-to: type=inline diff --git a/.github/workflows/prod-build.yml b/.github/workflows/prod-build.yml new file mode 100644 index 0000000..3c50392 --- /dev/null +++ b/.github/workflows/prod-build.yml @@ -0,0 +1,89 @@ +name: Production Build + +on: + pull_request: + branches: + - main + types: + - closed + +jobs: + prod-build: + if: github.event.pull_request.merged == true + + runs-on: ubuntu-latest + + permissions: + packages: write + contents: read + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Extract Version for Production Build + id: versioning + run: | + branch_name=${{ github.head_ref }} + if [[ "$branch_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + version=${branch_name#v} + echo "version=$version" >> $GITHUB_OUTPUT + echo "ghcr_tag=ghcr.io/thunderatz/stm32cubemx:${version}" >> $GITHUB_OUTPUT + echo "docker_tag=thunderatz/stm32cubemx:${version}" >> $GITHUB_OUTPUT + else + echo "Error: Branch name must follow 'vx.y.z' pattern." >&2 + exit 1 + fi + shell: bash + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build and Push Production Docker Image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.versioning.outputs.ghcr_tag }},${{ steps.versioning.outputs.docker_tag }} + cache-from: type=registry,ref=ghcr.io/thunderatz/stm32cubemx:${{ steps.versioning.outputs.version }} + cache-to: type=inline + + - name: Build and Push Production Docker Image for G4 MCU + uses: docker/build-push-action@v3 + with: + context: . + build-args: MCU=G4 + push: true + tags: ${{ steps.versioning.outputs.ghcr_tag }}-g4,${{ steps.versioning.outputs.docker_tag }}-g4 + cache-from: type=registry,ref=ghcr.io/thunderatz/stm32cubemx:${{ steps.versioning.outputs.version }}-g4 + cache-to: type=inline + + - name: Build and Push Production Docker Image for F4 MCU + uses: docker/build-push-action@v3 + with: + context: . + build-args: MCU=F4 + push: true + tags: ${{ steps.versioning.outputs.ghcr_tag }}-f4,${{ steps.versioning.outputs.docker_tag }}-f4 + cache-from: type=registry,ref=ghcr.io/thunderatz/stm32cubemx:${{ steps.versioning.outputs.version }}-f4 + cache-to: type=inline + + - name: Build and Push Production Docker Image for F1 MCU + uses: docker/build-push-action@v3 + with: + context: . + build-args: MCU=F1 + push: true + tags: ${{ steps.versioning.outputs.ghcr_tag }}-f1,${{ steps.versioning.outputs.docker_tag }}-f1 + cache-from: type=registry,ref=ghcr.io/thunderatz/stm32cubemx:${{ steps.versioning.outputs.version }}-f1 + cache-to: type=inline diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8caff8b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu:24.04 AS stm32cubemx + +RUN apt-get update -y && \ + apt-get upgrade -y && \ + apt-get install -y \ + unzip \ + xvfb \ + wget \ + openjdk-21-jre \ + libgbm1 \ + && apt-get clean + +RUN mkdir st && cd st && \ + wget -nv https://sw-center.st.com/packs/resource/library/stm32cube_mx_v6130-lin.zip && \ + unzip -q stm32cube_mx_v6130-lin.zip && \ + unzip -q JavaJre.zip && \ + mv MX /root/STM32CubeMX && \ + mv jre /root/STM32CubeMX && \ + cd .. && rm -rf st + +ENV CUBE_PATH="/root/STM32CubeMX" + +RUN echo "exit" > /root/cube-init && \ + Xvfb :10 -ac > /dev/null & \ + export DISPLAY=:10 && \ + $CUBE_PATH/STM32CubeMX -q /root/cube-init && \ + rm /root/cube-init && \ + pkill -f Xvfb + + +RUN rm /tmp/.X10-lock + +ARG MCU + +RUN if [ -z "$MCU" ]; then \ + echo "Docker built without MCU repository."; \ + else \ + apt-get install -y git && \ + mkdir -p /root/STM32Cube/Repository && cd /root/STM32Cube/Repository && \ + git clone https://github.com/STMicroelectronics/STM32Cube${MCU}.git && \ + cd STM32Cube${MCU} && \ + git submodule update --init --recursive; \ + fi diff --git a/README.md b/README.md index 7573630..d68f7dd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,131 @@ -# stm32cubemx_docker -Docker configurations for STM32 development with CubeMX + +
+ +STM32CubeMX Setup and Docker Environment for STM32 Projects + +
+ +
+ Built with Docker + Uses STM32CubeMX + Built on Ubuntu +
+ + +## 📑 Summary + +- [📑 Summary](#-summary) +- [🔨 Building](#-building) +- [🚀 Running](#-running) +- [💻 Docker Setup](#-docker-setup) +- [👥 Contributing](#-contributing) +- [✨ Contributors](#-contributors) + +## 🚀 Running + +To use the `thunderatz/stm32cubemx` image in another container, you can pull it directly from the GitHub Container Registry (GHCR) or Docker Hub. + +### 1. Pulling the Image + +If you're using **Docker Hub**, use the following command: + +```bash +docker pull thunderatz/stm32cubemx:6.13.0 +``` + +If you're using **GHCR**, the command will be: + +```bash +docker pull ghcr.io/thunderatz/stm32cubemx:6.13.0 +``` + +### 2. Running the Image + +After pulling the image, you can run it in a container with the following command. Make sure to adjust the volume according to your project: + +```bash +docker run --rm -it \ + -v /path/to/your/project:/workspace \ + thunderatz/stm32cubemx:6.13.0 +``` + +Or, if you're using **GHCR**: + +```bash +docker run --rm -it \ + -v /path/to/your/project:/workspace \ + ghcr.io/thunderatz/stm32cubemx:6.13.0 +``` + +## 🔨 Building + +This project uses Docker to containerize the STM32CubeMX environment, making setup and development easier. Follow these steps to set up your environment: + +### 1. Build the Docker Image + +Make sure Docker is installed on your machine. To build the Docker image, run the following command in the project's root directory: + +```bash +docker build -t stm32cubemx -f . +``` + +This will download and install all necessary dependencies, including STM32CubeMX and Java Runtime. + +### 2. Run STM32CubeMX in Docker + +Once the image is built, you can run STM32CubeMX inside the Docker container. To do this, execute the following command: + +```bash +docker run -it --rm stm32cubemx +``` + +This will launch the STM32CubeMX environment inside the Docker container, allowing you to work on your STM32 project. + +## 💻 Docker Setup + +The Dockerfile provided in this repository creates a containerized environment for STM32CubeMX. It includes all the necessary dependencies to run STM32CubeMX on an Ubuntu system. Here's a summary of how the Dockerfile works: + +- **Base Image**: The Dockerfile starts from the official Ubuntu 24.04 image. +- **Dependencies**: It installs essential packages such as `unzip`, `xvfb`, `wget`, `openjdk-21-jre`, and others required to run STM32CubeMX. +- **STM32CubeMX**: It downloads and sets up STM32CubeMX, along with the Java Runtime. +- **X11 Virtual Frame Buffer (Xvfb)**: A virtual X server is used to run the GUI-based STM32CubeMX in headless mode. + +## 👥 Contributing + +We welcome contributions! To contribute to the `ThundeRatz/stm32cubemx` project, please follow these guidelines: + +1. **Fork the repository** – Start by forking this repository to your own GitHub account. + +2. **Create a new branch** – When creating a new branch for your changes, please name the branch according to the version of STM32CubeMX you are working with. For example: + + - `v6.13.1` for version 6.13.1 of STM32CubeMX + - `v6.14.0` for version 6.14.0 of STM32CubeMX + +3. **Make your changes** – Implement the desired changes or fixes in your branch. + +4. **Test your changes** – Ensure everything works as expected within the container. Build and verify the setup for STM32CubeMX. + +5. **Submit a pull request** – Once your changes are ready, submit a pull request (PR) with a detailed description of the modifications. + +We appreciate all contributions, whether it's reporting issues, suggesting features, or submitting fixes! + +## ✨ Contributors + +Thanks goes to these wonderful people: + + + + + + + + + +
Eduardo Barreto
Eduardo Barreto

💻 📖 🔬 👀
Gabriel Cosme Barbosa
Gabriel Cosme Barbosa

💻 🔬 👀
+ + + + + + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of all kinds are welcome!