mediacms icon indicating copy to clipboard operation
mediacms copied to clipboard

Multi-arch builds

Open thebiblelover7 opened this issue 4 years ago • 8 comments

Could it be possible to have a build for arm64? I want to run this on my Raspberry Pi, but this is currently not possible as the container is only available for x86_64 and whenever I run the container it says exec format error. Thanks ahead of time!

thebiblelover7 avatar Oct 13 '21 16:10 thebiblelover7

I've build successfully an image to run on a Raspberry Pi. However, when uploading the videos, multiple ffmpeg processes start for the different video qualities, which results in resource exhaustion and the upload stops. Unless the number of processes in parallel is limited, it is unfeasible to use on devices like the Raspberry Pi.

simao-silva avatar Oct 13 '21 18:10 simao-silva

Running on a raspberry-pi then possible, but without the transcoding processes. See here - https://github.com/mediacms-io/mediacms/discussions/285 to disable transcoding. @simao-silva please share your raspberry pi build instructions if you don't mind.

swiftugandan avatar Oct 13 '21 19:10 swiftugandan

@swiftugandan Check my repository. The image is already built in Docker Hub if you would like to try it.

simao-silva avatar Oct 13 '21 22:10 simao-silva

I've build successfully an image to run on a Raspberry Pi. However, when uploading the videos, multiple ffmpeg processes start for the different video qualities, which results in resource exhaustion and the upload stops. Unless the number of processes in parallel is limited, it is unfeasible to use on devices like the Raspberry Pi.

ffmpeg starts after the uploading has completed, so if you see ffmpeg running it should mean that at least the file got uploaded. Which Raspberry Pi's are you using btw?

mgogoulos avatar Oct 14 '21 10:10 mgogoulos

@swiftugandan Check my repository. The image is already built in Docker Hub if you would like to try it.

I will have to get one of these to try it myself!

mgogoulos avatar Oct 14 '21 10:10 mgogoulos

ffmpeg starts after the uploading has completed, so if you see ffmpeg running it should mean that at least the file got uploaded. Which Raspberry Pi's are you using btw?

Yes, that true. What I meant was that while waiting for the video to be ready (upload + transcoding) I often get the ffmpeg process stopped and the video only available on the original quality. While this has happen with v1.5, I am now using v1.6 and seems more stable. I am using a Raspberry Pi 4B 8GB.

simao-silva avatar Oct 14 '21 14:10 simao-silva

Hi @simao-silva , can you write the steps to get MediaCMS working on the Raspberry Pi? Would you also be interested to write a post for the blog - https://medium.com/@MediaCMS.io ?

mgogoulos avatar Oct 15 '21 08:10 mgogoulos

@mgogoulos I just replace the default Dockerfile in the repository by the one below. Still, I am improving the building process.

ARG PYTHON_VERSION=3.9.7

############ BENTO COMPILATION ############
FROM python:${PYTHON_VERSION}-alpine AS bento-compiler

# LABEL source_code=https://github.com/axiomatic-systems/Bento4

# Setup environment variables
ARG BENTO4_VERSION=v1.6.0-639

# Install Dependencies
RUN apk update && \
    apk add --no-cache ca-certificates bash make cmake gcc g++ git

# Copy Sources and build
RUN set -eux && \
    ARCH=$(uname --m) && \
    if [ $(uname --m) = "aarch64" ]; then ARCH="arm"; fi && \
    git clone https://github.com/axiomatic-systems/Bento4 -b ${BENTO4_VERSION} /tmp/bento4 && \
    rm -rf /tmp/bento4/cmakebuild && \
    mkdir -p /tmp/bento4/cmakebuild/${ARCH} && \
    cd /tmp/bento4/cmakebuild/${ARCH} && \
    cmake -DCMAKE_BUILD_TYPE=Release ../.. && \
    make

# Install
RUN set -eux && \
    ARCH=$(uname --m) && \
    if [ $(uname --m) = "aarch64" ]; then ARCH="arm"; fi && \
    cd /tmp/bento4 && \
    python3 Scripts/SdkPackager.py ${ARCH} . cmake && \
    mkdir /opt/bento4 && \
    mv /tmp/bento4/SDK/Bento4-SDK-*/* /opt/bento4


############ OTHER COMPILATION ############
FROM python:${PYTHON_VERSION}-slim-buster AS compile-image

SHELL ["/bin/bash", "-c"]

# Set up virtualenv
ENV VIRTUAL_ENV=/home/mediacms.io
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
ENV PIP_NO_CACHE_DIR=1

RUN apt-get update && \
    apt-get install --no-install-recommends -y gcc libc6-dev libpq-dev

RUN set -eux && \
    mkdir -p /home/mediacms.io/mediacms/logs && \
    cd /home/mediacms.io && \ 
    python3 -m venv "$VIRTUAL_ENV"

# Install dependencies:
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . /home/mediacms.io/mediacms
WORKDIR /home/mediacms.io/mediacms

COPY --from=bento-compiler /opt/bento4 ../bento4


############ RUNTIME IMAGE ############
FROM python:${PYTHON_VERSION}-slim-buster as runtime-image

ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV ADMIN_USER='admin'
ENV ADMIN_PASSWORD='mediacms'
ENV ADMIN_EMAIL='admin@localhost'

# See: https://github.com/celery/celery/issues/6285#issuecomment-715316219
ENV CELERY_APP='cms'

# Use these to toggle which processes supervisord should run
ENV ENABLE_UWSGI='yes'
ENV ENABLE_NGINX='yes'
ENV ENABLE_CELERY_BEAT='yes'
ENV ENABLE_CELERY_SHORT='yes'
ENV ENABLE_CELERY_LONG='yes'
ENV ENABLE_MIGRATIONS='yes'

# Set up virtualenv
ENV VIRTUAL_ENV=/home/mediacms.io
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY --chown=www-data:www-data --from=compile-image /home/mediacms.io /home/mediacms.io

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        supervisor nginx ffmpeg imagemagick procps libpq-dev && \
    rm -rf /var/lib/apt/lists/* && \
    apt-get purge --auto-remove -y && \
    apt-get clean

WORKDIR /home/mediacms.io/mediacms

EXPOSE 9000 80

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

ENTRYPOINT ["./deploy/docker/entrypoint.sh"]

CMD ["./deploy/docker/start.sh"]

simao-silva avatar Oct 19 '21 01:10 simao-silva