flipper-xfw-xtreme-firmware
SUCCESS
18m 02s
History Source
SummaryIterations1Transcript25Dockerfile
Dockerfile66 lines · 1806 chars
# Builder stage: compile/build the project from source when possible
FROM ubuntu:20.04 AS builder

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
      build-essential \
      python3.8 \
      python3-pip \
      git \
      ca-certificates \
      pkg-config \
      gcc-arm-none-eabi \
      binutils-arm-none-eabi \
      openocd \
      gdb-multiarch \
      make \
      curl \
      unzip && \
    rm -rf /var/lib/apt/lists/*

# Prepare workdir and copy sources
WORKDIR /work
COPY . /work

# Ensure fbt script is executable if present
RUN if [ -f fbt ]; then chmod +x fbt; fi

ENV VERSION_TAG=local
ENV DEFAULT_TARGET=f7
ENV TARGETS=f7

# Attempt to build via updater_package if a git repo is present; otherwise create a stub dist
RUN set -e; \
    if [ -d .git ]; then \
      echo ".git present: running updater_package"; \
      TARGET_HW=$(echo ${DEFAULT_TARGET} | sed 's/^f//'); \
      ./fbt TARGET_HW=${TARGET_HW} DIST_SUFFIX=${VERSION_TAG} updater_package; \
    else \
      echo "No .git directory; creating stub dist"; \
      mkdir -p dist; echo "stubdist" > dist/README.txt; \
    fi

# Runtime stage will copy dist from builder if available
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

# Include runtime dependencies for a minimal shell container
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
      ca-certificates \
      tzdata \
      && rm -rf /var/lib/apt/lists/*

WORKDIR /work

# Copy any produced artifacts from builder stage
COPY --from=builder /work/dist /work/dist

# If no dist was produced, create a tiny placeholder so container can still run
RUN if [ -d /work/dist ]; then true; else mkdir -p /work/dist; echo "placeholder" > /work/dist/README.txt; fi

CMD ["/bin/bash"]