mirror of
https://github.com/MengMengCode/VoCat.git
synced 2026-08-13 03:13:43 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d117749b2 | ||
|
|
3604319faa |
+10
-5
@@ -1,20 +1,25 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
|
||||
# ---- Stage 1: build the web frontend ----
|
||||
FROM node:20-alpine AS web-builder
|
||||
# Build toolchains run natively on the BuildKit host. Without BUILDPLATFORM,
|
||||
# the arm64 branch executes npm and the Go compiler through QEMU, which is much
|
||||
# slower and makes npm ci appear to hang despite producing no progress output.
|
||||
# ---- Stage 1: build the web frontend once on the native builder ----
|
||||
FROM --platform=$BUILDPLATFORM node:20-alpine AS web-builder
|
||||
WORKDIR /web
|
||||
COPY web/package.json web/package-lock.json* ./
|
||||
RUN npm ci
|
||||
COPY web/ ./
|
||||
RUN npm run build
|
||||
|
||||
# ---- Stage 2: build the Go binary ----
|
||||
FROM golang:1.25-alpine AS go-builder
|
||||
# ---- Stage 2: cross-compile the Go binary on the native builder ----
|
||||
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS go-builder
|
||||
RUN apk add --no-cache git
|
||||
WORKDIR /src
|
||||
|
||||
ARG VERSION=0.1.0-dev
|
||||
ARG BUILD_TIME=""
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
@@ -23,7 +28,7 @@ COPY . .
|
||||
# Overlay the freshly built frontend so go:embed web/dist picks it up.
|
||||
COPY --from=web-builder /web/dist ./web/dist
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build \
|
||||
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build \
|
||||
-trimpath \
|
||||
-ldflags "-s -w -X vocat/internal/buildinfo.Version=${VERSION} -X vocat/internal/buildinfo.BuildTime=${BUILD_TIME}" \
|
||||
-o /out/vocat \
|
||||
|
||||
@@ -29,8 +29,9 @@ func TestSessionReceivesAndAcknowledgesSMSOverIMS(t *testing.T) {
|
||||
|
||||
received := make(chan ReceivedSMS, 1)
|
||||
serverDone := make(chan error, 1)
|
||||
readyForClose := make(chan struct{})
|
||||
nonce := base64.StdEncoding.EncodeToString(make([]byte, 32))
|
||||
go func() { serverDone <- serveInboundSMS(listener, nonce) }()
|
||||
go func() { serverDone <- serveInboundSMS(listener, nonce, readyForClose) }()
|
||||
provider, err := NewProvider(
|
||||
smsTestAKA{&recordingAKA{result: vowifi.AKAResult{RES: []byte{1, 2, 3, 4}}}},
|
||||
Config{
|
||||
@@ -65,6 +66,11 @@ func TestSessionReceivesAndAcknowledgesSMSOverIMS(t *testing.T) {
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("timed out waiting for inbound SMS")
|
||||
}
|
||||
select {
|
||||
case <-readyForClose:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("timed out waiting for the inbound RP-ACK exchange")
|
||||
}
|
||||
if err := session.Close(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -102,9 +108,10 @@ func TestSessionSendsSMSOverIMS(t *testing.T) {
|
||||
defer listener.Close()
|
||||
_ = listener.SetDeadline(time.Now().Add(10 * time.Second))
|
||||
serverDone := make(chan error, 1)
|
||||
readyForClose := make(chan struct{})
|
||||
statusReceived := make(chan ReceivedSMSStatus, 1)
|
||||
nonce := base64.StdEncoding.EncodeToString(make([]byte, 32))
|
||||
go func() { serverDone <- serveOutboundSMS(listener, nonce) }()
|
||||
go func() { serverDone <- serveOutboundSMS(listener, nonce, readyForClose) }()
|
||||
provider, err := NewProvider(
|
||||
smsTestAKA{&recordingAKA{result: vowifi.AKAResult{RES: []byte{1, 2, 3, 4}}}},
|
||||
Config{
|
||||
@@ -145,6 +152,11 @@ func TestSessionSendsSMSOverIMS(t *testing.T) {
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("timed out waiting for SMS delivery status")
|
||||
}
|
||||
select {
|
||||
case <-readyForClose:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("timed out waiting for the status-report RP-ACK exchange")
|
||||
}
|
||||
if err := session.Close(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -153,7 +165,7 @@ func TestSessionSendsSMSOverIMS(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func serveInboundSMS(listener *net.UDPConn, nonce string) error {
|
||||
func serveInboundSMS(listener *net.UDPConn, nonce string, readyForClose chan<- struct{}) error {
|
||||
packet := make([]byte, 65535)
|
||||
count, remote, err := listener.ReadFromUDP(packet)
|
||||
if err != nil {
|
||||
@@ -229,6 +241,7 @@ func serveInboundSMS(listener *net.UDPConn, nonce string) error {
|
||||
if _, err = listener.WriteToUDP(testResponse(200, "OK", report.Request.value("Call-ID"), report.Request.value("CSeq"), nil), remote); err != nil {
|
||||
return err
|
||||
}
|
||||
close(readyForClose)
|
||||
|
||||
count, remote, err = listener.ReadFromUDP(packet)
|
||||
if err != nil {
|
||||
@@ -245,7 +258,7 @@ func serveInboundSMS(listener *net.UDPConn, nonce string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func serveOutboundSMS(listener *net.UDPConn, nonce string) error {
|
||||
func serveOutboundSMS(listener *net.UDPConn, nonce string, readyForClose chan<- struct{}) error {
|
||||
packet := make([]byte, 65535)
|
||||
count, remote, err := listener.ReadFromUDP(packet)
|
||||
if err != nil {
|
||||
@@ -355,6 +368,7 @@ func serveOutboundSMS(listener *net.UDPConn, nonce string) error {
|
||||
if _, err = listener.WriteToUDP(testResponse(200, "OK", statusACK.Request.value("Call-ID"), statusACK.Request.value("CSeq"), nil), remote); err != nil {
|
||||
return err
|
||||
}
|
||||
close(readyForClose)
|
||||
|
||||
count, remote, err = listener.ReadFromUDP(packet)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user