forked from facebookexperimental/moxygen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
108 lines (93 loc) · 3.34 KB
/
Copy pathDockerfile
File metadata and controls
108 lines (93 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Dockerfile for building the Moq Relay Server
#
# docker build -t moqrelay -f docker/Dockerfile .
#
# To run the container:
#
# Using default values (udp port 4433, logging DBG)
# docker run --rm -p 4433:4433/udp moqrelay
#
# Override logging level
# docker run --rm -p 4433:4433/udp -e MOQ_LOG_LEVEL=INFO moqrelay
#
# Override both port and logging
# docker run --rm -p 8080:8080/udp -e MOQ_PORT=8080 -e MOQ_LOG_LEVEL=INFO moqrelay
#
# Using certs from a specific host directory
# docker run --rm -p 4433:4433/udp \
# -v /path/to/your/certs:/certs \
# moqrelay
#
# Using individual cert files with different names
# docker run --rm -p 4433:4433/udp \
# -v /path/to/custom.pem:/certs/certificate.pem \
# -v /path/to/custom.key:/certs/certificate.key \
# moqrelay
#
# # Using completely custom paths with environment variables
# docker run --rm -p 4433:4433/udp \
# -v /path/to/certs:/custom/certs \
# -e CERT_FILE=/custom/certs/my-cert.pem \
# -e KEY_FILE=/custom/certs/my-key.key \
# moqrelay
#
# Stage 1: Build
FROM ubuntu:latest AS builder
# Install python3 and sudo (getdeps.py install-system-deps requires sudo)
RUN apt-get update && apt-get install -y \
build-essential \
git \
gcc \
g++ \
make \
libssl-dev \
m4 \
doxygen \
python3 \
python3-pip \
sudo
# Allow pip to install packages system-wide (safe in Docker container)
ENV PIP_BREAK_SYSTEM_PACKAGES=1
# Set up working directory
WORKDIR /app
# Copy the rest of the project files
COPY . .
# Run the build script using getdeps.py (already running as root)
# First install system dependencies to reduce compilation
RUN ./build/fbcode_builder/getdeps.py install-system-deps --recursive moxygen
RUN ./build/fbcode_builder/getdeps.py build --allow-system-packages --verbose moxygen 2>&1 || \
(echo "=== Build failed, showing logs ===" && \
find /tmp -name "*.log" -type f -exec echo "=== {} ===" \; -exec cat {} \; 2>/dev/null; \
exit 1)
# Stage the binary and getdeps-built shared libs for the runtime image
RUN INST_DIR=$(./build/fbcode_builder/getdeps.py show-inst-dir moxygen) && \
mkdir -p /staging/bin /staging/lib && \
cp $INST_DIR/bin/moqrelayserver /staging/bin/
# Stage 2: Runtime
FROM ubuntu:latest
RUN apt-get update && apt-get install -y --no-install-recommends \
libsodium23 \
libdouble-conversion3 \
libevent-2.1-7 \
libgflags2.2 \
libssl3 \
libsnappy1v5 \
zlib1g \
ca-certificates \
openssl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /staging/bin/moqrelayserver /usr/local/bin/
COPY --from=builder /staging/lib/ /usr/local/lib/
# Generate default self-signed certs
RUN mkdir -p /certs && \
openssl req -newkey rsa:2048 -nodes -keyout /certs/certificate.key \
-x509 -out /certs/certificate.pem -subj '/CN=Test Certificate' \
-addext "subjectAltName = DNS:localhost"
ENV LD_LIBRARY_PATH=/usr/local/lib
ENV MOQ_LOG_LEVEL=DBG
ENV MOQ_PORT=4433
ENV CERT_FILE=/certs/certificate.pem
ENV KEY_FILE=/certs/certificate.key
ENV MOQ_ENDPOINT=/moq
EXPOSE ${MOQ_PORT}/udp
CMD ["sh", "-c", "moqrelayserver -port ${MOQ_PORT} -cert ${CERT_FILE} -key ${KEY_FILE} -endpoint \"${MOQ_ENDPOINT}\" --logging ${MOQ_LOG_LEVEL}"]