Skip to content

build(docker): make memory-layer image self-contained#58

Closed
changhoon-sung wants to merge 4 commits intoix-infrastructure:mainfrom
changhoon-sung:docker-self-contained-build
Closed

build(docker): make memory-layer image self-contained#58
changhoon-sung wants to merge 4 commits intoix-infrastructure:mainfrom
changhoon-sung:docker-self-contained-build

Conversation

@changhoon-sung
Copy link
Copy Markdown
Contributor

Summary

The Docker build was not actually building the server. It was packaging a
JAR that had to be assembled somewhere else first and depended on a
locally existing build artifact.

What changed

  • move the memory-layer build into a multi-stage Dockerfile
  • build from the repo root so the image can see the sbt project
  • add a root .dockerignore
  • update the local stack wrappers and release image path to use the same
    server build contract
  • split dependency resolution from source compilation in the Docker
    builder stage so repeated builds can reuse cached dependency layers

Validation

  • docker compose -f docker-compose.yml config
  • docker compose -f docker-compose.yml build memory-layer
  • bash -n stack.sh scripts/backend.sh

The stack was exposed too broadly by default.
Bind published ports to localhost and name shared Docker resources
explicitly to make the backend network and data volume clearer.
There is no good reason for the repo and standalone stacks to disagree
on health checks here.

Keep the checks container-local and use the same health-gated startup
ordering in both compose variants.
Copilot AI review requested due to automatic review settings March 26, 2026 20:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the memory-layer Docker image self-contained by building the Scala server JAR inside a multi-stage Docker build, removing the prior dependency on a locally pre-built artifact and aligning local scripts + release workflows to that contract.

Changes:

  • Move memory-layer JAR assembly into memory-layer/Dockerfile (multi-stage) and build from repo root for sbt project visibility.
  • Update local wrapper scripts and GitHub release workflows to build/push the image using the new root build context contract.
  • Add root .dockerignore and compose adjustments (localhost-only port bindings, internal backend network, mount-root variable).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
memory-layer/Dockerfile Adds multi-stage build that installs sbt and runs memoryLayer/assembly inside the image build.
docker-compose.yml Switches build context to repo root + adds internal network and adjusts ports/volume mount.
docker-compose.standalone.yml Aligns standalone compose runtime wiring (network/ports/depends_on health) and adjusts volume mount.
stack.sh Removes local sbt JAR build step; rebuild now forces a no-cache image rebuild for memory-layer.
scripts/backend.sh Removes local sbt JAR build step; rebuild now forces a no-cache image rebuild for memory-layer.
.github/workflows/release.yml Removes standalone sbt build; builds/pushes Docker image using repo-root context + Dockerfile path.
.github/workflows/release-please.yml Same as above for release-please driven releases.
.dockerignore Adds root ignore rules to keep the new root-context Docker builds slim/cached.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread memory-layer/Dockerfile Outdated
Comment on lines +14 to +16
RUN curl -fsSL "https://github.com/sbt/sbt/releases/download/v${SBT_VERSION}/sbt-${SBT_VERSION}.tgz" \
| tar -xz -C /opt \
&& ln -s /opt/sbt/bin/sbt /usr/local/bin/sbt
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The builder stage downloads and installs sbt via curl from GitHub without verifying integrity (checksum/signature). This is a supply-chain risk for the release image build. Consider pinning the download to a known SHA256 (and verifying it), or switching to a base image / package source that provides sbt with verifiable artifacts.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread scripts/backend.sh
Comment on lines 175 to 179
ensure_docker
build_jar true
echo "Rebuilding and starting backend..."
docker compose up -d --build
docker compose build --no-cache memory-layer
docker compose up -d
wait_for_health
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header usage comment still says rebuild will "Force rebuild JAR + restart", but the command now rebuilds the memory-layer Docker image (and no longer builds the JAR locally). Update the usage comment so it matches the new behavior.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

The Docker build was only packaging a jar built somewhere else.
Have the image build the server itself and stop depending on a local
sbt assembly step for the compose and release server path.
@changhoon-sung changhoon-sung force-pushed the docker-self-contained-build branch from d2233a9 to 10c3381 Compare March 26, 2026 20:57
@TannerTorrey3
Copy link
Copy Markdown
Contributor

memory-layer has been removed from public repo and placed in private repo. The docker compose now pulls straight from the docker image of memory-layer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants