-
Notifications
You must be signed in to change notification settings - Fork 76
RTOP-283: update the runtime from the editor, over Docker #190
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
Merged
Merged
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
d158cd6
feat(api): advertise who may change the runtime version
thiagoralves f4a3803
merge(RTOP-283): phase 1 - update policy advertisement
thiagoralves b602a0b
feat(sidecar): bootloader that supervises the runtime container
thiagoralves d5853fa
merge(RTOP-283): phase 2 - sidecar bootloader and supervisor
thiagoralves cd72d0b
feat(sidecar): authenticate against the runtime's own credentials
thiagoralves fb6f370
refactor: rename the sidecar to bootloader
thiagoralves aef0e66
feat(bootloader): control API on 8445
thiagoralves 3cddc31
merge(RTOP-283): phases 3-4 - bootloader auth, rename, and control API
thiagoralves 9b93cb9
feat(bootloader): version change executor, and a runtime HEALTHCHECK
thiagoralves d18ee93
fix(bootloader): point the runtime at the mounted data directory
thiagoralves 367c1e7
feat(bootloader): answer LAN discovery while in recovery
thiagoralves f466d01
feat(install): Docker install by default, and let the bootloader fetc…
thiagoralves 3b2f834
fix(bootloader): recreate the runtime when the spec asks for another …
thiagoralves 0cf194c
test(integration): make three assertions real, and the suite green
thiagoralves 2296dc6
merge(RTOP-283): update executor, discovery, installer and integratio…
thiagoralves 1105216
merge(RTOP-283): integration harness fixes
thiagoralves e004b26
feat(bootloader): replace itself with a newer version
thiagoralves 97f0b59
merge(RTOP-283): phase 7 - bootloader self-update
thiagoralves 0f49b39
fix(bootloader): a refused update must not disturb a running PLC
thiagoralves bbf57c6
test(integration): assert a failed pull leaves the PLC running
thiagoralves bffca06
merge(RTOP-283): phase 8 - fixes found on hardware
thiagoralves 799e6b6
fix(bootloader): let a container stop outlive the client timeout
thiagoralves 7a0a5b5
fix(bootloader): say why a pull failed, not just that it did
thiagoralves 88aa212
feat(bootloader): serve device information, and drop the runtime's copy
thiagoralves 1508a32
feat(install): a one-line container install, and a way back out
thiagoralves 4703e15
ci(bootloader): do not republish a bootloader version that already ex…
thiagoralves a2018e9
ci(windows): ask install.sh for the native build explicitly
thiagoralves ae34aca
fix(bootloader): address the review on RTOP-283
thiagoralves 0417dec
ci: install every plugin's test dependencies, and scope the pytest gate
thiagoralves File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| # Bootloader image: a single static binary on scratch. | ||
| # | ||
| # Cross-compiled rather than emulated. Go targets every architecture we ship | ||
| # from one native builder, so buildx needs no QEMU here -- BUILDPLATFORM pins | ||
| # the build stage to the host and TARGETOS/TARGETARCH pick the output. That is | ||
| # the difference between seconds and the many minutes the runtime image spends | ||
| # under emulation. | ||
| # | ||
| # scratch, not alpine: this is the component that has to work when the runtime | ||
| # will not start, and every byte in the image is a byte that could stop it | ||
| # starting. There is no shell to debug with, which is the intended trade -- the | ||
| # bootloader's job is to report over HTTP, not to be poked at over exec. | ||
| FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS build | ||
|
|
||
| ARG TARGETOS | ||
| ARG TARGETARCH | ||
| # Bootloader version, independent of the runtime's. It changes rarely, so tying it | ||
| # to every runtime release would produce a long run of identical images. | ||
| ARG BOOTLOADER_VERSION=dev | ||
|
|
||
| WORKDIR /src | ||
|
|
||
| # go.mod first so the dependency layer survives source-only changes. There are | ||
| # no third-party dependencies today, which keeps this honest rather than | ||
|
thiagoralves marked this conversation as resolved.
Outdated
|
||
| # theatrical: `go mod download` is a no-op and the layer is a cache anchor. | ||
| COPY go.mod ./ | ||
| RUN go mod download | ||
|
|
||
| COPY . . | ||
|
|
||
| # CGO off so the result is genuinely static and runs on scratch. | ||
| # -trimpath and -s -w keep the binary small and reproducible. | ||
| RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ | ||
| go build \ | ||
| -trimpath \ | ||
| -ldflags="-s -w -X main.version=${BOOTLOADER_VERSION}" \ | ||
| -o /out/openplc-bootloader . | ||
|
|
||
| # Fail the build rather than ship an untested bootloader. Tests run on the build | ||
| # platform, which is where they are meaningful -- the logic under test is a | ||
| # state machine, not anything architecture-specific. | ||
| RUN CGO_ENABLED=0 go test ./... | ||
|
|
||
| FROM scratch | ||
|
|
||
| ARG BOOTLOADER_VERSION=dev | ||
| LABEL org.opencontainers.image.title="OpenPLC Runtime Bootloader" \ | ||
| org.opencontainers.image.description="Bootloader and update manager for a local OpenPLC runtime" \ | ||
| org.opencontainers.image.source="https://github.com/Autonomy-Logic/openplc-runtime" \ | ||
| org.opencontainers.image.version="${BOOTLOADER_VERSION}" | ||
|
|
||
| # CA roots for any future outbound HTTPS. Nothing needs them today -- image | ||
| # pulls go through the Docker daemon, which has its own -- but a missing root | ||
| # store fails in a way that is genuinely hard to diagnose from a scratch image. | ||
| COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
|
|
||
| COPY --from=build /out/openplc-bootloader /openplc-bootloader | ||
|
|
||
| # Control API. 8445 keeps to the odd numbers alongside the runtime's 8443. | ||
| EXPOSE 8445 | ||
|
|
||
| ENTRYPOINT ["/openplc-bootloader"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| bootloader-v1.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // The bootloader keeps its dependencies to the minimum the job actually needs. | ||
| // It is the component that recovers a device when the runtime will not start, | ||
| // so every dependency is a way for that recovery to fail: the Docker Engine | ||
| // API is plain HTTP over a unix socket, JWT is an HMAC over two base64 | ||
| // segments, and PBKDF2 is twenty lines of RFC 8018 -- all of which net/http | ||
| // and crypto/* already cover -- PBKDF2 is crypto/pbkdf2 as of Go 1.24. | ||
| // | ||
| // The one exception is modernc.org/sqlite. Authenticating a caller while the | ||
| // runtime is DOWN means reading the runtime's own users table, and cold | ||
| // recovery after a reboot is exactly when there is no runtime to ask. A | ||
| // second credential store in the bootloader would have avoided the dependency at | ||
| // the cost of another thing that can be forgotten when an account is revoked, | ||
| // which is the worse trade. Pure Go, so it still cross-compiles with CGO off | ||
| // and still runs on scratch. | ||
| module github.com/Autonomy-Logic/openplc-runtime/bootloader | ||
|
|
||
| go 1.25.0 | ||
|
|
||
| require modernc.org/sqlite v1.58.0 | ||
|
|
||
| require ( | ||
| github.com/dustin/go-humanize v1.0.1 // indirect | ||
| github.com/google/uuid v1.6.0 // indirect | ||
| github.com/mattn/go-isatty v0.0.24 // indirect | ||
| github.com/ncruces/go-strftime v1.0.0 // indirect | ||
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect | ||
| golang.org/x/sys v0.47.0 // indirect | ||
| modernc.org/libc v1.75.6 // indirect | ||
| modernc.org/mathutil v1.7.1 // indirect | ||
| modernc.org/memory v1.12.1 // indirect | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= | ||
| github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= | ||
| github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 h1:LMLX+LgTNWpfvCBdFebv6EsYotImrt/Ppc5cXIriCSo= | ||
| github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk= | ||
| github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= | ||
| github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||
| github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= | ||
| github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= | ||
| github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI= | ||
| github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A= | ||
| github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= | ||
| github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= | ||
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= | ||
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= | ||
| golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk= | ||
| golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40= | ||
| golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= | ||
| golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= | ||
| golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= | ||
| golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= | ||
| golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE= | ||
| golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk= | ||
| modernc.org/cc/v4 v4.29.2 h1:h6+9ciCnPKutf4I03CvheAvDLX7+IHlqR6Iy6J+cgd8= | ||
| modernc.org/cc/v4 v4.29.2/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI= | ||
| modernc.org/ccgo/v4 v4.35.0 h1:F+TUsmw09QxLzmi3aeYYGxjAXarmZaKgj3mKQHNaA8w= | ||
| modernc.org/ccgo/v4 v4.35.0/go.mod h1:qrVGs9S3Sr2Ztcg9ve+kTAYMp5a3YvWjo+SoN06kJ5I= | ||
| modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM= | ||
| modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU= | ||
| modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= | ||
| modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= | ||
| modernc.org/gc/v3 v3.1.5 h1:21ldfPfRYE31Tb7B3mwAK8gy1AxP4+dKjrOQPfqakoc= | ||
| modernc.org/gc/v3 v3.1.5/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY= | ||
| modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= | ||
| modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI= | ||
| modernc.org/libc v1.75.6 h1:yKk8qo+Di4gkmvRboK8ocCqH22FiUCR6jRy2OwtCRus= | ||
| modernc.org/libc v1.75.6/go.mod h1:bO5o2ztHxBb2rjz0PgdHN0sSMw57CgxGFLZ3Qd/QpVQ= | ||
| modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= | ||
| modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= | ||
| modernc.org/memory v1.12.1 h1:nFMiWrpStgZczNl6XI9GnIk/rWhYIyHGUaR04pGbp9g= | ||
| modernc.org/memory v1.12.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= | ||
| modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg= | ||
| modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= | ||
| modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= | ||
| modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= | ||
| modernc.org/sqlite v1.58.0 h1:38u40/bwkfM7f0Myhosl+SEMltSDxnGdQf8o6Kjmys0= | ||
| modernc.org/sqlite v1.58.0/go.mod h1:rsD2CckafgObKC4DhBlGBf+RiHxkc3hINGt1Xw32tVY= | ||
| modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= | ||
| modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= | ||
| modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= | ||
| modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.