fix(docker): add Aliyun Maven mirror, fix port mapping, remove legacy schema init

- mateclaw-server/settings.xml: Maven mirror routes requests through Aliyun
  so dependency:go-offline no longer hangs in restricted networks
- Dockerfile: COPY settings.xml into /root/.m2/ before any mvn command
- docker-compose.yml: fix port mapping 18080->18088 (app listens on 18088)
- docker-compose.yml: remove legacy schema.sql/data.sql MySQL mounts;
  Flyway manages schema creation from V1 baseline on startup
This commit is contained in:
matevip 2026-04-24 10:26:19 +08:00
parent 27c4c3e5e2
commit c152a8bae9
3 changed files with 37 additions and 6 deletions

View File

@ -21,8 +21,9 @@ services:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
- ./mateclaw-server/src/main/resources/db/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql
- ./mateclaw-server/src/main/resources/db/data.sql:/docker-entrypoint-initdb.d/02-data.sql
# Schema and seed data are managed by Flyway on application startup.
# Do NOT mount legacy schema.sql / data.sql here — Flyway creates all
# tables from V1 baseline and applies incremental migrations automatically.
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
@ -71,7 +72,7 @@ services:
JWT_SECRET: ${JWT_SECRET:-}
MATECLAW_CORS_ALLOWED_ORIGINS: ${MATECLAW_CORS_ALLOWED_ORIGINS:-}
ports:
- "18080:18080"
- "18080:18088" # host:container — app listens on 18088 inside the container
volumes:
- server_data:/app/data

View File

@ -1,16 +1,21 @@
# 多阶段构建
# Multi-stage build
FROM maven:3.9-eclipse-temurin-21 AS builder
# 先构建并安装 plugin-api 到本地 Maven 缓存
# Inject mirror settings to avoid Maven Central timeouts in restricted networks
COPY mateclaw-server/settings.xml /root/.m2/settings.xml
# Build and install plugin-api into the local Maven cache first
WORKDIR /plugin-api
COPY mateclaw-plugin-api/pom.xml ./pom.xml
COPY mateclaw-plugin-api/src ./src
RUN mvn install -DskipTests -q
# 再构建 mateclaw-server
# Pre-fetch mateclaw-server dependencies (uses mirror, so this won't hang)
WORKDIR /build
COPY mateclaw-server/pom.xml .
RUN mvn dependency:go-offline -q
# Build the final JAR
COPY mateclaw-server/src ./src
RUN mvn package -DskipTests -q

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Maven mirror settings for Docker build.
Routes all repository requests through Aliyun Maven mirror to avoid
network timeouts when building inside containers in China.
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>aliyun-public</id>
<mirrorOf>central</mirrorOf>
<name>Aliyun Public Repository</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
<mirror>
<id>aliyun-spring</id>
<mirrorOf>spring-milestones,spring-snapshots</mirrorOf>
<name>Aliyun Spring Repository</name>
<url>https://maven.aliyun.com/repository/spring</url>
</mirror>
</mirrors>
</settings>