diff --git a/.github/workflows/Dockerfile.ci b/.github/workflows/Dockerfile.ci new file mode 100644 index 000000000..7aa620214 --- /dev/null +++ b/.github/workflows/Dockerfile.ci @@ -0,0 +1,84 @@ +FROM debian:bullseye AS ffmpeg +ARG DEBIAN_FRONTEND=noninteractive +WORKDIR /static +ARG TARGETPLATFORM +RUN echo ${TARGETPLATFORM} +RUN apt update && \ + apt install -y --no-install-recommends wget unzip tar ca-certificates xz-utils + +RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ + wget https://github.com/Dusk-Labs/ffmpeg-static/releases/download/ffmpeg-all-0.0.1/ffmpeg && \ + wget https://github.com/Dusk-Labs/ffmpeg-static/releases/download/ffmpeg-all-0.0.1/ffprobe && \ + ls -la . && \ + pwd \ + ; fi + +RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ + wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-arm64-static.tar.xz && \ + tar --strip-components 1 -xf ffmpeg-release-arm64-static.tar.xz \ + ; fi + +RUN if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \ + wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-armhf-static.tar.xz && \ + tar --strip-components 1 -xf ffmpeg-release-armhf-static.tar.xz \ + ; fi + +RUN chmod +x /static/ffmpeg && chmod +x /static/ffprobe +# Smoke Test +#RUN /static/ffmpeg -version +#RUN /static/ffprobe -version + +FROM debian:bullseye AS dim +ARG DEBIAN_FRONTEND=noninteractive +ARG TARGETPLATFORM +WORKDIR /dim +COPY bin/ bin/ +RUN ls -al bin/ +RUN mkdir -p target/ + +RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ + mv bin/amd64-bin/dim target/dim && \ + chmod +x target/dim && \ + ls -la target/ . && \ + pwd \ + ; fi + +RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ + mv bin/aarch64-bin/dim target/dim && \ + chmod +x target/dim && \ + ls -la target/ . && \ + pwd \ + ; fi + +RUN if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \ + mv bin/armhf-bin/dim target/dim && \ + chmod +x target/dim && \ + ls -la target/ . && \ + pwd \ + ; fi + + +FROM debian:bullseye +ENV RUST_BACKTRACE=full +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y \ + ca-certificates \ + libfontconfig \ + libfribidi0 \ + libharfbuzz0b \ + libtheora0 \ + libva-drm2 \ + libva2 \ + libvorbis0a \ + libvorbisenc2 \ + && rm -rf /var/lib/apt/lists/* +COPY --from=ffmpeg /static/ffmpeg /opt/dim/utils/ffmpeg +COPY --from=ffmpeg /static/ffprobe /opt/dim/utils/ffprobe +COPY --from=dim /dim/target/dim /opt/dim/dim + +EXPOSE 8000 +VOLUME ["/opt/dim/config"] + +ENV RUST_LOG=info +WORKDIR /opt/dim +CMD ["./dim"] diff --git a/.github/workflows/docker-image-rust-target-multi.yml b/.github/workflows/docker-image-rust-target-multi.yml new file mode 100644 index 000000000..86c66e55c --- /dev/null +++ b/.github/workflows/docker-image-rust-target-multi.yml @@ -0,0 +1,231 @@ +name: Build Dim Bin and Dockerize + +on: + push: + branches: [ 'master','docker-build' ] + tags: 'v*' + pull_request: + branches: [ 'master' ] + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + # OpenSSL Tweak + +jobs: + create-ui: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Build UI + uses: actions/setup-node@v3 + with: + node-version: '16' + cache: 'yarn' + - run: npm install -g yarn + - run: yarn -d --cwd ui/ install + - run: yarn -d --cwd ui/ build + - name: upload ui artifacts + uses: actions/upload-artifact@v3 + with: + name: ui + path: ui/build + + build-armhf: + needs: [create-ui] + runs-on: ubuntu-latest + container: + image: rust:1.63 + env: + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc + OPENSSL_INCLUDE_DIR: "/usr/include/openssl/" + OPENSSL_LIB_DIR: "/usr/lib/arm-linux-gnueabihf/" + CARGO_TERM_COLOR: always + steps: + - name: add armhf architecture + run: dpkg --add-architecture armhf + - name: install runtime + run: apt update && apt install -y pkg-config gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-armhf-cross libc6-dev-armhf-cross tar ca-certificates + - name: Checkout repository + uses: actions/checkout@v2 + - name: Download webui + uses: actions/download-artifact@v3 + with: + name: ui + path: ui/build + - uses: actions/cache@v3 + with: + path: | + .cargo/bin + .cargo/registry/index + .cargo/registry/cache + .cargo/git/db + target + key: lldap-bin-armhf-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + lldap-bin-armhf- + - name: add armhf target + run: rustup target add armv7-unknown-linux-gnueabihf + - name: smoke test + run: rustc --version + - name: compile armhf + run: cargo build --target=armv7-unknown-linux-gnueabihf --release + - name: check path + run: ls -al target/ + - name: upload armhf artifacts + uses: actions/upload-artifact@v3 + with: + name: armhf-bin + path: target/armv7-unknown-linux-gnueabihf/release/dim + + + build-aarch64: + needs: [create-ui] + runs-on: ubuntu-latest + container: + image: rust:1.63 + env: + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc + OPENSSL_INCLUDE_DIR: "/usr/include/openssl/" + OPENSSL_LIB_DIR: "/usr/lib/aarch64-linux-gnu/" + CARGO_TERM_COLOR: always + steps: + - name: add arm64 architecture + run: dpkg --add-architecture arm64 + - name: install runtime + run: apt update && apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-arm64-cross libc6-dev-arm64-cross libssl-dev:arm64 + - name: Checkout repository + uses: actions/checkout@v2 + - name: Download webui + uses: actions/download-artifact@v3 + with: + name: ui + path: ui/build + - uses: actions/cache@v3 + with: + path: | + .cargo/bin + .cargo/registry/index + .cargo/registry/cache + .cargo/git/db + target + key: lldap-bin-aarch64-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + lldap-bin-aarch64- + - name: add arm64 target + run: rustup target add aarch64-unknown-linux-gnu + - name: smoke test + run: rustc --version + - name: compile aarch64 + run: cargo build --target=aarch64-unknown-linux-gnu --release + - name: check path + run: ls -al target/ + - name: upload aarch64 artifacts + uses: actions/upload-artifact@v3 + with: + name: aarch64-bin + path: target/aarch64-unknown-linux-gnu/release/dim + + build-amd64: + needs: [create-ui] + runs-on: ubuntu-latest + container: + image: rust:1.63 + env: + CARGO_TERM_COLOR: always + steps: + - name: install runtime + run: apt update && apt install -y gcc-x86-64-linux-gnu g++-x86-64-linux-gnu libc6-dev libssl-dev libva-dev libva-drm2 libva2 + - name: Checkout repository + uses: actions/checkout@v2 + - name: Download webui + uses: actions/download-artifact@v3 + with: + name: ui + path: ui/build + - uses: actions/cache@v3 + with: + path: | + .cargo/bin + .cargo/registry/index + .cargo/registry/cache + .cargo/git/db + target + key: lldap-bin-amd64-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + lldap-bin-amd64- + - name: add x86_64 target + run: rustup target add x86_64-unknown-linux-gnu + - name: smoke test + run: rustc --version + - name: compile amd64 + run: cargo build --features vaapi --target=x86_64-unknown-linux-gnu --release + - name: check path + run: ls -al target/ + - name: upload amd64 artifacts + uses: actions/upload-artifact@v3 + with: + name: amd64-bin + path: target/x86_64-unknown-linux-gnu/release/dim + + build-docker-image: + needs: [build-armhf,build-aarch64,build-amd64] + name: Build Docker image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: fetch repo + uses: actions/checkout@v2 + - name: Download armhf dim artifacts + uses: actions/download-artifact@v3 + with: + name: armhf-bin + path: bin/armhf-bin + - name: Download armhf dim artifacts + uses: actions/download-artifact@v3 + with: + name: aarch64-bin + path: bin/aarch64-bin + - name: Download amd64 dim artifacts + uses: actions/download-artifact@v3 + with: + name: amd64-bin + path: bin/amd64-bin + + - name: check path + run: ls -al + - name: check bin path + run: ls -al bin/ + + - name: setup qemu + uses: docker/setup-qemu-action@v1 + - uses: docker/setup-buildx-action@v2 + - uses: docker/metadata-action@v3 + id: meta + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + - uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v2 + with: + #push: true + push: ${{ github.event_name != 'pull_request' }} + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7 + file: ./.github/workflows/Dockerfile.ci + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-to: type=gha,mode=max + cache-from: type=gha + diff --git a/Dockerfile b/Dockerfile index c0ad75c81..5efa0da46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,30 +9,31 @@ RUN yarn run build FROM debian:bullseye AS ffmpeg ARG DEBIAN_FRONTEND=noninteractive WORKDIR /static +ARG TARGETPLATFORM +RUN echo ${TARGETPLATFORM} +RUN apt update && \ + apt install -y --no-install-recommends wget unzip tar ca-certificates xz-utils -ARG TARGETARCH=amd64 -RUN if [ "$TARGETARCH" = "amd64" ]; then \ - apt-get update && \ - apt-get install -y wget unzip && \ +RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ wget https://github.com/Dusk-Labs/ffmpeg-static/releases/download/ffmpeg-all-0.0.1/ffmpeg && \ wget https://github.com/Dusk-Labs/ffmpeg-static/releases/download/ffmpeg-all-0.0.1/ffprobe && \ ls -la . && \ pwd \ ; fi -RUN if [ "$TARGETARCH" = "arm64" ]; then \ - apt-get update && \ - apt-get install -y wget tar xz-utils && \ + +RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-arm64-static.tar.xz && \ tar --strip-components 1 -xf ffmpeg-release-arm64-static.tar.xz \ ; fi -RUN if [ "$TARGETARCH" = "arm" ]; then \ - apt-get update && \ - apt-get install -y wget tar xz-utils && \ + +RUN if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \ wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-armhf-static.tar.xz && \ tar --strip-components 1 -xf ffmpeg-release-armhf-static.tar.xz \ ; fi + RUN chmod +x /static/ffmpeg && chmod +x /static/ffprobe + FROM rust:bullseye AS dim ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y \