-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile.alpine
68 lines (57 loc) · 2.24 KB
/
Dockerfile.alpine
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
# Stage 1: Build image
FROM alpine:latest AS builder
RUN apk update && apk add --no-cache \
git cmake build-base pkgconfig \
ffmpeg-dev sqlite-dev \
curl-dev \
mbedtls2-dev \
bash
# Fetch external dependencies
RUN mkdir -p /opt/external && \
# ezxml
cd /opt/external && \
git clone https://github.com/lxfontes/ezxml.git && \
# inih
cd /opt/external && \
git clone https://github.com/benhoyt/inih.git
# Copy current directory contents into container
WORKDIR /opt
COPY . .
# Clean any existing build files and build the application
RUN mkdir -p /etc/lightnvr /var/lib/lightnvr /var/log/lightnvr /var/run/lightnvr /var/lib/lightnvr/recordings && \
chmod -R 777 /var/lib/lightnvr /var/log/lightnvr /var/run/lightnvr && \
# Clean any existing build files
rm -rf build/ && \
# Build the application
# PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH \
./scripts/build.sh --release --with-sod && \
./scripts/install.sh --prefix=/ --without-systemd --without-ldconfig
# Stage 2: Minimal runtime image
FROM alpine:latest AS final
# Install runtime dependencies
RUN apk update && apk add --no-cache \
ffmpeg-libavformat \
sqlite-libs \
ffmpeg-libavcodec \
ffmpeg-libswscale \
libcurl \
mbedtls2
# Create necessary directories in runtime
RUN mkdir -p /etc/lightnvr /var/lib/lightnvr /var/log/lightnvr /var/run/lightnvr /var/lib/lightnvr/recordings && \
chmod -R 777 /var/lib/lightnvr /var/log/lightnvr /var/run/lightnvr
# Copy compiled binary and config files from builder stage
COPY --from=builder /bin/lightnvr /bin/lightnvr
COPY --from=builder /etc/lightnvr /etc/lightnvr
COPY --from=builder /var/lib/lightnvr /var/lib/lightnvr
COPY --from=builder /var/log/lightnvr /var/log/lightnvr
COPY --from=builder /var/run/lightnvr /var/run/lightnvr
COPY --from=builder /lib/libsod.so.1.1.9 /lib/libsod.so.1.1.9
COPY --from=builder /lib/libsod.so.1.1.9 /lib/libsod.so.1
COPY --from=builder /lib/libsod.so.1 /lib/libsod.so
# Expose required ports
EXPOSE 8080
# Volume for configuration and recordings persistence
VOLUME /etc/lightnvr
VOLUME /var/lib/lightnvr/recordings
# Command to start the service
CMD ["/bin/lightnvr", "-c", "/etc/lightnvr/lightnvr.ini"]