Skip to content

Commit 06f3ab9

Browse files
committed
Initial commit
1 parent 9525209 commit 06f3ab9

File tree

13 files changed

+546
-0
lines changed

13 files changed

+546
-0
lines changed

.github/workflows/platformio.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# PlatformIO Docker Build Workflow
2+
name: PlatformIO Docker Image
3+
4+
on:
5+
push:
6+
branches: [master, dev]
7+
paths:
8+
- '.github/workflows/platformio.yml'
9+
- 'images/platformio/**'
10+
pull_request:
11+
branches: [master, dev]
12+
paths:
13+
- '.github/workflows/platformio.yml'
14+
- 'images/platformio/**'
15+
# Manual trigger
16+
workflow_dispatch:
17+
inputs:
18+
force_rebuild:
19+
description: 'Force rebuild without cache'
20+
required: false
21+
default: false
22+
type: boolean
23+
custom_tag:
24+
description: 'Additional custom tag (optional)'
25+
required: false
26+
default: ''
27+
type: string
28+
# Scheduled monthly rebuild (1st of each month at 2 AM UTC)
29+
schedule:
30+
- cron: '0 2 1 * *'
31+
32+
env:
33+
REGISTRY: ghcr.io
34+
IMAGE_NAME: jethome-dev-platformio
35+
36+
jobs:
37+
build-and-push:
38+
runs-on: ubuntu-latest
39+
permissions:
40+
contents: read
41+
packages: write
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
- name: Log in to GitHub Container Registry
51+
if: github.event_name != 'pull_request'
52+
uses: docker/login-action@v3
53+
with:
54+
registry: ${{ env.REGISTRY }}
55+
username: ${{ github.actor }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
57+
58+
- name: Extract metadata
59+
id: meta
60+
uses: docker/metadata-action@v5
61+
with:
62+
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
63+
64+
- name: Generate tags based on branch
65+
id: tags
66+
run: |
67+
TAGS=""
68+
SHA_SHORT=$(echo "${{ github.sha }}" | cut -c1-7)
69+
VERSION=$(date +%Y.%m.%d)
70+
71+
# Determine branch (for manual/scheduled triggers)
72+
if [[ "${{ github.event_name }}" == "schedule" ]] || [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
73+
BRANCH="${{ github.ref_name }}"
74+
else
75+
BRANCH="${{ github.ref }}"
76+
fi
77+
78+
if [[ "$BRANCH" == "refs/heads/master" ]] || [[ "$BRANCH" == "master" ]]; then
79+
TAGS="${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest"
80+
TAGS="$TAGS,${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:stable"
81+
TAGS="$TAGS,${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:$VERSION"
82+
TAGS="$TAGS,${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:sha-$SHA_SHORT"
83+
elif [[ "$BRANCH" == "refs/heads/dev" ]] || [[ "$BRANCH" == "dev" ]]; then
84+
TAGS="${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:dev"
85+
TAGS="$TAGS,${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:dev-$VERSION"
86+
TAGS="$TAGS,${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:sha-$SHA_SHORT"
87+
fi
88+
89+
# Add custom tag if provided
90+
if [[ "${{ github.event.inputs.custom_tag }}" != "" ]]; then
91+
TAGS="$TAGS,${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.custom_tag }}"
92+
fi
93+
94+
# Add rebuild tag for scheduled/manual rebuilds
95+
if [[ "${{ github.event_name }}" == "schedule" ]]; then
96+
TAGS="$TAGS,${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:monthly-$(date +%Y%m%d)"
97+
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
98+
TAGS="$TAGS,${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:manual-$(date +%Y%m%d-%H%M%S)"
99+
fi
100+
101+
echo "TAGS=$TAGS" >> $GITHUB_OUTPUT
102+
103+
- name: Determine cache strategy
104+
id: cache
105+
run: |
106+
if [[ "${{ github.event.inputs.force_rebuild }}" == "true" ]]; then
107+
echo "CACHE_FROM=" >> $GITHUB_OUTPUT
108+
echo "CACHE_TO=" >> $GITHUB_OUTPUT
109+
else
110+
echo "CACHE_FROM=type=gha" >> $GITHUB_OUTPUT
111+
echo "CACHE_TO=type=gha,mode=max" >> $GITHUB_OUTPUT
112+
fi
113+
114+
- name: Build and push Docker image
115+
uses: docker/build-push-action@v5
116+
with:
117+
context: images/platformio
118+
push: ${{ github.event_name != 'pull_request' }}
119+
tags: ${{ steps.tags.outputs.TAGS }}
120+
labels: ${{ steps.meta.outputs.labels }}
121+
cache-from: ${{ steps.cache.outputs.CACHE_FROM }}
122+
cache-to: ${{ steps.cache.outputs.CACHE_TO }}
123+
platforms: linux/amd64,linux/arm64

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Replit
2+
attached_assets/
3+
.idea/
4+

.replit

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
11
[agent]
22
expertMode = true
3+
4+
[workflows]
5+
runButton = "Project"
6+
7+
[[workflows.workflow]]
8+
name = "Project"
9+
mode = "parallel"
10+
author = "agent"
11+
12+
[[workflows.workflow.tasks]]
13+
task = "workflow.run"
14+
args = "Project Info"
15+
16+
[[workflows.workflow]]
17+
name = "Project Info"
18+
author = "agent"
19+
20+
[[workflows.workflow.tasks]]
21+
task = "shell.exec"
22+
args = "echo \"JetHome Development Environment - Docker CI/CD Project\" && echo \"=================================================\" && echo \"\" && echo \"This project builds Docker images via GitHub Actions.\" && echo \"Push to GitHub to trigger automated builds:\" && echo \" - dev branch → dev images\" && echo \" - master branch → stable images\" && echo \"\" && echo \"Images are published to: ghcr.io/jethome-iot/jethome-dev-platformio\" && sleep infinity"
23+
24+
[workflows.workflow.metadata]
25+
outputType = "console"
26+
27+
[nix]
28+
packages = ["docker"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 JetHome LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# JetHome Development Environment
2+
3+
Collection of Docker images for JetHome development and CI/CD workflows.
4+
5+
## Images
6+
7+
| Image | Description | Tags |
8+
|-------|-------------|------|
9+
| [jethome-dev-platformio](./images/platformio/) | PlatformIO development environment with ESP32 and native platform support | `latest`, `stable`, `dev` |
10+
11+
## Usage
12+
13+
Pull images from GitHub Container Registry:
14+
15+
```bash
16+
docker pull ghcr.io/jethome-iot/jethome-dev-platformio:latest
17+
```
18+
19+
## Building Locally
20+
21+
To build an image locally:
22+
23+
```bash
24+
cd images/platformio
25+
docker build -t jethome-dev-platformio .
26+
```
27+
28+
## CI/CD
29+
30+
Images are automatically built and published to GHCR when:
31+
- Changes are pushed to `master` branch (tagged as `latest`, `stable`, and date-versioned)
32+
- Changes are pushed to `dev` branch (tagged as `dev`, `dev-YYYYMMDD`)
33+
- Monthly scheduled rebuild on the 1st of each month (tagged as `monthly-YYYYMMDD`)
34+
- Manual workflow dispatch (tagged as `manual-YYYYMMDD-HHMMSS`)
35+
36+
Each image has its own GitHub Actions workflow that only triggers when relevant files change.
37+
38+
## License
39+
40+
MIT License - see [LICENSE](LICENSE) file for details.

generated-icon.png

-3.75 KB
Binary file not shown.

images/platformio/Dockerfile

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Use Python 3.11 slim as base for minimal footprint
2+
FROM python:3.11-slim-bookworm
3+
4+
# 6.12 don't work with this image (tested on 2025-10-09)
5+
ARG ESP32_PLATFORM_VERSION=6.11.0
6+
ARG NATIVE_PLATFORM_VERSION=1.2.1
7+
ARG UNITY_VERSION=2.6.0
8+
9+
# List of PlatformIO environments to build by default
10+
ARG PIO_ENVS="esp32 native"
11+
12+
# Configure PlatformIO directories
13+
ENV PLATFORMIO_CORE_DIR=/opt/platformio
14+
ENV PLATFORMIO_CACHE_DIR=/opt/platformio/.cache
15+
ENV PLATFORMIO_PACKAGES_DIR=/opt/platformio/packages
16+
ENV PLATFORMIO_PLATFORMS_DIR=/opt/platformio/platforms
17+
ENV PLATFORMIO_GLOBALLIB_DIR=/opt/platformio/lib
18+
ENV PLATFORMIO_BUILD_CACHE_DIR=/opt/platformio/.cache/build
19+
20+
# Install essential build tools only
21+
RUN apt-get update && apt-get install -y \
22+
# Build essentials
23+
build-essential \
24+
pkg-config \
25+
cmake \
26+
clang-format \
27+
# Version control and network tools
28+
git \
29+
curl \
30+
wget \
31+
jq \
32+
# Clean up
33+
&& apt-get clean \
34+
&& rm -rf /var/lib/apt/lists/*
35+
36+
# Install PlatformIO and additional Python packages
37+
RUN pip install --no-cache-dir \
38+
platformio \
39+
protobuf \
40+
jinja2
41+
42+
# Install platforms: \
43+
# - espressif32@6.8.0 (6.12 don't work with this image)
44+
# - native@1.2.1 (for unit testing)
45+
RUN pio platform install \
46+
espressif32@${ESP32_PLATFORM_VERSION} \
47+
native@${NATIVE_PLATFORM_VERSION}
48+
49+
# Install Unity test framework globally
50+
RUN pio pkg install -g --library "throwtheswitch/Unity@^${UNITY_VERSION}" \
51+
&& pio pkg list -g | grep Unity
52+
53+
# Copy pre-configured project files
54+
COPY pio_project/ /tmp/pio_project/
55+
56+
# GIT init need for isp-idf.
57+
# Use pio run to download all toolchains and frameworks
58+
# pio run - downloads all toolchains and frameworks
59+
# pio test - download Unity test dependencies
60+
# - VERY LONG step, temporarily disabled
61+
#WORKDIR /tmp/pio_project
62+
#RUN git init \
63+
# && git config user.email "build@local" \
64+
# && git config user.name "Build System" \
65+
# && git add . \
66+
# && git commit -m "Initial commit" --no-gpg-sign --quiet \
67+
# && for e in $PIO_ENVS; do pio run -e "$e"; done \
68+
# && for e in $PIO_ENVS; do pio test -e "$e" --without-uploading --without-testing; done \
69+
# && rm -rf /tmp/pio_project
70+
71+
# Set working directory
72+
WORKDIR /workspace
73+
74+
# Verify installation
75+
RUN pio --version \
76+
&& python --version \
77+
&& gcc --version \
78+
&& pio platform list
79+
80+
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)