Skip to content

Dev Dockerfile

Summary

The following Dockerfile examples assumes it is copying over the working-copy of the Flamenco repo and that you want to automatically make the executables while building the container. See setup details.

The Docker Container will run various applications from building everything, to running the webapp to the flamenco-manager so it includes all necessary elements. It will also run all the Go Mock tests.

This includes a copy of Blender as the Flamenco Manager setup workflow looks for Blender executable on the host running the Flamenco Manager.

Requirements

  1. Nodejs is installed using https://deb.nodesource.com/setup_16.x
  2. Golang is installed using backport PPA 2:1.20~1longsleep1
  3. Blender 3.5.1
  4. Docker Desktop with buildx
  5. Configure Europe/Amsterdam timezone (scheduling tests dependency)
  6. Run make as non-root testuser

Example Multi-Stage Dockerfile

This example uses Ubuntu Jammy (U22.04) which is quite large. Attempts to use Debian Bookworm failed due to some issues installing updates at the time of writing (Bug#1033502: software-properties-common: got ‘NoneType’ object has no attribute ‘people’ while adding LP PPA).

You can directly download this file https://blender.dtmc.ca/docs/resources/docker/flamenco/dev/Dockerfile

FROM --platform=$BUILDPLATFORM ubuntu:jammy AS build
ARG TARGETOS TARGETARCH

ENV TZ="Europe/Amsterdam"

# Toolchain dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
    --mount=type=cache,target=/var/lib/apt,sharing=locked \
    apt-get update && \
    apt install -y curl gzip tzdata software-properties-common && \
    add-apt-repository ppa:longsleep/golang-backports  && \
    apt-get update && \
    apt-get install -y default-jre-headless golang git && \    
    curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
    apt-get update && \
    apt install -y hugo file make nodejs && \
    npm install --global yarn && \
    ln -fs /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata && \
    apt-get -y autoremove

ENV DEBIAN_FRONTEND=dialog
ARG TARGETOS TARGETARCH
# Port: flameno-manager API
EXPOSE 8080 
# Port: flamenco yarn (dev) webapp ports
EXPOSE 8081 
# Port: Hugo documentation server
EXPOSE 1313

# Create a non-root user and some
# expected folders.
# - This is safer and also some Flamenco mock tests do
#   not expect root user with full file-system permissions
# - Tests require a /tmp/ folder (Go TempDir)
# - Mock /media/shared/flamenco/development folder
RUN mkdir -p /home/testuser && \
    groupadd -g 999 testuser && \
    useradd -r -s /bin/bash -u 999 -g testuser testuser && \
    chown testuser:testuser /home/testuser && \
    mkdir -p /code; chown testuser:testuser /code && \
    mkdir -p /media/shared/flamenco/development && \
    mkdir -p /tmp

# Copy over working-copy contents and
WORKDIR /code

# Pull in go modules to not invalidate download cache
COPY go.mod go.sum /code/
RUN go mod download
USER testuser
COPY --chown=testuser:testuser . /code
RUN git config --global --add safe.directory /code

# Build webapp, flamenco-manager, flamenco-worker executables
# for the appropriate target OS & Arch
RUN --mount=type=cache,target=/root/.cache/go-build \
    --mount=type=cache,target=/go/pkg \
    GOOS=${TARGETOS} GOARCH=${TARGETARCH} make with-deps

# Run tests as non-root user
RUN --mount=type=cache,target=/root/.cache/go-build \
    --mount=type=cache,target=/go/pkg \
    GOOS=${TARGETOS} GOARCH=${TARGETARCH} make test

FROM scratch AS export
ARG TARGETOS TARGETARCH
COPY --from=build /code/flamenco-manager ./flamenco-manager_${TARGETARCH}
COPY --from=build /code/flamenco-worker ./flamenco-worker_${TARGETARCH}

# Launch the webapp locally when container is run
CMD ["yarn", "--cwd", "/code/web/app", "run", "dev", "--host"]

Note

The path /media/shared/flamenco/development/ is created inside the Container because this is the NFS share on the host and in this example we want the development instance of Flamenco Manager running in the Container to use that location.

Warning

Do not use an actual Flamenco NFS share location unless you want to overwrite an existing deployment! In this example, a ‘development’ folder is used for the manager files and database.