- Created a new README_cross.md file with Docker build instructions. - Updated srs.conf to include logging configuration options. - Added docker-compose.yml to define the SRS SIP service with necessary ports and volume mappings. - Introduced config.yaml for general and GB28181-specific configurations. - Added initial srs.conf with settings for RTMP, HTTP API, and WebRTC support.
97 lines
2.7 KiB
Docker
97 lines
2.7 KiB
Docker
# 引入SRS
|
|
FROM ossrs/srs:v6.0.184 AS srs
|
|
|
|
# 前端构建阶段
|
|
FROM node:20-slim AS frontend-builder
|
|
ARG HTTP_PROXY=
|
|
ARG NO_PROXY=
|
|
ENV http_proxy=${HTTP_PROXY} \
|
|
https_proxy=${HTTP_PROXY} \
|
|
no_proxy=${NO_PROXY}
|
|
WORKDIR /app/frontend
|
|
COPY html/NextGB/package*.json ./
|
|
# RUN npm config set registry http://mirrors.cloud.tencent.com/npm/ \
|
|
# && npm install
|
|
RUN npm install
|
|
COPY html/NextGB/ .
|
|
RUN npm run build
|
|
|
|
# 后端构建阶段
|
|
FROM golang:1.23 AS backend-builder
|
|
ARG HTTP_PROXY=
|
|
ARG NO_PROXY=
|
|
ENV http_proxy=${HTTP_PROXY} \
|
|
https_proxy=${HTTP_PROXY} \
|
|
no_proxy=${NO_PROXY} \
|
|
GOPROXY=https://goproxy.cn,direct
|
|
WORKDIR /app
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
COPY . .
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/srs-sip main/main.go
|
|
|
|
# 最终运行阶段
|
|
FROM ubuntu:22.04
|
|
ARG HTTP_PROXY=
|
|
ARG NO_PROXY=
|
|
ENV http_proxy=${HTTP_PROXY} \
|
|
https_proxy=${HTTP_PROXY} \
|
|
no_proxy=${NO_PROXY}
|
|
WORKDIR /usr/local
|
|
|
|
# 设置时区
|
|
ENV TZ=Asia/Shanghai
|
|
RUN sed -i \
|
|
-e 's@http://archive.ubuntu.com/ubuntu/@http://mirrors.ustc.edu.cn/ubuntu/@g' \
|
|
-e 's@http://security.ubuntu.com/ubuntu/@http://mirrors.ustc.edu.cn/ubuntu/@g' \
|
|
/etc/apt/sources.list && \
|
|
apt-get update && \
|
|
apt-get install -y ca-certificates tzdata supervisor && \
|
|
ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
|
|
dpkg-reconfigure -f noninteractive tzdata && \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# 复制SRS
|
|
COPY --from=srs /usr/local/srs /usr/local/srs
|
|
COPY conf/srs.conf /usr/local/srs/conf/
|
|
|
|
# 复制前端构建产物到html目录
|
|
COPY --from=frontend-builder /app/frontend/dist /usr/local/srs-sip/html
|
|
|
|
# 复制后端构建产物
|
|
COPY --from=backend-builder /app/srs-sip /usr/local/srs-sip/
|
|
COPY conf/config.yaml /usr/local/srs-sip/
|
|
|
|
# 创建supervisor配置
|
|
RUN mkdir -p /etc/supervisor/conf.d
|
|
RUN echo "[supervisord]\n\
|
|
nodaemon=true\n\
|
|
user=root\n\
|
|
logfile=/dev/stdout\n\
|
|
logfile_maxbytes=0\n\
|
|
\n\
|
|
[program:srs]\n\
|
|
command=/usr/local/srs/objs/srs -c /usr/local/srs/conf/srs.conf\n\
|
|
directory=/usr/local/srs\n\
|
|
autostart=true\n\
|
|
autorestart=true\n\
|
|
stdout_logfile=/dev/stdout\n\
|
|
stdout_logfile_maxbytes=0\n\
|
|
stderr_logfile=/dev/stderr\n\
|
|
stderr_logfile_maxbytes=0\n\
|
|
\n\
|
|
[program:srs-sip]\n\
|
|
command=/usr/local/srs-sip/srs-sip -c /usr/local/srs-sip/config.yaml\n\
|
|
directory=/usr/local/srs-sip\n\
|
|
autostart=true\n\
|
|
autorestart=true\n\
|
|
stdout_logfile=/dev/stdout\n\
|
|
stdout_logfile_maxbytes=0\n\
|
|
stderr_logfile=/dev/stderr\n\
|
|
stderr_logfile_maxbytes=0" > /etc/supervisor/conf.d/supervisord.conf
|
|
|
|
EXPOSE 1935 5060 8025 9000 5060/udp 8000/udp
|
|
|
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|