edit dockerfiles for compatible deploy

This commit is contained in:
kae 2026-07-22 12:35:21 +09:00
parent eafcb9ea88
commit 028bb6cc0e
9 changed files with 196 additions and 30 deletions

View File

@ -1,14 +1,16 @@
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library/
FROM ${BASE_REGISTRY}/golang:1.24-alpine AS builder FROM ${BASE_REGISTRY}golang:1.24-alpine AS builder
ENV GOPROXY=https://goproxy.cn,direct ARG GOPROXY=https://goproxy.cn,direct
ENV GOPROXY=${GOPROXY}
WORKDIR /app WORKDIR /app
COPY shared/ ./shared/ COPY shared/ ./shared/
COPY auth-service/ ./auth-service/ COPY auth-service/ ./auth-service/
WORKDIR /app/auth-service WORKDIR /app/auth-service
RUN go build -o /auth-service ./cmd/ RUN go build -o /auth-service ./cmd/
FROM ${BASE_REGISTRY}/alpine:3.20 FROM ${BASE_REGISTRY}alpine:3.20
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories ARG APK_MIRROR=mirrors.aliyun.com
RUN if [ -n "$APK_MIRROR" ]; then sed -i "s|dl-cdn.alpinelinux.org|$APK_MIRROR|g" /etc/apk/repositories; fi
RUN apk add --no-cache wget RUN apk add --no-cache wget
COPY --from=builder /auth-service /auth-service COPY --from=builder /auth-service /auth-service
EXPOSE 8081 EXPOSE 8081

View File

@ -6,6 +6,10 @@ services:
build: build:
context: . context: .
dockerfile: gateway/Dockerfile dockerfile: gateway/Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
GOPROXY: ${GOPROXY-https://goproxy.cn,direct}
APK_MIRROR: ${APK_MIRROR-mirrors.aliyun.com}
ports: ports:
- "${GATEWAY_PORT:-8080}:8080" - "${GATEWAY_PORT:-8080}:8080"
environment: environment:
@ -33,6 +37,10 @@ services:
build: build:
context: . context: .
dockerfile: auth-service/Dockerfile dockerfile: auth-service/Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
GOPROXY: ${GOPROXY-https://goproxy.cn,direct}
APK_MIRROR: ${APK_MIRROR-mirrors.aliyun.com}
ports: ports:
- "${AUTH_SERVICE_PORT:-8081}:8081" - "${AUTH_SERVICE_PORT:-8081}:8081"
environment: environment:
@ -54,6 +62,10 @@ services:
build: build:
context: . context: .
dockerfile: purchaser-service/Dockerfile dockerfile: purchaser-service/Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
GOPROXY: ${GOPROXY-https://goproxy.cn,direct}
APK_MIRROR: ${APK_MIRROR-mirrors.aliyun.com}
ports: ports:
- "${PURCHASER_SERVICE_PORT:-8082}:8082" - "${PURCHASER_SERVICE_PORT:-8082}:8082"
environment: environment:
@ -74,6 +86,10 @@ services:
build: build:
context: . context: .
dockerfile: textile-service/Dockerfile dockerfile: textile-service/Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
GOPROXY: ${GOPROXY-https://goproxy.cn,direct}
APK_MIRROR: ${APK_MIRROR-mirrors.aliyun.com}
ports: ports:
- "${TEXTILE_SERVICE_PORT:-8083}:8083" - "${TEXTILE_SERVICE_PORT:-8083}:8083"
environment: environment:
@ -94,6 +110,10 @@ services:
build: build:
context: . context: .
dockerfile: washing-service/Dockerfile dockerfile: washing-service/Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
GOPROXY: ${GOPROXY-https://goproxy.cn,direct}
APK_MIRROR: ${APK_MIRROR-mirrors.aliyun.com}
ports: ports:
- "${WASHING_SERVICE_PORT:-8084}:8084" - "${WASHING_SERVICE_PORT:-8084}:8084"
environment: environment:
@ -112,8 +132,10 @@ services:
frontend: frontend:
build: build:
context: . context: ./iloom-flatten
dockerfile: iloom-flatten/Dockerfile dockerfile: Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
ports: ports:
- "${FRONTEND_PORT:-3015}:3015" - "${FRONTEND_PORT:-3015}:3015"
depends_on: depends_on:

View File

@ -35,6 +35,10 @@ services:
build: build:
context: . context: .
dockerfile: gateway/Dockerfile dockerfile: gateway/Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
GOPROXY: ${GOPROXY-https://goproxy.cn,direct}
APK_MIRROR: ${APK_MIRROR-mirrors.aliyun.com}
ports: ports:
- "${GATEWAY_PORT:-8080}:8080" - "${GATEWAY_PORT:-8080}:8080"
environment: environment:
@ -59,6 +63,10 @@ services:
build: build:
context: . context: .
dockerfile: auth-service/Dockerfile dockerfile: auth-service/Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
GOPROXY: ${GOPROXY-https://goproxy.cn,direct}
APK_MIRROR: ${APK_MIRROR-mirrors.aliyun.com}
ports: ports:
- "${AUTH_SERVICE_PORT:-8081}:8081" - "${AUTH_SERVICE_PORT:-8081}:8081"
environment: environment:
@ -80,6 +88,10 @@ services:
build: build:
context: . context: .
dockerfile: purchaser-service/Dockerfile dockerfile: purchaser-service/Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
GOPROXY: ${GOPROXY-https://goproxy.cn,direct}
APK_MIRROR: ${APK_MIRROR-mirrors.aliyun.com}
ports: ports:
- "${PURCHASER_SERVICE_PORT:-8082}:8082" - "${PURCHASER_SERVICE_PORT:-8082}:8082"
environment: environment:
@ -100,6 +112,10 @@ services:
build: build:
context: . context: .
dockerfile: textile-service/Dockerfile dockerfile: textile-service/Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
GOPROXY: ${GOPROXY-https://goproxy.cn,direct}
APK_MIRROR: ${APK_MIRROR-mirrors.aliyun.com}
ports: ports:
- "${TEXTILE_SERVICE_PORT:-8083}:8083" - "${TEXTILE_SERVICE_PORT:-8083}:8083"
environment: environment:
@ -120,6 +136,10 @@ services:
build: build:
context: . context: .
dockerfile: washing-service/Dockerfile dockerfile: washing-service/Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
GOPROXY: ${GOPROXY-https://goproxy.cn,direct}
APK_MIRROR: ${APK_MIRROR-mirrors.aliyun.com}
ports: ports:
- "${WASHING_SERVICE_PORT:-8084}:8084" - "${WASHING_SERVICE_PORT:-8084}:8084"
environment: environment:
@ -138,8 +158,10 @@ services:
frontend: frontend:
build: build:
context: . context: ./iloom-flatten
dockerfile: iloom-flatten/Dockerfile dockerfile: Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
ports: ports:
- "${FRONTEND_PORT:-3015}:3015" - "${FRONTEND_PORT:-3015}:3015"
depends_on: depends_on:

View File

@ -1,14 +1,16 @@
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library/
FROM ${BASE_REGISTRY}/golang:1.24-alpine AS builder FROM ${BASE_REGISTRY}golang:1.24-alpine AS builder
ENV GOPROXY=https://goproxy.cn,direct ARG GOPROXY=https://goproxy.cn,direct
ENV GOPROXY=${GOPROXY}
WORKDIR /app WORKDIR /app
COPY shared/ ./shared/ COPY shared/ ./shared/
COPY gateway/ ./gateway/ COPY gateway/ ./gateway/
WORKDIR /app/gateway WORKDIR /app/gateway
RUN go build -o /gateway ./cmd/ RUN go build -o /gateway ./cmd/
FROM ${BASE_REGISTRY}/alpine:3.20 FROM ${BASE_REGISTRY}alpine:3.20
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories ARG APK_MIRROR=mirrors.aliyun.com
RUN if [ -n "$APK_MIRROR" ]; then sed -i "s|dl-cdn.alpinelinux.org|$APK_MIRROR|g" /etc/apk/repositories; fi
RUN apk add --no-cache wget RUN apk add --no-cache wget
COPY --from=builder /gateway /gateway COPY --from=builder /gateway /gateway
EXPOSE 8080 EXPOSE 8080

@ -1 +1 @@
Subproject commit 3093ae18c25f6d654e1c0c3a6cd546c04a5438d1 Subproject commit d085054437c10ef8bf09c983d115e97b0946881d

View File

@ -1,14 +1,16 @@
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library/
FROM ${BASE_REGISTRY}/golang:1.24-alpine AS builder FROM ${BASE_REGISTRY}golang:1.24-alpine AS builder
ENV GOPROXY=https://goproxy.cn,direct ARG GOPROXY=https://goproxy.cn,direct
ENV GOPROXY=${GOPROXY}
WORKDIR /app WORKDIR /app
COPY shared/ ./shared/ COPY shared/ ./shared/
COPY purchaser-service/ ./purchaser-service/ COPY purchaser-service/ ./purchaser-service/
WORKDIR /app/purchaser-service WORKDIR /app/purchaser-service
RUN go build -o /purchaser-service ./cmd/ RUN go build -o /purchaser-service ./cmd/
FROM ${BASE_REGISTRY}/alpine:3.20 FROM ${BASE_REGISTRY}alpine:3.20
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories ARG APK_MIRROR=mirrors.aliyun.com
RUN if [ -n "$APK_MIRROR" ]; then sed -i "s|dl-cdn.alpinelinux.org|$APK_MIRROR|g" /etc/apk/repositories; fi
RUN apk add --no-cache wget RUN apk add --no-cache wget
COPY --from=builder /purchaser-service /purchaser-service COPY --from=builder /purchaser-service /purchaser-service
EXPOSE 8082 EXPOSE 8082

112
scripts/deploy.sh Executable file
View File

@ -0,0 +1,112 @@
#!/usr/bin/env bash
# Deploy iloom (backend services + frontend) in integrated mode against a running muyu-apiserver stack.
#
# Prerequisites:
# - muyu-apiserver already running (cd ../muyu-apiserver/deploy && docker compose up -d)
# - .env present in repo root (copy from .env.example and fill in secrets)
#
# Usage: ./scripts/deploy.sh [--no-mirror]
# --no-mirror Build images against upstream registries (Docker Hub, proxy.golang.org,
# official Alpine CDN) instead of the Harbor/Aliyun/goproxy.cn mirrors that
# the Dockerfiles use by default.
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
MUYU_NETWORK="deploy_default"
MUYU_MYSQL_CONTAINER="muyu-mysql"
SERVICES=(gateway auth-service purchaser-service textile-service washing-service frontend)
COMPOSE_FILE="docker-compose.integrated.yml"
NO_MIRROR=false
for arg in "$@"; do
case "$arg" in
--no-mirror) NO_MIRROR=true ;;
*) ;;
esac
done
log() { printf '\n==> %s\n' "$1"; }
die() { printf '\nERROR: %s\n' "$1" >&2; exit 1; }
[ -f .env ] || die ".env not found in $ROOT_DIR. Copy .env.example to .env and fill in real values first."
while IFS='=' read -r key value; do
[[ -z "$key" || "$key" == \#* ]] && continue
export "$key=$value"
done < <(grep -v '^\s*#' .env | grep '=')
[ -n "${DB_DSN:-}" ] || die "DB_DSN is not set in .env"
[ -n "${JWT_SECRET:-}" ] || die "JWT_SECRET is not set in .env"
[ -n "${JWT_REFRESH_SECRET:-}" ] || die "JWT_REFRESH_SECRET is not set in .env"
[ -n "${INTERNAL_SERVICE_KEY:-}" ] || die "INTERNAL_SERVICE_KEY is not set in .env"
if [ "$NO_MIRROR" = true ]; then
log "Disabling build mirrors (--no-mirror): using upstream registries"
export BASE_REGISTRY=""
export GOPROXY="https://proxy.golang.org,direct"
export APK_MIRROR=""
fi
log "Checking muyu-apiserver dependencies"
docker network inspect "$MUYU_NETWORK" >/dev/null 2>&1 || \
die "Docker network '$MUYU_NETWORK' not found. Start muyu-apiserver first: cd ../muyu-apiserver/deploy && docker compose up -d"
docker inspect -f '{{.State.Running}}' "$MUYU_MYSQL_CONTAINER" 2>/dev/null | grep -q true || \
die "Container '$MUYU_MYSQL_CONTAINER' is not running. Start muyu-apiserver first."
for c in muyu-system-rpc muyu-inventory-rpc; do
docker inspect -f '{{.State.Running}}' "$c" >/dev/null 2>&1 || die "Container '$c' is not running."
done
echo "muyu-apiserver stack is up (network '$MUYU_NETWORK' found, mysql/system-rpc/inventory-rpc running)."
log "Applying iloom schema to shared muyu_wms database (idempotent)"
docker exec -i "$MUYU_MYSQL_CONTAINER" mysql -uroot -p"${MYSQL_ROOT_PASSWORD:?Set MYSQL_ROOT_PASSWORD in .env}" < scripts/init-iloom.sql
echo "iloom tables (ilm_*) ensured in muyu_wms."
log "Building and starting iloom services: ${SERVICES[*]}"
docker compose -f "$COMPOSE_FILE" up -d --build "${SERVICES[@]}"
log "Waiting for services to become healthy"
port_for() {
case "$1" in
gateway) echo "${GATEWAY_PORT:-8080}" ;;
auth-service) echo "${AUTH_SERVICE_PORT:-8081}" ;;
purchaser-service) echo "${PURCHASER_SERVICE_PORT:-8082}" ;;
textile-service) echo "${TEXTILE_SERVICE_PORT:-8083}" ;;
washing-service) echo "${WASHING_SERVICE_PORT:-8084}" ;;
frontend) echo "${FRONTEND_PORT:-3015}" ;;
esac
}
path_for() {
case "$1" in
frontend) echo "/" ;;
*) echo "/health" ;;
esac
}
all_ok=true
for svc in "${SERVICES[@]}"; do
port="$(port_for "$svc")"
path="$(path_for "$svc")"
ok=false
for _ in $(seq 1 30); do
if curl -fsS -o /dev/null "http://localhost:${port}${path}" 2>/dev/null; then
ok=true
break
fi
sleep 2
done
if [ "$ok" = true ]; then
echo " [OK] $svc (http://localhost:${port}${path})"
else
echo " [FAIL] $svc (http://localhost:${port}${path}) did not become healthy in time"
all_ok=false
fi
done
if [ "$all_ok" = true ]; then
log "Deploy complete. All services healthy."
else
log "Deploy finished with failures. Check logs: docker compose -f $COMPOSE_FILE logs -f <service>"
exit 1
fi

View File

@ -1,14 +1,16 @@
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library/
FROM ${BASE_REGISTRY}/golang:1.24-alpine AS builder FROM ${BASE_REGISTRY}golang:1.24-alpine AS builder
ENV GOPROXY=https://goproxy.cn,direct ARG GOPROXY=https://goproxy.cn,direct
ENV GOPROXY=${GOPROXY}
WORKDIR /app WORKDIR /app
COPY shared/ ./shared/ COPY shared/ ./shared/
COPY textile-service/ ./textile-service/ COPY textile-service/ ./textile-service/
WORKDIR /app/textile-service WORKDIR /app/textile-service
RUN go build -o /textile-service ./cmd/ RUN go build -o /textile-service ./cmd/
FROM ${BASE_REGISTRY}/alpine:3.20 FROM ${BASE_REGISTRY}alpine:3.20
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories ARG APK_MIRROR=mirrors.aliyun.com
RUN if [ -n "$APK_MIRROR" ]; then sed -i "s|dl-cdn.alpinelinux.org|$APK_MIRROR|g" /etc/apk/repositories; fi
RUN apk add --no-cache wget RUN apk add --no-cache wget
COPY --from=builder /textile-service /textile-service COPY --from=builder /textile-service /textile-service
EXPOSE 8083 EXPOSE 8083

View File

@ -1,14 +1,16 @@
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library/
FROM ${BASE_REGISTRY}/golang:1.24-alpine AS builder FROM ${BASE_REGISTRY}golang:1.24-alpine AS builder
ENV GOPROXY=https://goproxy.cn,direct ARG GOPROXY=https://goproxy.cn,direct
ENV GOPROXY=${GOPROXY}
WORKDIR /app WORKDIR /app
COPY shared/ ./shared/ COPY shared/ ./shared/
COPY washing-service/ ./washing-service/ COPY washing-service/ ./washing-service/
WORKDIR /app/washing-service WORKDIR /app/washing-service
RUN go build -o /washing-service ./cmd/ RUN go build -o /washing-service ./cmd/
FROM ${BASE_REGISTRY}/alpine:3.20 FROM ${BASE_REGISTRY}alpine:3.20
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories ARG APK_MIRROR=mirrors.aliyun.com
RUN if [ -n "$APK_MIRROR" ]; then sed -i "s|dl-cdn.alpinelinux.org|$APK_MIRROR|g" /etc/apk/repositories; fi
RUN apk add --no-cache wget RUN apk add --no-cache wget
COPY --from=builder /washing-service /washing-service COPY --from=builder /washing-service /washing-service
EXPOSE 8084 EXPOSE 8084