From 0f5c6ece93876ff7d81d4facc653a37b63004bfc Mon Sep 17 00:00:00 2001 From: George Hilliard Date: Fri, 3 Jul 2020 00:47:34 -0500 Subject: [PATCH 1/3] Implement Docker image based on Alpine --- .dockerignore | 3 +++ .github/workflows/docker.yaml | 19 ++++++++++++++++ Dockerfile | 42 +++++++++++++++++++++++++++++++++++ docker/entrypoint.sh | 9 ++++++++ 4 files changed, 73 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/docker.yaml create mode 100644 Dockerfile create mode 100755 docker/entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..da6a8f2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +target/ +Dockerfile +.dockerignore diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..a7fac5e --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,19 @@ +# A single-shot build-n-pack on Alpine Linux +name: Publish Docker image +on: [push] + +jobs: + push_to_registry: + name: Build Docker image + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + - name: Push to Docker Hub + uses: docker/build-push-action@v1 + with: + username: thirtythreeforty + password: ${{ secrets.DOCKER_TOKEN }} + registry: docker.io + repository: thirtythreeforty/neolink + tag_with_ref: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b71ba31 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +# Neolink Docker image build scripts +# Copyright (c) 2020 George Hilliard +# SPDX-License-Identifier: AGPL-3.0-only + +FROM docker.io/rust:1-alpine AS build +MAINTAINER thirtythreeforty@gmail.com + +RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \ + gst-rtsp-server-dev +RUN apk add --no-cache musl-dev gcc + +# Use static linking to work around https://github.com/rust-lang/rust/pull/58575 +ENV RUSTFLAGS='-C target-feature=-crt-static' + +# Compile dependencies before main app to save rebuild time +# https://github.com/errmac-v/cargo-build-dependencies +RUN cargo install cargo-build-dependencies +RUN mkdir /usr/local/src \ + && cd /usr/local/src \ + && USER=root cargo new --bin neolink +WORKDIR /usr/local/src/neolink +COPY Cargo.toml Cargo.lock ./ +RUN cargo build-dependencies --release + +# Build the main program +COPY . /usr/local/src/neolink +RUN cargo build --release + +# Create the release container. Match the base OS used to build +FROM docker.io/alpine:latest + +RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing gst-rtsp-server +RUN apk add libgcc + +COPY --from=build \ + /usr/local/src/neolink/target/release/neolink \ + /usr/local/bin/neolink +COPY docker/entrypoint.sh /entrypoint.sh + +CMD ["/usr/local/bin/neolink", "--config", "/etc/neolink.toml"] +ENTRYPOINT ["/entrypoint.sh"] +EXPOSE 8554 diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..d53714f --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Allows Ctrl-C, by letting this sh process act as PID 1 +exit_func() { + exit 1 +} +trap exit_func SIGTERM SIGINT + +"$@" From 8e293a4f1b7531ad62ba9f4d5fed07c7c1058912 Mon Sep 17 00:00:00 2001 From: George Hilliard Date: Fri, 3 Jul 2020 13:55:51 -0500 Subject: [PATCH 2/3] Docker: Remove pre-build of dependencies --- Dockerfile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index b71ba31..8ee830b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,15 +12,7 @@ RUN apk add --no-cache musl-dev gcc # Use static linking to work around https://github.com/rust-lang/rust/pull/58575 ENV RUSTFLAGS='-C target-feature=-crt-static' -# Compile dependencies before main app to save rebuild time -# https://github.com/errmac-v/cargo-build-dependencies -RUN cargo install cargo-build-dependencies -RUN mkdir /usr/local/src \ - && cd /usr/local/src \ - && USER=root cargo new --bin neolink WORKDIR /usr/local/src/neolink -COPY Cargo.toml Cargo.lock ./ -RUN cargo build-dependencies --release # Build the main program COPY . /usr/local/src/neolink From 10f1e584a85c25d8d950b7e544c0d72034014d89 Mon Sep 17 00:00:00 2001 From: George Hilliard Date: Fri, 3 Jul 2020 14:07:20 -0500 Subject: [PATCH 3/3] README: mention Docker --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index d0e858b..049da05 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ Neolink does not support other cameras such as the RLC-420, since they already [ In the future Neolink will be much easier to install. For now, follow these steps. +### Windows/Linux + 1. [Install Gstreamer][gstreamer] from the most recent MSI installer on Windows, or your package manager on Linux. 2. If you are using Windows, add the following to your `PATH` environment variable: @@ -57,6 +59,24 @@ neolink --config my_config.toml [gstreamer]: https://gstreamer.freedesktop.org/documentation/installing/index.html [ci-download]: https://github.com/thirtythreeforty/neolink/actions?query=branch%3Amaster +### Docker + +A Docker image is also available containing Neolink and all its dependencies. +The image is `thirtythreeforty/neolink`. +Port 8554 is exposed, which is the default listen port. +You must mount a configuration file (see below) into the container at `/etc/neolink.toml`. + +Here is a sample launch commmand: + +``` +docker run \ + --restart=on-failure \ + --volume=$PWD/config.toml:/etc/neolink.toml \ + thirtythreeforty/neolink +``` + +The Docker image is "best effort" and intended for advanced users; questions about running Docker are outside the scope of Neolink. + ## Configuration Copy and modify the `sample_config.toml` to specify the address, username, and password for each camera (if there is no password, you can omit that line).