Skip to content

Commit cca18a1

Browse files
authored
Merge pull request #145 from rostilos/1.5.1-rc
1.5.1 rc
2 parents 9cbbc52 + 3f6fdb3 commit cca18a1

14 files changed

Lines changed: 126 additions & 162 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# Flow:
77
# 1. Checkout code (with submodules)
8-
# 2. Build Java artifacts (Maven)
8+
# 2. Build & test Java artifacts (Maven + JaCoCo)
99
# 3. Build all 5 Docker images
1010
# 4. Save images as a compressed tarball
1111
# 5. SCP tarball to production server
@@ -42,7 +42,7 @@ env:
4242

4343
jobs:
4444
build:
45-
name: Build Docker Images
45+
name: Build & Test → Docker Images
4646
runs-on: ubuntu-latest
4747
if: github.event.inputs.skip_build != 'true'
4848
timeout-minutes: 30
@@ -73,11 +73,27 @@ jobs:
7373
chmod +x deployment/ci/ci-build.sh
7474
deployment/ci/ci-build.sh
7575
76+
- name: Publish test results
77+
if: always()
78+
uses: dorny/test-reporter@v1
79+
with:
80+
name: Java Tests
81+
path: java-ecosystem/**/target/surefire-reports/*.xml
82+
reporter: java-junit
83+
84+
- name: Upload test reports
85+
if: failure()
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: surefire-reports
89+
path: java-ecosystem/**/target/surefire-reports/
90+
retention-days: 7
91+
7692
- name: Upload artifact
7793
uses: actions/upload-artifact@v4
7894
with:
7995
name: codecrow-images
80-
path: build-output/codecrow-images.tar.gz
96+
path: build-output/codecrow-images.tar.zst
8197
retention-days: 7
8298
compression-level: 0
8399

@@ -120,7 +136,7 @@ jobs:
120136
if: github.event.inputs.skip_build != 'true'
121137
run: |
122138
scp -i ~/.ssh/deploy_key \
123-
build-output/codecrow-images.tar.gz \
139+
build-output/codecrow-images.tar.zst \
124140
${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:${{ env.DEPLOY_PATH }}/releases/
125141
126142
- name: Deploy on server

deployment/build/production-build.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ CONFIG_PATH="deployment/config"
1111

1212
cd "$(dirname "$0")/../../"
1313

14-
# echo "--- 1. Ensuring frontend submodule is synchronized ---"
15-
# if [ -d "$FRONTEND_DIR" ] && [ ! -f "$FRONTEND_DIR/.git" ]; then
16-
# echo "Stale frontend directory detected (not a submodule). Removing and re-initializing..."
17-
# rm -rf "$FRONTEND_DIR"
18-
# git submodule update --init --remote -- "$FRONTEND_DIR"
19-
# elif [ -d "$FRONTEND_DIR" ]; then
20-
# echo "Frontend submodule exists. Updating..."
21-
# git submodule update --remote -- "$FRONTEND_DIR"
22-
# else
23-
# echo "Initializing frontend submodule..."
24-
# git submodule update --init --remote -- "$FRONTEND_DIR"
25-
# fi
26-
# (cd "$FRONTEND_DIR" && git checkout "$FRONTEND_BRANCH" && git pull origin "$FRONTEND_BRANCH")
14+
echo "--- 1. Ensuring frontend submodule is synchronized ---"
15+
if [ -d "$FRONTEND_DIR" ] && [ ! -f "$FRONTEND_DIR/.git" ]; then
16+
echo "Stale frontend directory detected (not a submodule). Removing and re-initializing..."
17+
rm -rf "$FRONTEND_DIR"
18+
git submodule update --init --remote -- "$FRONTEND_DIR"
19+
elif [ -d "$FRONTEND_DIR" ]; then
20+
echo "Frontend submodule exists. Updating..."
21+
git submodule update --remote -- "$FRONTEND_DIR"
22+
else
23+
echo "Initializing frontend submodule..."
24+
git submodule update --init --remote -- "$FRONTEND_DIR"
25+
fi
26+
(cd "$FRONTEND_DIR" && git checkout "$FRONTEND_BRANCH" && git pull origin "$FRONTEND_BRANCH")
2727

2828
echo "--- 2. Injecting Environment Configurations ---"
2929

deployment/ci/ci-build.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
###############################################################################
33
# ci-build.sh — Runs inside the GitHub Actions runner.
44
#
5-
# 1. Builds Java artifacts (Maven)
6-
# 2. Copies MCP JARs to inference-orchestrator context
7-
# 3. Writes .env files from GitHub secrets
5+
# 1. Writes .env files from GitHub secrets
6+
# 2. Builds & tests Java artifacts (Maven) — fails fast on test errors
7+
# 3. Copies MCP JARs to inference-orchestrator context
88
# 4. Builds all 5 Docker images
99
# 5. Saves them to a single compressed tarball
1010
#
@@ -48,10 +48,10 @@ if [ -n "${ENV_WEB_FRONTEND:-}" ]; then
4848
echo " ✓ web-frontend/.env written"
4949
fi
5050

51-
# ── 2. Build Java Artifacts ────────────────────────────────────────────────
52-
echo "--- 2. Building Java artifacts (mvn clean package) ---"
53-
(cd "$JAVA_DIR" && mvn clean package -DskipTests -q)
54-
echo " ✓ Java build complete"
51+
# ── 2. Build & Test Java Artifacts ─────────────────────────────────────────
52+
echo "--- 2. Building & testing Java artifacts (mvn clean verify) ---"
53+
(cd "$JAVA_DIR" && mvn clean verify)
54+
echo " ✓ Java build & tests complete"
5555

5656
# ── 3. Copy MCP JARs ──────────────────────────────────────────────────────
5757
echo "--- 3. Copying MCP server JARs ---"
@@ -96,12 +96,12 @@ for entry in "${IMAGES[@]}"; do
9696
IMAGE_LIST="$IMAGE_LIST ${IMAGE_NAME}:latest"
9797
done
9898

99-
docker save $IMAGE_LIST | gzip > "$OUTPUT_DIR/codecrow-images.tar.gz"
99+
docker save $IMAGE_LIST | zstd -T0 --ultra -20 -o "$OUTPUT_DIR/codecrow-images.tar.zst"
100100

101-
TARBALL_SIZE=$(du -h "$OUTPUT_DIR/codecrow-images.tar.gz" | cut -f1)
102-
echo " ✓ Tarball created: codecrow-images.tar.gz ($TARBALL_SIZE)"
101+
TARBALL_SIZE=$(du -h "$OUTPUT_DIR/codecrow-images.tar.zst" | cut -f1)
102+
echo " ✓ Tarball created: codecrow-images.tar.zst ($TARBALL_SIZE)"
103103

104104
echo ""
105105
echo "=========================================="
106-
echo " Build complete! Artifact: build-output/codecrow-images.tar.gz"
106+
echo " Build complete! Artifact: build-output/codecrow-images.tar.zst"
107107
echo "=========================================="

deployment/ci/server-deploy.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Usage:
1717
# server-deploy.sh [tarball-name]
1818
#
19-
# Default tarball: codecrow-images.tar.gz
19+
# Default tarball: codecrow-images.tar.zst
2020
###############################################################################
2121
set -euo pipefail
2222

@@ -25,7 +25,7 @@ RELEASES_DIR="$DEPLOY_DIR/releases"
2525
CONFIG_DIR="$DEPLOY_DIR/config"
2626
BACKUP_DIR="$DEPLOY_DIR/backups"
2727
COMPOSE_FILE="$DEPLOY_DIR/docker-compose.prod.yml"
28-
TARBALL_NAME="${1:-codecrow-images.tar.gz}"
28+
TARBALL_NAME="${1:-codecrow-images.tar.zst}"
2929
TARBALL_PATH="$RELEASES_DIR/$TARBALL_NAME"
3030

3131
echo "=========================================="
@@ -34,6 +34,11 @@ echo " $(date '+%Y-%m-%d %H:%M:%S')"
3434
echo "=========================================="
3535

3636
# ── Pre-flight checks ─────────────────────────────────────────────────────
37+
if ! command -v zstd &>/dev/null; then
38+
echo "ERROR: zstd is not installed. Run: sudo apt-get install zstd"
39+
exit 1
40+
fi
41+
3742
if [ ! -f "$TARBALL_PATH" ]; then
3843
echo "ERROR: Tarball not found: $TARBALL_PATH"
3944
exit 1
@@ -91,7 +96,7 @@ fi
9196

9297
# ── 2. Load Docker images ─────────────────────────────────────────────────
9398
echo "--- 2. Loading Docker images from tarball ---"
94-
docker load -i "$TARBALL_PATH"
99+
zstd -d --stdout "$TARBALL_PATH" | docker load
95100
echo " ✓ Images loaded"
96101

97102
# ── 3. Stop existing services ─────────────────────────────────────────────
@@ -127,8 +132,8 @@ docker compose -f docker-compose.prod.yml ps
127132
# ── 6. Cleanup old releases (keep last 5) ─────────────────────────────────
128133
echo "--- 6. Cleaning up old releases and backups ---"
129134
cd "$RELEASES_DIR"
130-
ls -1t *.tar.gz 2>/dev/null | tail -n +6 | xargs -r rm -f
131-
REMAINING=$(ls -1 *.tar.gz 2>/dev/null | wc -l)
135+
ls -1t *.tar.zst 2>/dev/null | tail -n +6 | xargs -r rm -f
136+
REMAINING=$(ls -1 *.tar.zst 2>/dev/null | wc -l)
132137
echo " ✓ Keeping $REMAINING release(s)"
133138

134139
# Cleanup old DB backups (keep last 10)

deployment/ci/server-init.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,25 @@ echo "=========================================="
1717
echo " CodeCrow Server Initialization"
1818
echo "=========================================="
1919

20-
# ── 1. Create directory structure ──────────────────────────────────────────
21-
echo "--- 1. Creating directory structure ---"
20+
# ── 1. Install required packages ───────────────────────────────────────────
21+
echo "--- 1. Installing required packages ---"
22+
if ! command -v zstd &>/dev/null; then
23+
apt-get update -qq && apt-get install -y -qq zstd
24+
echo " ✓ zstd installed"
25+
else
26+
echo " ○ zstd already installed"
27+
fi
28+
29+
# ── 2. Create directory structure ──────────────────────────────────────────
30+
echo "--- 2. Creating directory structure ---"
2231
mkdir -p "$DEPLOY_DIR"/{releases,backups,config/{java-shared/github-private-key,inference-orchestrator,rag-pipeline,web-frontend}}
2332

24-
# ── 2. Set ownership ─────────────────────────────────────────────────────
25-
echo "--- 2. Setting ownership to $DEPLOY_USER ---"
33+
# ── 3. Set ownership ─────────────────────────────────────────────────────
34+
echo "--- 3. Setting ownership to $DEPLOY_USER ---"
2635
chown -R "$DEPLOY_USER:$DEPLOY_USER" "$DEPLOY_DIR"
2736

28-
# ── 3. Create sample config files ────────────────────────────────────────
29-
echo "--- 3. Creating sample config placeholders ---"
37+
# ── 4. Create sample config files ────────────────────────────────────────
38+
echo "--- 4. Creating sample config placeholders ---"
3039

3140
if [ ! -f "$DEPLOY_DIR/config/java-shared/application.properties" ]; then
3241
cat > "$DEPLOY_DIR/config/java-shared/application.properties" <<'SAMPLE'
@@ -98,7 +107,7 @@ else
98107
echo " ○ .env already exists (skipped)"
99108
fi
100109

101-
# ── 4. Print summary ─────────────────────────────────────────────────────
110+
# ── 5. Print summary ─────────────────────────────────────────────────────
102111
echo ""
103112
echo "=========================================="
104113
echo " Server initialized! Directory layout:"
@@ -108,7 +117,7 @@ echo " $DEPLOY_DIR/"
108117
echo " ├── docker-compose.prod.yml ← copy from repo"
109118
echo " ├── server-deploy.sh ← copy from repo"
110119
echo " ├── releases/"
111-
echo " │ └── codecrow-images.tar.gz ← uploaded by CI"
120+
echo " │ └── codecrow-images.tar.zst ← uploaded by CI"
112121
echo " └── config/"
113122
echo " ├── java-shared/"
114123
echo " │ ├── application.properties ← YOUR secrets"

deployment/docker-compose.prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ services:
221221
volumes:
222222
- web_frontend_logs:/app/logs
223223
healthcheck:
224-
test: ["CMD-SHELL", "wget -qO /dev/null http://localhost:8080 || exit 1"]
224+
test: ["CMD-SHELL", "wget -qO /dev/null http://127.0.0.1:8080 || exit 1"]
225225
interval: 30s
226226
timeout: 10s
227227
retries: 5

deployment/docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ services:
225225
- codecrow-network
226226
volumes:
227227
- web_frontend_logs:/app/logs
228+
healthcheck:
229+
test: ["CMD-SHELL", "wget -qO /dev/null http://127.0.0.1:8080 || exit 1"]
230+
interval: 30s
231+
timeout: 10s
232+
retries: 5
233+
start_period: 15s
228234
restart: unless-stopped
229235

230236
fix-permissions:
Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,17 @@
1-
FROM maven:latest AS builder
2-
3-
WORKDIR /app
4-
5-
COPY ./target/codecrow-pipeline-agent-1.0.jar ./codecrow-pipeline-agent-1.0.jar
6-
7-
FROM openjdk:17.0.2-jdk-slim-bullseye
1+
FROM eclipse-temurin:17-jre-alpine
82

9-
10-
RUN apt-get update && \
11-
apt-get install -y curl && \
12-
apt-get clean && \
13-
rm -rf /var/lib/apt/lists/*
14-
15-
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
16-
RUN mkdir -p /app/logs && chown -R appuser:appgroup /app
3+
RUN apk add --no-cache curl && \
4+
addgroup -g 1001 -S appgroup && adduser -u 1001 -S appuser -G appgroup && \
5+
mkdir -p /app/logs && chown -R appuser:appgroup /app
176

187
WORKDIR /app
198

20-
# Copy the built jar file
21-
#COPY ./codecrow-pipeline-agent/mcp-server ./codecrow-pipeline-agent/mcp-server
22-
COPY --from=builder /app/codecrow-pipeline-agent-1.0.jar app.jar
23-
24-
# Change ownership
25-
RUN chown -R appuser:appgroup /app
9+
COPY --chown=appuser:appgroup ./target/codecrow-pipeline-agent-1.0.jar app.jar
2610

27-
# Switch to non-root user
2811
USER appuser
2912

30-
# Expose port
3113
EXPOSE 8082
3214

33-
# JVM options
3415
ENV JAVA_OPTS="-Xms512m -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:+UseStringDeduplication"
3516

36-
# Run the application
3717
CMD ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]
Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
FROM maven:latest AS builder
1+
FROM eclipse-temurin:17-jre-alpine
22

3-
WORKDIR /app
4-
5-
COPY ./target/codecrow-pipeline-agent-1.0.jar ./codecrow-pipeline-agent-1.0.jar
6-
7-
FROM openjdk:17.0.2-jdk-slim-bullseye
8-
9-
RUN apt-get update && \
10-
apt-get install -y curl unzip && \
11-
apt-get clean && \
12-
rm -rf /var/lib/apt/lists/*
13-
14-
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
15-
RUN mkdir -p /app/logs && chown -R appuser:appgroup /app
3+
RUN apk add --no-cache curl unzip && \
4+
addgroup -g 1001 -S appgroup && adduser -u 1001 -S appuser -G appgroup && \
5+
mkdir -p /app/logs && chown -R appuser:appgroup /app
166

177
WORKDIR /app
188

19-
# Copy the built jar file
20-
COPY --from=builder /app/codecrow-pipeline-agent-1.0.jar app.jar
9+
# Copy the built jar file (--chown avoids a duplicate layer)
10+
COPY --chown=appuser:appgroup ./target/codecrow-pipeline-agent-1.0.jar app.jar
2111

2212
# Download New Relic Java agent (config newrelic.yml is mounted at runtime)
2313
RUN mkdir -p /usr/local/newrelic && \
@@ -26,23 +16,13 @@ RUN mkdir -p /usr/local/newrelic && \
2616
unzip -jo /tmp/newrelic-java.zip 'newrelic/newrelic.jar' -d /usr/local/newrelic/ && \
2717
rm /tmp/newrelic-java.zip && \
2818
chmod 644 /usr/local/newrelic/newrelic.jar && \
29-
chown -R appuser:appgroup /app /usr/local/newrelic
30-
31-
# Change ownership
32-
RUN chown appuser:appgroup app.jar
19+
chown -R appuser:appgroup /usr/local/newrelic
3320

34-
# Switch to non-root user
3521
USER appuser
3622

37-
# Expose port
3823
EXPOSE 8082
3924

40-
# New Relic config via environment (override at runtime via docker-compose)
41-
# NEW_RELIC_APP_NAME and NEW_RELIC_LICENSE_KEY must be set at runtime
4225
ENV NEW_RELIC_LOG_FILE_NAME=STDOUT
43-
44-
# JVM options
4526
ENV JAVA_OPTS="-Xms512m -Xmx1g -javaagent:/usr/local/newrelic/newrelic.jar -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:+UseStringDeduplication"
4627

47-
# Run the application
4828
CMD ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]

0 commit comments

Comments
 (0)