Skip to content

Commit

Permalink
Switch to alpine and build q3asm.
Browse files Browse the repository at this point in the history
This shrinks the image from ~200MB to ~30MB.
  • Loading branch information
dsvensson committed Nov 2, 2024
1 parent e860fbe commit ee5da5c
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
FROM debian:bookworm-slim AS builder
FROM alpine:3.20.3 AS builder

ARG TARGETOS
ARG TARGETARCH

RUN apt-get update -qq && apt-get install -qq --no-install-recommends build-essential bison
RUN --mount=type=cache,id=${TARGETARCH}/var/cache/apk,target=/var/cache/apk \
apk add --update build-base bison

ADD /q3lcc /opt/q3lcc
WORKDIR /opt/q3lcc
ADD /q3asm /opt/q3asm

RUN make -j $(nproc) PLATFORM=${TARGETOS} ARCH=${TARGETARCH}
WORKDIR /opt

RUN cd q3lcc && make -j $(nproc) PLATFORM=${TARGETOS} ARCH=${TARGETARCH}
RUN cd q3asm && make -j $(nproc)

WORKDIR /opt/q3lcc/build-${TARGETOS}-${TARGETARCH}
RUN install -s -m 0755 q3lcc q3cpp q3rcc /usr/local/bin/

WORKDIR /opt/q3asm
RUN install -s -m 0755 q3asm /usr/local/bin/

FROM alpine:3.20.3

RUN install -s -m 0755 q3lcc q3cpp q3rcc /usr/local/bin/
ARG TARGETOS
ARG TARGETARCH

FROM debian:bookworm-slim
RUN --mount=type=cache,id=${TARGETARCH}/var/cache/apk,target=/var/cache/apk \
apk add --no-cache cmake bash ninja-build && rm /usr/bin/cpack /usr/bin/ctest

RUN apt-get update -qq && apt-get install -qq --no-install-recommends build-essential cmake ninja-build && mkdir /src
COPY --from=builder /usr/local/bin/q3asm /usr/local/bin/q3lcc /usr/local/bin/q3cpp /usr/local/bin/q3rcc /usr/local/bin/

COPY --from=builder /usr/local/bin/q3lcc /usr/local/bin/q3cpp /usr/local/bin/q3rcc /usr/local/bin/
# cmake needs to have some kind of cc installed, even if not used for regular C code
ENV CC="q3lcc" \
PATH="$PATH:/usr/lib/ninja-build/bin"

WORKDIR /src

0 comments on commit ee5da5c

Please sign in to comment.