stlink-org-stlink
SUCCESS
8m 18s
History Source
SummaryIterations1Transcript7Dockerfile
01Iteration 1
WRITEWriteFile· step #1
0s
Dockerfile1235 bytes written
text44 lines · 1235 chars
# Multi-stage Dockerfile to build stlink from source and provide a runnable container

# Stage 1: Build the project from source
FROM ubuntu:22.04 AS builder

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        build-essential cmake libusb-1.0-0-dev libgtk-3-dev pkg-config git ca-certificates \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /src
COPY . /src

# Build and install to /usr/local
RUN mkdir -p build && cd build \
    && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. \
    && make -j"$(nproc)" \
    && make install

# Stage 2: Run the built binaries
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

# Runtime dependencies (include GTK for GUI binary compatibility)
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        libusb-1.0-0 libgtk-3-0 libgl1-mesa-dri libgl1-mesa-glx ca-certificates \
        fontconfig x11-apps \
    && rm -rf /var/lib/apt/lists/*

# Copy the built artifacts from the builder stage
COPY --from=builder /usr/local /usr/local

# Ensure binaries can be found in PATH
ENV PATH=/usr/local/bin:$PATH

WORKDIR /workspace

# Provide an interactive shell by default
CMD ["/bin/bash"]
WRITEWriteFile· step #2
0s
.dockerignore225 bytes written
dockerignore19 lines · 225 chars
# Exclude VCS and build artifacts
.git
.gitignore
build/
*CMakeCache*
CMakeFiles/
Makefile
.dockerignore
.DS_Store

# Node, Python, etc. artifacts if present
node_modules/
__pycache__/
*.pyc

# GTK GUI temporary files
*.log

VERIFYVerifyBuild· step #3
2m 37s
VerifyBuildsmoke_failed
Concerns: GUI dependencies (libgtk-3-0, libgtk-3-dev) inflate the image; if only CLI functionality is required, consider trimming runtime dependencies., Container runs as root by default; consider adding a non-root user for security in production use., COPY . /src copies the entire build context; ensure a .dockerignore is present to exclude large or sensitive files.
Smoke [FAIL]: test -x /usr/local/bin/st-util && echo 'st-util present
  Output: sh: 1: Syntax error: Unterminated quoted string

Smoke [FAIL]: test -x /usr/local/bin/st-info && echo 'st-info present
  Output: sh: 1: Syntax error: Unterminated quoted string

Smoke [FAIL]: test -x /usr/local/bin/st-flash && echo 'st-flash present
  Output: sh: 1: Syntax error: Unterminated quoted string
WRITEWriteFile· step #4
0s
Dockerfile1435 bytes written
text50 lines · 1435 chars
# Multi-stage Dockerfile to build stlink from source and provide a runnable container

# Stage 1: Build the project from source
FROM ubuntu:22.04 AS builder

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        build-essential cmake libusb-1.0-0-dev libgtk-3-dev pkg-config git ca-certificates \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /src
COPY . /src

# Build and install to /usr/local
RUN mkdir -p build && cd build \
    && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. \
    && make -j$(nproc) \
    && make install

# Stage 2: Run the built binaries
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

# Lightweight runtime dependencies (CLI tools do not require GTK at runtime)
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        libusb-1.0-0 ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user for running the application
RUN groupadd -r stlink && useradd -m -r -g stlink -d /home/stlink -s /bin/bash stlink

# Copy the built artifacts from the builder stage
COPY --from=builder /usr/local /usr/local

# Adjust ownership so the non-root user can access the binaries and libs
RUN chown -R stlink:stlink /usr/local

# Ensure binaries can be found in PATH
ENV PATH=/usr/local/bin:$PATH

USER stlink
WORKDIR /workspace

# Provide an interactive shell by default
CMD ["/bin/bash"]
VERIFYVerifyBuild· step #5
43s
VerifyBuildsmoke_failed
Concerns: Runtime image may require GTK libraries if GUI tools are used; currently final image only includes libusb-1.0-0 and ca-certificates. If GUI features are needed, consider adding libgtk-3-0 to the runtime image or build without GTK dependencies.
Smoke [FAIL]: command -v st-info >/dev/null 2>&1 && st-info --help || echo 'st-info-missing
  Output: sh: 1: Syntax error: Unterminated quoted string

Smoke [FAIL]: command -v st-flash >/dev/null 2>&1 && st-flash --help || echo 'st-flash-missing
  Output: sh: 1: Syntax error: Unterminated quoted string

Smoke [FAIL]: command -v st-util >/dev/null 2>&1 && st-util --help || echo 'st-util-missing
  Output: sh: 1: Syntax error: Unterminated quoted string
WRITEWriteFile· step #6
0s
Dockerfile1466 bytes written
text46 lines · 1466 chars
# Multi-stage Dockerfile to build stlink from source and provide a runnable container

# Stage 1: Build the project from source
FROM ubuntu:22.04 AS builder

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        build-essential cmake libusb-1.0-0-dev libgtk-3-dev pkg-config git ca-certificates \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /src
COPY . /src

# Build and install to /usr/local
RUN mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
    make -j$(nproc) && make install

# Stage 2: Run the built binaries
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

# Runtime dependencies (GUI libraries included for compatibility with GUI tools)
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        libusb-1.0-0-dev libusb-1.0-0 libgtk-3-0 libgl1-mesa-dri libgl1-mesa-glx ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Create a simple, non-root user for running the application (security best practice)
RUN groupadd -r stlink && useradd -m -r -g stlink -d /home/stlink -s /bin/bash stlink

# Copy the built artifacts from the builder stage
COPY --from=builder /usr/local /usr/local

# Ensure binaries can be found in PATH and fix permissions
ENV PATH=/usr/local/bin:$PATH
RUN chown -R stlink:stlink /usr/local

USER stlink
WORKDIR /workspace

# Provide an interactive shell by default
CMD ["/bin/bash"]
VERIFYVerifyBuild· step #7
2m 10s
VerifyBuildaccepted
Concerns: Runtime image installs -dev and GUI libraries (libgtk-3-0) which greatly increase image size; consider trimming runtime deps to needed libraries only., Stage 1 copies entire build context; ensure a .dockerignore to avoid sending large files (e.g., build artifacts, local dependencies) to docker daemon., The final image relies on the assumption that the built tools install to /usr/local/bin (e.g., st-info, st-flash). If the project changes, the smoke tests may fail; consider adding explicit test or verifying presence of expected binaries.
Smoke [PASS]: test -x /usr/local/bin/st-info || test -x /usr/local/bin/st-flash
Smoke [PASS]: test -d /usr/local/lib