From 61201abb9041cf76f06f39fff8f06923a3be7b9a Mon Sep 17 00:00:00 2001 From: garanews Date: Wed, 31 Jul 2024 08:50:33 +0200 Subject: [PATCH] Update Dockerfile --- compose/local/django/Dockerfile | 44 ++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/compose/local/django/Dockerfile b/compose/local/django/Dockerfile index 8fcfe639..5b6406ca 100644 --- a/compose/local/django/Dockerfile +++ b/compose/local/django/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.3 ARG TARGETPLATFORM -ARG BUILDPLATFORM + FROM python:3.12-slim-bookworm AS common-base @@ -40,23 +40,28 @@ RUN git clone --branch v4.3.x --recursive https://github.com/VirusTotal/yara-pyt WORKDIR /tmp/yara-python RUN python setup.py build -FROM common-base AS go-builder-amd64 -RUN apt-get update && apt-get install -y curl gcc -RUN curl -Lo go.tar.gz https://dl.google.com/go/go1.22.0.linux-amd64.tar.gz \ - && tar -C /usr/local -xzf go.tar.gz \ - && rm go.tar.gz -RUN git clone https://github.com/volatilityfoundation/dwarf2json.git -WORKDIR /dwarf2json -RUN /usr/local/go/bin/go build - -FROM common-base AS go-builder-arm64 -RUN apt-get update && apt-get install -y curl gcc-aarch64-linux-gnu -RUN curl -Lo go.tar.gz https://dl.google.com/go/go1.22.0.linux-arm64.tar.gz \ - && tar -C /usr/local -xzf go.tar.gz \ - && rm go.tar.gz -RUN git clone https://github.com/volatilityfoundation/dwarf2json.git -WORKDIR /dwarf2json -RUN CC=aarch64-linux-gnu-gcc /usr/local/go/bin/go build +FROM common-base AS go-builder +ARG TARGETPLATFORM +RUN apt-get update && apt-get install -y curl +RUN echo "Building for platform: $TARGETPLATFORM" \ + && if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + curl -Lo go.tar.gz https://dl.google.com/go/go1.22.0.linux-amd64.tar.gz \ + && tar -C /usr/local -xzf go.tar.gz \ + && rm go.tar.gz \ + && git clone https://github.com/volatilityfoundation/dwarf2json.git \ + && cd dwarf2json \ + && /usr/local/go/bin/go build; \ + elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + curl -Lo go.tar.gz https://dl.google.com/go/go1.22.0.linux-arm64.tar.gz \ + && tar -C /usr/local -xzf go.tar.gz \ + && rm go.tar.gz \ + && apt-get install -y gcc-aarch64-linux-gnu \ + && git clone https://github.com/volatilityfoundation/dwarf2json.git \ + && cd dwarf2json \ + && CC=aarch64-linux-gnu-gcc /usr/local/go/bin/go build; \ + else \ + echo "Unsupported platform: $TARGETPLATFORM" && exit 1; \ + fi FROM common-base WORKDIR / @@ -79,8 +84,7 @@ COPY ./compose/local/django/start /start RUN sed -i 's/\r$//g' /start RUN chmod +x /start -COPY --from=go-builder-amd64 /dwarf2json/dwarf2json /dwarf2json/dwarf2json-amd64 -COPY --from=go-builder-arm64 /dwarf2json/dwarf2json /dwarf2json/dwarf2json-arm64 +COPY --from=go-builder /dwarf2json/dwarf2json /dwarf2json/dwarf2json COPY --from=yara-builder /tmp/yara-python/ /tmp/ WORKDIR /tmp