Files
dex/Dockerfile.gateway
T
zeekay 77558a0ac2 Add CORS, price data, stats, and history endpoints to dex-gateway
- CORS middleware: Access-Control-Allow-Origin: * on all responses
- Token prices: Real market data for all Lux/Zoo tokens
  (LUX=$2.47, ZOO=$0.85, WETH=$3285, WBTC=$96420, stables=$1)
- GET /v1/stats?chainId= : Aggregate pool TVL/volume/count
- GET /v1/history/prices?symbol=&period= : OHLCV price history
- GET /v1/history/tvl?chainId=&period= : TVL history for charts
- Periods: 1h, 1d, 7d, 30d, 1y with deterministic price simulation
2026-03-02 16:45:00 -08:00

40 lines
858 B
Docker

# Build stage - use BUILDPLATFORM for native compilation, cross-compile via TARGETOS/TARGETARCH
FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS builder
ARG TARGETOS
ARG TARGETARCH
RUN apk add --no-cache git make gcc musl-dev
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o gateway ./cmd/gateway/
# Final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
RUN addgroup -g 1000 -S gateway && \
adduser -u 1000 -S gateway -G gateway
WORKDIR /home/gateway
COPY --from=builder /app/gateway .
RUN chown -R gateway:gateway /home/gateway
USER gateway
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
ENTRYPOINT ["./gateway"]