Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enabling multiarch support #456

Merged
merged 22 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
84 changes: 84 additions & 0 deletions .github/workflows/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -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"]
246 changes: 246 additions & 0 deletions .github/workflows/docker-image-rust-target-multi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
name: Build Dim Bin and Dockerize

on:
push:
branches: [ 'master' ] #rolling build on develop only
tags: 'v*' #tag for specific release v1.0.2,or anytag, start with v
pull_request:
branches: [ 'main' ] #build test on main, not pushing
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
DATABASE_URL: "sqlite://./dim_dev.db"
# 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: rustlang/rust:nightly
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
DATABASE_URL: "sqlite://./dim_dev.db"
steps:
- name: add armhf architecture
run: dpkg --add-architecture armhf
- name: install runtime
run: apt update && apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-armhf-cross libc6-dev-armhf-cross libssl-dev:armhf
- name: add armhf target
run: rustup target add armv7-unknown-linux-gnueabihf
- name: set default nightly
run: rustup default nightly
- name: smoke test
run: rustc --version
- name: Checkout repository
uses: actions/checkout@v2
- name: Download webui
uses: actions/download-artifact@v3
with:
name: ui
path: ui/build
- 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: rustlang/rust:nightly
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
DATABASE_URL: "sqlite://./dim_dev.db"
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: add arm64 target
run: rustup target add aarch64-unknown-linux-gnu
- name: set default nightly
run: rustup default nightly
- name: smoke test
run: rustc --version
- name: Checkout repository
uses: actions/checkout@v2
- name: Download webui
uses: actions/download-artifact@v3
with:
name: ui
path: ui/build
- 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-aarch64-musl:
# needs: [create-ui]
# runs-on: ubuntu-latest
# container:
# image: rustlang/rust:stable
# env:
# CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc
# OPENSSL_INCLUDE_DIR: "/usr/include/openssl/"
# OPENSSL_LIB_DIR: "/usr/lib/aarch64-linux-gnu/"
# CARGO_TERM_COLOR: always
# DATABASE_URL: "sqlite://./dim_dev.db"
# 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: add arm64 target
# run: rustup target add aarch64-unknown-linux-musl
# - name: set default nightly
# run: rustup default nightly
# - name: smoke test
# run: rustc --version
# - name: Checkout repository
# uses: actions/checkout@v2
# - name: Download webui
# uses: actions/download-artifact@v3
# with:
# name: ui
# path: ui/build
# - name: compile aarch64-musl
# run: cargo build --target=aarch64-unknown-linux-musl --release
# - name: check path
# run: ls -al target/
# - name: upload aarch64 artifacts
# uses: actions/upload-artifact@v3
# with:
# name: aarch64-bin-musl
# path: target/aarch64-unknown-linux-musl/release/dim

martadinata666 marked this conversation as resolved.
Show resolved Hide resolved

build-amd64:
needs: [create-ui]
runs-on: ubuntu-latest
container:
image: rustlang/rust:nightly
env:
CARGO_TERM_COLOR: always
DATABASE_URL: "sqlite://./dim_dev.db"
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: set default nightly
run: rustup default nightly
- name: smoke test
run: rustc --version
- name: Checkout repository
uses: actions/checkout@v2
- name: Download webui
uses: actions/download-artifact@v3
with:
name: ui
path: ui/build
- 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

21 changes: 11 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down