Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
garanews authored Aug 7, 2024
1 parent 6375f6a commit 719be50
Showing 1 changed file with 32 additions and 52 deletions.
84 changes: 32 additions & 52 deletions compose/local/django/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,75 +1,59 @@
# syntax=docker/dockerfile:1.3
FROM --platform=$BUILDPLATFORM python:3.12-slim-bookworm AS common-base
ARG TARGETARCH
FROM python:3.12.4-slim-bookworm as common-base

ENV DJANGO_SETTINGS_MODULE=config.settings.local
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV DJANGO_SETTINGS_MODULE config.settings.local
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1

ARG local_folder=/uploads

RUN apt-get update \
# dependencies for building Python packages
&& apt-get install -y --no-install-recommends build-essential \
# ldap
libsasl2-dev python3-dev libldap2-dev libssl-dev \
libpq-dev libmagic1 p7zip-full gettext git \
# psycopg2 dependencies
libpq-dev \
# archive
libmagic1 p7zip-full \
# Translations dependencies
gettext \
# git for cloning
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# App running in /app
RUN mkdir -p /app

FROM common-base AS base-builder
FROM common-base as base-builder
RUN apt-get update \
&& apt-get install --no-install-recommends -y curl unzip \
automake libtool make gcc pkg-config flex bison libssl-dev libjansson-dev libmagic-dev \
&& apt-get install --no-install-recommends -y \
# utils
curl unzip \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*

FROM base-builder AS yara-builder
WORKDIR /tmp
RUN git clone --recursive https://github.com/VirusTotal/yara.git
WORKDIR /tmp/yara
RUN ./bootstrap.sh \
&& ./configure --enable-cuckoo --enable-magic --enable-dotnet --with-crypto \
&& make \
&& make install \
&& echo "Install yara-python..."
WORKDIR /tmp
RUN git clone --branch v4.3.x --recursive https://github.com/VirusTotal/yara-python
WORKDIR /tmp/yara-python
RUN python setup.py build

FROM common-base AS go-builder
ARG TARGETARCH
RUN apt-get update && apt-get install -y curl
RUN echo "Building for platform: $TARGETARCH" \
&& if [ "$TARGETARCH" = "amd64" ]; then \
apt-get install -y gcc-multilib \
&& 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 \
&& CC=gcc /usr/local/go/bin/go build; \
elif [ "$TARGETARCH" = "arm64" ]; then \
apt-get install -y gcc-aarch64-linux-gnu \
&& 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 \
&& 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: $TARGETARCH" && exit 1; \
fi
FROM golang:alpine3.20 as go-builder
RUN apk add git
WORKDIR /
RUN git clone https://github.com/volatilityfoundation/dwarf2json.git
WORKDIR /dwarf2json
RUN /usr/local/go/bin/go build

FROM common-base
WORKDIR /
COPY ./requirements /requirements
RUN pip install uv==0.1.21 -e git+https://github.com/volatilityfoundation/volatility3.git@55dd39f2ba60ffdd2126b7ea011940f0df42815a#egg=volatility3 \
RUN pip install uv==0.2.31 -e git+https://github.com/dadokkio/volatility3.git@f740146f692ba288f376a939b24b1c1a8f7cf5e2#egg=volatility3 \
&& uv pip install --no-cache --system -r /requirements/base.txt

COPY ./compose/local/__init__.py /src/volatility3/volatility3/framework/constants/__init__.py

#EXPERIMENTAL SUPPORT FOR ARM64
COPY ./compose/local/linux.py /src/volatility3/volatility3/framework/automagic/linux.py
COPY ./compose/local/arm.py /src/volatility3/volatility3/framework/layers/arm.py
RUN sed -i 's/\["Intel32", "Intel64"\]/\["Intel32", "Intel64", "AArch64"\]/g' /src/volatility3/volatility3/framework/plugins/linux/*.py

RUN mkdir -p $local_folder /maxmind
COPY ./compose/local/maxmind /maxmind

Expand All @@ -85,9 +69,5 @@ RUN chmod +x /start

COPY --from=go-builder /dwarf2json/dwarf2json /dwarf2json/dwarf2json

COPY --from=yara-builder /tmp/yara-python/ /tmp/
WORKDIR /tmp
RUN python setup.py install

WORKDIR /app
ENTRYPOINT ["/entrypoint"]

0 comments on commit 719be50

Please sign in to comment.