-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This shrinks the image from ~200MB to ~30MB.
- Loading branch information
Showing
1 changed file
with
22 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |