Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Dockerfile build pipeline #2

Merged
merged 7 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Perform a release

on: [workflow_dispatch] # yamllint disable-line rule:truthy
jobs:
build-images:
runs-on: ubuntu-latest
steps:
- id: version
name: Get version string
run: echo "::set-output name=VERSION::v$(date +'+%Y.%m.%d').${{ github.run_number }}"

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.VERSION }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: true
19 changes: 19 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Test image build

on: [push] # yamllint disable-line rule:truthy
jobs:
build-images:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: "Build images"
run: |
docker buildx bake ci
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "infinitude-src"]
path = infinitude-src
url = https://github.com/nebulous/infinitude
36 changes: 18 additions & 18 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Home Assistant",
"type": "shell",
"command": "supervisor_run",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
}
]
}
"version": "2.0.0",
"tasks": [
{
"label": "Start Home Assistant",
"type": "shell",
"command": "supervisor_run",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
}
]
}
8 changes: 8 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
extends: default

rules:
line-length: disable

ignore:
- infinitude-src/
38 changes: 38 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
variable "VERSION" {
}

target "ci" {
pull = true

platforms = ["linux/amd64", "linux/arm64"]

context = "docker"
}

target "infinitude" {
pull = true

platforms = ["linux/amd64", "linux/arm64"]

context = "infinitude-src"

tags = [
"docker.io/sosheskaz/infinitude:${VERSION}",
]

}

target "release" {
pull = true

platforms = ["linux/amd64", "linux/arm64"]

context {
dockerfile = "Dockerfile"
}

tags = [
"docker.io/sosheskaz/ha-infinitude:${VERSION}",
// "docker.io/sosheskaz/ha-infinitude:latest"
]
}
13 changes: 13 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM docker.io/nebulous/infinitude:latest

RUN apt-get update && apt-get install -y \
bash \
jq \
tini \
&& rm -rf /var/lib/apt/lists/*

COPY run.sh /

MAINTAINER "Eric Miller (sosheskaz)"

ENTRYPOINT ["tini", "--", "/run.sh"]
52 changes: 52 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

set -e

CONFIG_PATH=/data/options.json

cfg() {
jq -r --arg key "$1" '.[$key]' < "${CONFIG_PATH}"
}

MODE="$(cfg 'mode')"

if [[ "${MODE}" = "Development" ]]
then
set -x
fi

APP_SECRET="$(cfg 'app_secret')"
PASS_REQS="$(cfg 'pass_reqs')"
SERIAL_TTY="$(cfg 'serial_tty')"
SERIAL_SOCKET="$(cfg 'serial_socket')"

CFG="$(jq -s \
--arg APP_SECRET "${APP_SECRET}" \
--argjson PASS_REQS "${PASS_REQS}" \
'{"app_secret":$APP_SECRET,"pass_reqs":$PASS_REQS}' \
< /dev/null)"

if [[ -n "${SERIAL_TTY}" ]]
then
CFG="$(jq \
--arg SERIAL_TTY "${SERIAL_TTY}" \
'. + {"serial_tty":$SERIAL_TTY}' \
<<< "${CFG}")"
fi

if [[ -n "${SERIAL_SOCKET}" ]]
then
CFG="$(jq \
--arg SERIAL_SOCKET "${SERIAL_SOCKET}" \
'. + {"serial_tty":$SERIAL_SOCKET}' \
<<< "${CFG}")"
fi

echo "${CFG}" > /infinitude/infinitude.json

rm -rf /infinitude/state
mkdir -p /data/infinitude/state
ln -sfT /data/infinitude/state /infinitude/state

cd /infinitude
exec ./infinitude daemon -m "${MODE}" "$@"
1 change: 1 addition & 0 deletions infinitude-src
Submodule infinitude-src added at 690f68
Loading