Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 52 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
FROM ubuntu:24.04
ARG TARGETARCH
FROM ubuntu:24.04 AS builder
ARG TARGETARCH

# 1. Install EVERYTHING (Build tools + Runtime tools)
# Install build tools
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
ninja-build \
wget \
ca-certificates \
python3 \
nano \
less \
git \
libxml2 \
libxml2-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# 2. Install srcML (Runtime and Dev headers together)
RUN if [ "$TARGETARCH" = "amd64" ]; then \
wget https://github.com/srcML/srcML/releases/download/v1.1.0/srcml_1.1.0-1_ubuntu24.04_amd64.deb \
&& wget https://github.com/srcML/srcML/releases/download/v1.1.0/srcml-dev_1.1.0-1_ubuntu24.04_amd64.deb; \
elif [ "$TARGETARCH" = "arm64" ]; then \
wget https://github.com/srcML/srcML/releases/download/v1.1.0/srcml_1.1.0-1_ubuntu24.04_arm64.deb \
&& wget https://github.com/srcML/srcML/releases/download/v1.1.0/srcml-dev_1.1.0-1_ubuntu22.04_arm64.deb; \
else \
echo "Unsupported arch: $TARGETARCH" && exit 1; \
fi && \
apt-get update && apt-get install -y ./*.deb && rm -f ./*.deb

# 3. Build and install srcSAX (Force standard paths so nameCollector finds it)
COPY srcSAX /srcSAX
# Build and install srcSAX
RUN mkdir -p /srcSAX \
&& wget -O /tmp/srcSAX.tar.gz https://github.com/srcML/srcSAX/archive/refs/heads/master.tar.gz \
&& tar -xzf /tmp/srcSAX.tar.gz -C /srcSAX --strip-components=1 \
&& rm /tmp/srcSAX.tar.gz
WORKDIR /srcSAX
RUN cmake -B build -G Ninja \
-DCMAKE_INSTALL_PREFIX=/usr/local \
Expand All @@ -39,10 +25,50 @@ RUN cmake -B build -G Ninja \
&& cd build \
&& ninja install

# 4. Build nameCollector
COPY nameCollector /nameCollector
# Build nameCollector
RUN mkdir -p /nameCollector \
&& wget -O /tmp/nameCollector.tar.gz https://github.com/srcML/nameCollector/archive/refs/heads/main.tar.gz \
&& tar -xzf /tmp/nameCollector.tar.gz -C /nameCollector --strip-components=1 \
&& rm /tmp/nameCollector.tar.gz
WORKDIR /nameCollector
RUN cmake -B build -G Ninja && cd build && ninja

# 5. Set default directory straight to the compiled binary
WORKDIR /nameCollector/build/bin
FROM ubuntu:24.04
ARG TARGETARCH

# Install runtime deps only
RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
ca-certificates \
libxml2 \
nano \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /var/cache/debconf/*-old /var/log/dpkg.log /var/log/apt/*

# Install srcML
RUN if [ "$TARGETARCH" = "amd64" ]; then \
wget https://github.com/srcML/srcML/releases/download/v1.1.0/srcml_1.1.0-1_ubuntu24.04_amd64.deb; \
elif [ "$TARGETARCH" = "arm64" ]; then \
wget https://github.com/srcML/srcML/releases/download/v1.1.0/srcml_1.1.0-1_ubuntu24.04_arm64.deb; \
else \
echo "Unsupported arch: $TARGETARCH" && exit 1; \
fi && \
apt-get update && apt-get install -y ./*.deb && rm -f ./*.deb \
&& rm -rf /var/lib/apt/lists/* /var/cache/debconf/*-old /var/log/dpkg.log /var/log/apt/*

# Copy srcSAX shared libs from builder
COPY --from=builder /usr/local/lib/ /usr/local/lib/
RUN ldconfig

# Copy nameCollector binary from builder
COPY --from=builder /nameCollector/build/bin/nameCollector /usr/local/bin/nameCollector

# Install examples
WORKDIR /examples
ARG CACHEBUST=1
RUN wget -qO- https://api.github.com/repos/srcML/nameCollector/releases/tags/v1.0.0 \
| grep -oE '"browser_download_url": *"[^"]*"' \
| sed -E 's/.*"(https:[^"]+)".*/\1/' \
| wget -i - \
&& apt-get remove -y wget && apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* /var/cache/debconf/*-old /var/log/dpkg.log /var/log/apt/*
37 changes: 37 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
variable "REGISTRY" {
default = "docker.io/srcml"
}

variable "IMAGE" {
default = "namecollector"
}

variable "TAG" {
default = "latest"
}

group "default" {
targets = ["namecollector"]
}

target "namecollector" {
context = "."
dockerfile = "Dockerfile"
platforms = ["linux/amd64", "linux/arm64"]
args = {
CACHEBUST = "${timestamp()}"
}
tags = [
"${REGISTRY}/${IMAGE}:1.0.0",
"${REGISTRY}/${IMAGE}:1.0",
"${REGISTRY}/${IMAGE}:1",
"${REGISTRY}/${IMAGE}:latest",
]
}

target "local" {
inherits = ["namecollector"]
platforms = ["linux/amd64"]
output = ["type=docker"]
tags = ["${IMAGE}:${TAG}"]
}