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
46 changes: 41 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,48 @@ 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/}"
tags="${REPO_NAME}:${branch}"
if [ "${branch}" == "master" ]; then
tags="${tags},${REPO_NAME}:latest"
fi
echo "::set-output name=TAGS::${tags}"
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
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm/v7,linux/arm/v6
push: true
file: Dockerfile
tags: ${{ steps.tags.outputs.TAGS }}
build-args: VERSION=${{ steps.toml.outputs.version }}, REPO=${{ github.repository }}, OWNER=${{ github.repository_owner }}
env:
DOCKER_BUILDKIT: 1
64 changes: 48 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,34 @@
# Copyright (c) 2020 George Hilliard
# SPDX-License-Identifier: AGPL-3.0-only

FROM docker.io/rust:1-alpine AS build
MAINTAINER thirtythreeforty@gmail.com
#################################
## SETUP ##
#################################
# This is the generic base for #
# all other dockers to follow #
#################################
FROM docker.io/alpine:edge AS setup
ARG TARGETPLATFORM

RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing libgcc \
libgcc \
tzdata \
gstreamer \
gst-plugins-base \
gst-plugins-good \
gst-plugins-bad \
gst-plugins-ugly \
gst-rtsp-server


#################################
## BUILD ##
#################################
# Install dev packages and #
# with cargo #
#################################
FROM setup AS build
ARG TARGETPLATFORM

# Until Alpine merges gst-rtsp-server into a release, pull all Gstreamer packages
# from the "testing" release
Expand All @@ -12,6 +38,7 @@ 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
RUN apk add --no-cache rust cargo

# Use static linking to work around https://github.com/rust-lang/rust/pull/58575
ENV RUSTFLAGS='-C target-feature=-crt-static'
Expand All @@ -22,26 +49,31 @@ WORKDIR /usr/local/src/neolink
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/main \
-X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
libgcc \
tzdata \
gstreamer \
gst-plugins-base \
gst-plugins-good \
gst-plugins-bad \
gst-plugins-ugly \
gst-rtsp-server
#################################
## PUBLISH ##
#################################
# Copy from build neolink and #
# prepares for execution #
#################################
FROM setup
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"

COPY --from=build \
/usr/local/src/neolink/target/release/neolink \
/usr/local/bin/neolink

COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

CMD ["/usr/local/bin/neolink", "--config", "/etc/neolink.toml"]
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 8554
EXPOSE 8554