build: refactor docker to multi-arch buildx and add GitHub Actions workflows#61
Draft
Coooolfan wants to merge 8 commits into
Draft
build: refactor docker to multi-arch buildx and add GitHub Actions workflows#61Coooolfan wants to merge 8 commits into
Coooolfan wants to merge 8 commits into
Conversation
d153f44 to
cdcc2e7
Compare
Add .github/workflows/ci.yml with backend build, backend test, and frontend check jobs; triggers on push to main, pull_request, and workflow_dispatch.
- Remove backend-build: ./gradlew test already compiles, so running buildx in a separate job was duplicate work with no extra signal. - Drop the frontend "Unit tests" step: the repo currently has no spec/test files, and the @vue/cli-plugin-unit-jest preset additionally requires @vue/vue3-jest which is not declared. Re-enable once real tests land.
SLF4J api is declared as compileOnly, so any production class that initializes a logger (e.g. SystemUtils) fails at test time with NoClassDefFoundError: org/slf4j/LoggerFactory, cascading into ExceptionInInitializerError in unrelated FormatTest / StatementTest cases. Add slf4j-api and slf4j-simple as testRuntimeOnly so the logger initializes and tests can also emit logs.
…ions" This reverts commit 23aa79e.
Add a CD workflow that on push to main (and via workflow_dispatch):
- build-tgz job: JDK 21 + Node 22.22.1, runs package.sh --build, uploads
cgdm-{alone,console,sidecar}.tar.gz and the four deployment yml templates as
14-day artifacts.
- docker job: matrix over [alone, console, sidecar], buildx + QEMU on the
amd64 runner to emit linux/amd64 + linux/arm64 manifests in one go, pushes
to ghcr.io/<owner>/<repo>/clouddm-<service> with tags main and main-<short
sha>.
Add a unified, multi-arch Dockerfile per service under .github/docker/ that
replaces the per-arch x86_64/ and arm64/ trees for CI use:
- Base on eclipse-temurin:21-jre-noble (auto multi-arch, no hand-rolled JDK
install).
- alone bundles MySQL 8.0 via apt mysql-server-core-8.0 + mysql-client-core-8.0
instead of the upstream tarball, so $TARGETARCH dispatch and the libncurses
/ libtinfo softlink workarounds are no longer needed.
- shared/ holds per-service properties, init.sh and (sidecar) checker.sh,
copied from the existing x86_64 tree (the x86_64/arm64 contents were
identical bar trailing newlines).
The existing package/docker/{x86_64,arm64}/ trees stay in place for the local
package.sh --docker flow.
mysql-server-core-8.0 ships only the binaries; the mysql user is normally created by the mysql-server-8.0 wrapper package, which we deliberately skip because its postinst tries to start the daemon during docker build. Add an explicit groupadd/useradd before chown so the apt-only install path works.
Apt-installed mysql-server-core-8.0 defaults secure-file-priv to /var/lib/mysql-files; without that directory mysqld exits during boot. Create it alongside /var/lib/mysql and chown to mysql.
…ildx
- merge package/docker/{x86_64,arm64}/* and .github/docker/* into single
package/docker/{alone,console,sidecar}.Dockerfile shared across archs
- drop standalone base image; FROM eclipse-temurin:21-jre-noble directly
- install MySQL via apt (mysql-server-core-8.0) instead of tarball download,
eliminating per-arch download URLs and ncurses/tinfo symlink workarounds
- rewrite build-docker.sh to use buildx: default builds host arch with --load
for quick local iteration; --platform=all|x86_64|arm64 still produces
per-arch tars and compose/k8s yml for offline distribution
- drop obsolete --mirrors flag from package.sh (apt path no longer needs
custom Ubuntu mirrors)
- cd.yml now references package/docker/ as the single source of truth
cdcc2e7 to
c6768c6
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
.github/workflows/ci.yml) and CD (.github/workflows/cd.yml). CD builds multi-arch images (linux/amd64+linux/arm64) and pushes to GHCR on push tomain.package/docker/:x86_64/andarm64/into a single set of multi-arch Dockerfiles (alone.Dockerfile,console.Dockerfile,sidecar.Dockerfile).package/docker/shared/.baseimage; build directlyFROM eclipse-temurin:21-jre-noble.mysql-server-core-8.0) instead of the mysql.com tarball, removing per-arch download URLs andncurses/tinfosymlink patches.build-docker.shto usebuildx. Default builds host arch with--load;--platform=all|x86_64|arm64still emits per-arch tars + compose/k8s yml, preserving the existing publish contract.--mirrorsflag frompackage.sh(no longer needed without the tarball path).Motivation
x86_64/andarm64/were near-identical duplicates (onlyBASE_IMAGE,MYSQL_PLATFORM, and a couple of symlinks differed); every change had to be made twice. There was also no automated image publishing. A single multi-arch Dockerfile with buildx removes the duplication, and apt removes the tarball download + symlink workarounds.Test plan
ghcr.io/coooolfan/open-cdm/clouddm-{alone,console,sidecar}:main(linux/amd64+linux/arm64)cd package && ./package.sh --build --docker x86_64produces per-arch tars —build-docker.sh's output contract is unchanged.docker-publish-{china,global}.shconsumedocker-{svc}-{arch}-{ver}.tarwith{arch}-{ver}tags; this contract is preserved, so they are unaffected.