Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/armhf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install cross compile tools
run: |
sudo apt-get update
sudo apt-get install --assume-yes --no-install-recommends gcc-arm-linux-gnueabihf
sudo apt-get install --assume-yes --no-install-recommends gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
- name: Install armhf gstreamer
run: |
sudo apt-get update
Expand Down
58 changes: 53 additions & 5 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,60 @@ jobs:
uses: ASzc/change-string-case-action@v1
with:
string: ${{ github.repository }}
- name: Push to Docker Hub
uses: docker/build-push-action@v1
- name: Set up QEMU
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
uses: docker/setup-buildx-action@v1
- name: Login to dockerhub
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
uses: docker/login-action@v1
with:
username: ${{ steps.string_user.outputs.lowercase }}
password: ${{ secrets.DOCKER_TOKEN }}
registry: docker.io
repository: ${{ steps.string_repo.outputs.lowercase }}
tag_with_ref: true
- name: Get tag name
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
id: tags
run: |
branch="${GITHUB_REF#refs/heads/}"
debtags="${REPO_NAME}:${branch}"
alptags="${REPO_NAME}:${branch}-alpine"
if [ "${branch}" == "master" ]; then
debtags="${debtags},${REPO_NAME}:latest"
alptags="${alptags},${REPO_NAME}:latest-alpine"
fi
echo "::set-output name=DEBTAGS::${debtags}"
echo "::set-output name=ALPTAGS::${alptags}"
env:
REPO_NAME: ${{ steps.string_repo.outputs.lowercase }}
- name: Install toml-cli
uses: actions-rs/install@v0.1
with:
crate: toml-cli
version: latest
- name: Get project version
id: toml
run: |
NEOLINK_VERSION="$(toml get Cargo.toml package.version | sed 's|"||g')"
echo "::set-output name=version::${NEOLINK_VERSION}"
- name: Push to Docker Hub Debian
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
uses: docker/build-push-action@v2
with:
platforms: linux/arm/v7,linux/arm/v8,linux/amd64
push: true
file: docker/debian/Dockerfile
tags: ${{ steps.tags.outputs.DEBTAGS }}
build-args: VERSION=${{ steps.toml.outputs.version }}, REPO=${{ github.repository }}, OWNER=${{ github.repository_owner }}
env:
DOCKER_BUILDKIT: 1
- name: Push to Docker Hub Alpine
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
uses: docker/build-push-action@v2
with:
platforms: linux/amd64
push: true
file: docker/alpine/Dockerfile
tags: ${{ steps.tags.outputs.ALPTAGS }}
build-args: VERSION=${{ steps.toml.outputs.version }}, REPO=${{ github.repository }}, OWNER=${{ github.repository_owner }}
21 changes: 18 additions & 3 deletions Dockerfile → docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
# SPDX-License-Identifier: AGPL-3.0-only

FROM docker.io/rust:1-alpine AS build
MAINTAINER thirtythreeforty@gmail.com
ARG REPO
ARG VERSION
ARG OWNER

LABEL description="An image for the neolink program which is a reolink camera to rtsp translator"
LABEL repository="$REPO"
LABEL version="$VERSION"
LABEL maintainer="$OWNER"

RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
gst-rtsp-server-dev
Expand All @@ -20,6 +27,14 @@ RUN cargo build --release

# Create the release container. Match the base OS used to build
FROM docker.io/alpine:latest
ARG REPO
ARG VERSION
ARG OWNER

LABEL description="An image for the neolink program which is a reolink camera to rtsp translator"
LABEL repository="$REPO"
LABEL version="$VERSION"
LABEL maintainer="$OWNER"

RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing libgcc \
tzdata \
Expand All @@ -33,8 +48,8 @@ RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing libg
COPY --from=build \
/usr/local/src/neolink/target/release/neolink \
/usr/local/bin/neolink
COPY docker/entrypoint.sh /entrypoint.sh
COPY docker/alpine/entrypoint.sh /entrypoint.sh

CMD ["/usr/local/bin/neolink", "--config", "/etc/neolink.toml"]
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 8554
EXPOSE 8554
File renamed without changes.
95 changes: 95 additions & 0 deletions docker/debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Neolink Docker image build scripts
# Copyright (c) 2020 George Hilliard
# SPDX-License-Identifier: AGPL-3.0-only
# syntax=docker/dockerfile:experimental

FROM docker.io/debian:buster-slim AS build
ARG TARGETPLATFORM
ARG REPO
ARG VERSION
ARG OWNER

LABEL description="An image for the neolink program which is a reolink camera to rtsp translator"
LABEL repository="$REPO"
LABEL version="$VERSION"
LABEL maintainer="$OWNER"


# ORIGINALLY I TRIED TO BUILD IN A QEMU CONTAINER.
# THIS WOULD HAVE BEEN IDEAL BECAUSE THEN WE COULD BUILD FOR ALL
# ARCH SUPPORTED BY QEMU, DEBIAN AND RUST WITHOUT ANY COMPLICATED CROSS COMPILES.
# HOWEVER I KEPT GETTING THE FOLLOWING ERROR DURING COMPILE
# could not read directory '/usr/local/cargo/registry/index/github.com-1285ae84e5963aae/.git//refs': Value too large for defined data type; class=Os (2)
# Google suggest I should either update the kernel or my fs neither of which I can do on github actions
# SO INSTEAD I CROSS COMPILE USING platform=$BUILDPLATFORM and deploy on platform=$TARGETPLATFORM

WORKDIR /usr/local/src/neolink

# Build the main program
COPY . /usr/local/src/neolink

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

RUN --mount=type=tmpfs,destination=/usr/local/cargo/registry/ \
--mount=type=tmpfs,destination=/usr/local/cargo/git/ \
echo >&2 "\e[0;32mBUILDING FOR: ${TARGETPLATFORM}\e[0m"; \
echo >&2 "\e[0;33mUpdating apt\e[0m"; \
apt-get update && \
echo >&2 "\e[0;33mInstalling packages\e[0m"; \
apt-get install --assume-yes --no-install-recommends \
build-essential \
curl ca-certificates build-essential \
libgstrtspserver-1.0-dev \
libgstreamer1.0-dev \
libgtk2.0-dev && \
/bin/rm -rf /var/cache/apt && \
/bin/rm -rf /var/lib/apt/lists/* && \
update-ca-certificates && \
echo >&2 "\e[0;33mInstalling rust\e[0m"; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustinit.sh && \
sh rustinit.sh --verbose -y && \
echo >&2 "\e[0;33mBuilding neolink\e[0m"; \
echo >&2 "\e[0;34mPATH: ${PATH} \e[0m"; \
echo >&2 "\e[0;35mmount: $(mount | grep tmpfs) \e[0m"; \
echo >&2 "\e[0;36mls: $(ls -lha /usr/local/cargo/bin) \e[0m"; \
cargo build --release --all-features && \
cp "/usr/local/src/neolink/target/release/neolink" /neolink

# Create the release container.
FROM --platform=$TARGETPLATFORM docker.io/debian:buster-slim

ARG TARGETPLATFORM
ARG REPO
ARG VERSION
ARG OWNER

LABEL description="An image for the neolink program which is a reolink camera to rtsp translator"
LABEL repository="$REPO"
LABEL version="$VERSION"
LABEL maintainer="$OWNER"

RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends \
libgstrtspserver-1.0-0 \
libgstreamer1.0-0 \
libgstreamer-plugins-bad1.0-0 \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
libglib2.0-0 && \
/bin/rm -rf /var/cache/apt && \
/bin/rm -rf /var/lib/apt/lists/*

COPY --from=build \
/usr/local/src/neolink/target/release/neolink \
/usr/local/bin/neolink
COPY docker/debian/entrypoint.sh /entrypoint.sh

# Check that we can run the binary
# RUN ldd /usr/local/bin/neolink >&2 && /usr/local/bin/neolink --help >&2

CMD ["/usr/local/bin/neolink", "--config", "/etc/neolink.toml"]
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 8554
9 changes: 9 additions & 0 deletions docker/debian/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 TERM INT

"$@"