mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-04 16:02:43 +08:00
Refactoring CI
This commit is contained in:
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@@ -7,9 +7,6 @@ on:
|
|||||||
- 'master'
|
- 'master'
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
|
50
Dockerfile
50
Dockerfile
@@ -1,57 +1,55 @@
|
|||||||
# https://hub.docker.com/_/python/tags?page=1&name=-alpine
|
# 0. Prepare images
|
||||||
ARG PYTHON_VERSION="3.10.8"
|
ARG PYTHON_VERSION="3.11"
|
||||||
# https://hub.docker.com/_/golang/tags?page=1&name=-alpine
|
ARG GO_VERSION="1.19"
|
||||||
ARG GO_VERSION="1.19.3"
|
ARG NGROK_VERSION="3"
|
||||||
# https://hub.docker.com/r/ngrok/ngrok/tags?page=1&name=-alpine
|
|
||||||
ARG NGROK_VERSION="3.1.0"
|
|
||||||
|
|
||||||
|
|
||||||
FROM python:${PYTHON_VERSION}-alpine AS base
|
FROM python:${PYTHON_VERSION}-alpine AS base
|
||||||
|
|
||||||
|
|
||||||
FROM golang:${GO_VERSION}-alpine AS go
|
FROM golang:${GO_VERSION}-alpine AS go
|
||||||
|
|
||||||
|
|
||||||
FROM ngrok/ngrok:${NGROK_VERSION}-alpine AS ngrok
|
FROM ngrok/ngrok:${NGROK_VERSION}-alpine AS ngrok
|
||||||
|
|
||||||
|
|
||||||
# Build go2rtc binary
|
# 1. Build go2rtc binary
|
||||||
FROM go AS build
|
FROM go AS build
|
||||||
|
|
||||||
WORKDIR /workspace
|
WORKDIR /build
|
||||||
|
|
||||||
# Cache dependencies
|
# Cache dependencies
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
# Build binary
|
COPY . .
|
||||||
COPY cmd cmd
|
|
||||||
COPY pkg pkg
|
|
||||||
COPY www www
|
|
||||||
COPY main.go .
|
|
||||||
RUN CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath
|
RUN CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath
|
||||||
|
|
||||||
RUN mkdir -p /config
|
|
||||||
|
|
||||||
# Collect all files
|
# 2. Collect all files
|
||||||
FROM scratch AS rootfs
|
FROM scratch AS rootfs
|
||||||
|
|
||||||
COPY --from=build /workspace/go2rtc /usr/local/bin/
|
COPY --from=build /build/go2rtc /usr/local/bin/
|
||||||
# Ensure an empty /config folder exists so that the container can be run without a volume
|
|
||||||
COPY --from=build /config /config
|
|
||||||
COPY --from=ngrok /bin/ngrok /usr/local/bin/
|
COPY --from=ngrok /bin/ngrok /usr/local/bin/
|
||||||
COPY ./docker/run.sh /run.sh
|
COPY ./build/docker/run.sh /
|
||||||
|
|
||||||
|
|
||||||
# Final image
|
# 3. Final image
|
||||||
FROM base
|
FROM base
|
||||||
|
|
||||||
# Install ffmpeg, bash (for run.sh), tini (for signal handling),
|
# Install ffmpeg, bash (for run.sh), tini (for signal handling),
|
||||||
# and other common tools for the echo source.
|
# and other common tools for the echo source.
|
||||||
RUN apk add --no-cache ffmpeg bash tini curl jq
|
RUN apk add --no-cache tini ffmpeg bash curl jq
|
||||||
|
|
||||||
|
# Hardware Acceleration for Intel CPU (+50MB)
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
RUN if [ "${TARGETARCH}" = "amd64" ]; then apk add --no-cache libva-intel-driver intel-media-driver; fi
|
||||||
|
|
||||||
|
# Hardware: AMD and NVidia VAAPI (not sure about this)
|
||||||
|
# RUN libva-glx mesa-va-gallium
|
||||||
|
# Hardware: AMD and NVidia VDPAU (not sure about this)
|
||||||
|
# RUN libva-vdpau-driver mesa-vdpau-gallium (+150MB total)
|
||||||
|
|
||||||
COPY --from=rootfs / /
|
COPY --from=rootfs / /
|
||||||
|
|
||||||
|
RUN chmod a+x /run.sh && mkdir -p /config
|
||||||
|
|
||||||
ENTRYPOINT ["/sbin/tini", "--"]
|
ENTRYPOINT ["/sbin/tini", "--"]
|
||||||
|
|
||||||
CMD ["/run.sh"]
|
CMD ["/run.sh"]
|
||||||
|
5
docker/run.sh → build/docker/run.sh
Executable file → Normal file
5
docker/run.sh → build/docker/run.sh
Executable file → Normal file
@@ -1,11 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# ==============================================================================
|
|
||||||
# Runs go2rtc
|
|
||||||
# ==============================================================================
|
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
echo 'Starting go2rtc...' >&2
|
echo "Starting go2rtc..." >&2
|
||||||
|
|
||||||
readonly config_path="/config"
|
readonly config_path="/config"
|
||||||
|
|
Reference in New Issue
Block a user