turbulenz-turbulenz_engine
SUCCESS
27m 43s
History Source
SummaryIterations2Transcript21Dockerfile
Dockerfile69 lines · 1995 chars
# Build stage
FROM ubuntu:22.04 AS builder

ENV DEBIAN_FRONTEND=noninteractive

# Install essential build tools and a modern Node.js (for ts/js builds)
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        ca-certificates curl git pkg-config build-essential python3 \
        python3-distutils python3-venv \
    && rm -rf /var/lib/apt/lists/*

# Install Node.js (LTS) - setup 22.x
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
    && apt-get install -y --no-install-recommends nodejs \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /workspace

# Copy source code into image
COPY . /workspace

# Ensure tzbuild is present; if not, clone it
RUN if [ ! -d external/tzbuild ]; then \
        echo "tzbuild not present; cloning..."; \
        git clone --depth 1 https://github.com/turbulenz/tzbuild.git external/tzbuild; \
    else \
        echo "tzbuild already present"; \
    fi

# Initialize submodules if any
WORKDIR /workspace
RUN if [ -f external/tzbuild/.gitmodules ]; then git -C external/tzbuild submodule update --init --recursive || true; fi

# Install tzbuild dependencies if package.json exists
WORKDIR /workspace/external/tzbuild
RUN if [ -f package.json ]; then npm ci --silent; fi

# Return to repo root and attempt to build jslib
WORKDIR /workspace
RUN make jslib || true

# Stage 2: runtime image
FROM ubuntu:22.04 AS runtime

ENV DEBIAN_FRONTEND=noninteractive

# Create a non-root user for running the server
RUN groupadd -r app && useradd -r -g app app

# Minimal runtime: Python for static content serving
RUN apt-get update \
    && apt-get install -y --no-install-recommends python3 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /workspace

# Copy built artifacts from the builder
COPY --from=builder /workspace /workspace

RUN chown -R app:app /workspace

USER app

EXPOSE 8080

# Serve repository contents over HTTP for smoke tests
CMD ["python3", "-m", "http.server", "8080", "--bind", "0.0.0.0", "--directory", "/workspace"]