edit dockerfiles for compatible deploy
This commit is contained in:
parent
eafcb9ea88
commit
028bb6cc0e
@ -1,14 +1,16 @@
|
||||
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library
|
||||
FROM ${BASE_REGISTRY}/golang:1.24-alpine AS builder
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library/
|
||||
FROM ${BASE_REGISTRY}golang:1.24-alpine AS builder
|
||||
ARG GOPROXY=https://goproxy.cn,direct
|
||||
ENV GOPROXY=${GOPROXY}
|
||||
WORKDIR /app
|
||||
COPY shared/ ./shared/
|
||||
COPY auth-service/ ./auth-service/
|
||||
WORKDIR /app/auth-service
|
||||
RUN go build -o /auth-service ./cmd/
|
||||
|
||||
FROM ${BASE_REGISTRY}/alpine:3.20
|
||||
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories
|
||||
FROM ${BASE_REGISTRY}alpine:3.20
|
||||
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
|
||||
COPY --from=builder /auth-service /auth-service
|
||||
EXPOSE 8081
|
||||
|
||||
@ -6,6 +6,10 @@ services:
|
||||
build:
|
||||
context: .
|
||||
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:
|
||||
- "${GATEWAY_PORT:-8080}:8080"
|
||||
environment:
|
||||
@ -33,6 +37,10 @@ services:
|
||||
build:
|
||||
context: .
|
||||
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:
|
||||
- "${AUTH_SERVICE_PORT:-8081}:8081"
|
||||
environment:
|
||||
@ -54,6 +62,10 @@ services:
|
||||
build:
|
||||
context: .
|
||||
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:
|
||||
- "${PURCHASER_SERVICE_PORT:-8082}:8082"
|
||||
environment:
|
||||
@ -74,6 +86,10 @@ services:
|
||||
build:
|
||||
context: .
|
||||
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:
|
||||
- "${TEXTILE_SERVICE_PORT:-8083}:8083"
|
||||
environment:
|
||||
@ -94,6 +110,10 @@ services:
|
||||
build:
|
||||
context: .
|
||||
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:
|
||||
- "${WASHING_SERVICE_PORT:-8084}:8084"
|
||||
environment:
|
||||
@ -112,8 +132,10 @@ services:
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: iloom-flatten/Dockerfile
|
||||
context: ./iloom-flatten
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
|
||||
ports:
|
||||
- "${FRONTEND_PORT:-3015}:3015"
|
||||
depends_on:
|
||||
|
||||
@ -35,6 +35,10 @@ services:
|
||||
build:
|
||||
context: .
|
||||
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:
|
||||
- "${GATEWAY_PORT:-8080}:8080"
|
||||
environment:
|
||||
@ -59,6 +63,10 @@ services:
|
||||
build:
|
||||
context: .
|
||||
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:
|
||||
- "${AUTH_SERVICE_PORT:-8081}:8081"
|
||||
environment:
|
||||
@ -80,6 +88,10 @@ services:
|
||||
build:
|
||||
context: .
|
||||
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:
|
||||
- "${PURCHASER_SERVICE_PORT:-8082}:8082"
|
||||
environment:
|
||||
@ -100,6 +112,10 @@ services:
|
||||
build:
|
||||
context: .
|
||||
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:
|
||||
- "${TEXTILE_SERVICE_PORT:-8083}:8083"
|
||||
environment:
|
||||
@ -120,6 +136,10 @@ services:
|
||||
build:
|
||||
context: .
|
||||
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:
|
||||
- "${WASHING_SERVICE_PORT:-8084}:8084"
|
||||
environment:
|
||||
@ -138,8 +158,10 @@ services:
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: iloom-flatten/Dockerfile
|
||||
context: ./iloom-flatten
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
BASE_REGISTRY: ${BASE_REGISTRY-harbor-in-k3s.cheverjohn.me/library/}
|
||||
ports:
|
||||
- "${FRONTEND_PORT:-3015}:3015"
|
||||
depends_on:
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library
|
||||
FROM ${BASE_REGISTRY}/golang:1.24-alpine AS builder
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library/
|
||||
FROM ${BASE_REGISTRY}golang:1.24-alpine AS builder
|
||||
ARG GOPROXY=https://goproxy.cn,direct
|
||||
ENV GOPROXY=${GOPROXY}
|
||||
WORKDIR /app
|
||||
COPY shared/ ./shared/
|
||||
COPY gateway/ ./gateway/
|
||||
WORKDIR /app/gateway
|
||||
RUN go build -o /gateway ./cmd/
|
||||
|
||||
FROM ${BASE_REGISTRY}/alpine:3.20
|
||||
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories
|
||||
FROM ${BASE_REGISTRY}alpine:3.20
|
||||
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
|
||||
COPY --from=builder /gateway /gateway
|
||||
EXPOSE 8080
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 3093ae18c25f6d654e1c0c3a6cd546c04a5438d1
|
||||
Subproject commit d085054437c10ef8bf09c983d115e97b0946881d
|
||||
@ -1,14 +1,16 @@
|
||||
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library
|
||||
FROM ${BASE_REGISTRY}/golang:1.24-alpine AS builder
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library/
|
||||
FROM ${BASE_REGISTRY}golang:1.24-alpine AS builder
|
||||
ARG GOPROXY=https://goproxy.cn,direct
|
||||
ENV GOPROXY=${GOPROXY}
|
||||
WORKDIR /app
|
||||
COPY shared/ ./shared/
|
||||
COPY purchaser-service/ ./purchaser-service/
|
||||
WORKDIR /app/purchaser-service
|
||||
RUN go build -o /purchaser-service ./cmd/
|
||||
|
||||
FROM ${BASE_REGISTRY}/alpine:3.20
|
||||
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories
|
||||
FROM ${BASE_REGISTRY}alpine:3.20
|
||||
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
|
||||
COPY --from=builder /purchaser-service /purchaser-service
|
||||
EXPOSE 8082
|
||||
|
||||
112
scripts/deploy.sh
Executable file
112
scripts/deploy.sh
Executable 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
|
||||
@ -1,14 +1,16 @@
|
||||
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library
|
||||
FROM ${BASE_REGISTRY}/golang:1.24-alpine AS builder
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library/
|
||||
FROM ${BASE_REGISTRY}golang:1.24-alpine AS builder
|
||||
ARG GOPROXY=https://goproxy.cn,direct
|
||||
ENV GOPROXY=${GOPROXY}
|
||||
WORKDIR /app
|
||||
COPY shared/ ./shared/
|
||||
COPY textile-service/ ./textile-service/
|
||||
WORKDIR /app/textile-service
|
||||
RUN go build -o /textile-service ./cmd/
|
||||
|
||||
FROM ${BASE_REGISTRY}/alpine:3.20
|
||||
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories
|
||||
FROM ${BASE_REGISTRY}alpine:3.20
|
||||
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
|
||||
COPY --from=builder /textile-service /textile-service
|
||||
EXPOSE 8083
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library
|
||||
FROM ${BASE_REGISTRY}/golang:1.24-alpine AS builder
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library/
|
||||
FROM ${BASE_REGISTRY}golang:1.24-alpine AS builder
|
||||
ARG GOPROXY=https://goproxy.cn,direct
|
||||
ENV GOPROXY=${GOPROXY}
|
||||
WORKDIR /app
|
||||
COPY shared/ ./shared/
|
||||
COPY washing-service/ ./washing-service/
|
||||
WORKDIR /app/washing-service
|
||||
RUN go build -o /washing-service ./cmd/
|
||||
|
||||
FROM ${BASE_REGISTRY}/alpine:3.20
|
||||
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories
|
||||
FROM ${BASE_REGISTRY}alpine:3.20
|
||||
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
|
||||
COPY --from=builder /washing-service /washing-service
|
||||
EXPOSE 8084
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user