Repository: google/turbinia (language: python)

Issue:
[FR]: Support Ubuntu 24.04 LTS docker containers
### What is the feature you are proposing?

Ubuntu 24.04 LTS has been released, we may want to test things out with containers using 24.04

### What would this feature improve or what problem would it solve?

Maintainability

### What alternatives have you considered?

_No response_


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml
index 66ab1d290..de80b078e 100644
--- a/.github/workflows/actions.yml
+++ b/.github/workflows/actions.yml
@@ -9,7 +9,7 @@ jobs:
     strategy:
       matrix:
         os:
-          - ubuntu-22.04
+          - ubuntu-24.04
         gift_ppa_track: ["staging", "stable"]
     steps:
       - name: checkout
diff --git a/docker/api_server/Dockerfile b/docker/api_server/Dockerfile
index f82886c46..503e6062e 100644
--- a/docker/api_server/Dockerfile
+++ b/docker/api_server/Dockerfile
@@ -7,16 +7,14 @@ COPY web/. .
 RUN npm run build
 
 # Build Turbinia API Server, copy from build, and setup rest of requirements
-FROM --platform=linux/amd64 ubuntu:22.04 as build-stage2
+FROM --platform=linux/amd64 ubuntu:24.04 as build-stage2
 
 ENV DEBIAN_FRONTEND=noninteractive \
     PIP_NO_CACHE_DIR=1 
 
 COPY --from=build-stage /tmp/web/dist /web/dist
 RUN apt-get update && apt-get -y upgrade
-RUN apt-get -y install git python3-pip
-RUN pip3 install pip --upgrade
-RUN pip3 install poetry
+RUN apt-get -y install git python3-pip python3.12-venv
 
 RUN useradd -r -s /sbin/nologin -u 999 turbinia
 RUN mkdir /etc/turbinia && mkdir -p /mnt/turbinia/ && mkdir -p /var/lib/turbinia/ \
@@ -31,13 +29,16 @@ RUN mkdir /etc/turbinia && mkdir -p /mnt/turbinia/ && mkdir -p /var/lib/turbinia
 USER turbinia
 WORKDIR /home/turbinia
 
+# Install poetry
+RUN python3 -m venv .venv
+ENV PATH="/home/turbinia/.local/bin:/home/turbinia/.venv/bin:$PATH" \
+    VIRTUAL_ENV=/home/turbinia/.venv
+RUN python3 -m pip install poetry
+
 # Copy requirements and install dependencies to cache them in docker layer
 COPY --chown=turbinia:turbinia ./pyproject.toml ./poetry.toml ./poetry.lock /home/turbinia/
 RUN poetry install --no-interaction --no-ansi --no-root
 
-ENV PATH="/home/turbinia/.venv/bin:$PATH" \
-    VIRTUAL_ENV=/home/turbinia/.venv
-
 # Copy the source directory to the container
 COPY --chown=turbinia:turbinia . /home/turbinia/
 COPY --chown=turbinia:turbinia docker/api_server/start.sh /home/turbinia/start.sh
diff --git a/docker/oauth2_proxy/Dockerfile b/docker/oauth2_proxy/Dockerfile
index 757053a52..ac6648ed8 100644
--- a/docker/oauth2_proxy/Dockerfile
+++ b/docker/oauth2_proxy/Dockerfile
@@ -1,4 +1,4 @@
-FROM ubuntu:20.04
+FROM ubuntu:24.04
 
 ENV DEBIAN_FRONTEND=noninteractive 
 RUN apt-get update && apt-get -y upgrade
diff --git a/docker/server/Dockerfile b/docker/server/Dockerfile
index dced48cad..0b9b3dbd9 100644
--- a/docker/server/Dockerfile
+++ b/docker/server/Dockerfile
@@ -1,4 +1,4 @@
-FROM --platform=linux/amd64 ubuntu:22.04
+FROM --platform=linux/amd64 ubuntu:24.04
 
 ENV DEBIAN_FRONTEND=noninteractive 
 ENV PIP_NO_CACHE_DIR=1
@@ -9,13 +9,11 @@ RUN apt-get update && apt-get -y upgrade && apt-get -y install \
     git \
     libterm-readline-gnu-perl \
     python3-pip \
+    python3.12-venv \
     software-properties-common \
     sudo \
     && apt-get clean && rm -rf /var/cache/apt/* /var/lib/apt/lists/*
 
-RUN pip3 install pip --upgrade
-RUN pip3 install poetry
-
 RUN useradd -r -s /sbin/nologin -u 999 turbinia
 
 RUN mkdir /etc/turbinia && mkdir -p /mnt/turbinia/ && mkdir -p /var/lib/turbinia/ \
@@ -30,13 +28,16 @@ RUN mkdir /etc/turbinia && mkdir -p /mnt/turbinia/ && mkdir -p /var/lib/turbinia
 USER turbinia
 WORKDIR /home/turbinia
 
+# Install poetry
+RUN python3 -m venv .venv
+ENV PATH="/home/turbinia/.local/bin:/home/turbinia/.venv/bin:$PATH" \
+    VIRTUAL_ENV=/home/turbinia/.venv
+RUN python3 -m pip install poetry
+
 # Copy requirements and install dependencies to cache them in docker layer
 COPY --chown=turbinia:turbinia ./pyproject.toml ./poetry.toml ./poetry.lock /home/turbinia/
 RUN poetry install --no-interaction --no-ansi --no-root
 
-ENV PATH="/home/turbinia/.venv/bin:$PATH" \
-    VIRTUAL_ENV=/home/turbinia/.venv
-
 # Copy the source directory to the container
 COPY --chown=turbinia:turbinia . /home/turbinia/
 COPY --chown=turbinia:turbinia docker/server/start.sh /home/turbinia/start.sh
diff --git a/docker/worker/Dockerfile b/docker/worker/Dockerfile
index 58bac52d8..d12352ca1 100644
--- a/docker/worker/Dockerfile
+++ b/docker/worker/Dockerfile
@@ -1,5 +1,5 @@
 # Build 1 - Turbinia Worker
-FROM --platform=linux/amd64 ubuntu:22.04
+FROM --platform=linux/amd64 ubuntu:24.04
 ENV DEBIAN_FRONTEND=noninteractive \
     PIP_NO_CACHE_DIR=1
 ARG PPA_TRACK=stable
@@ -20,15 +20,13 @@ RUN apt-get update && apt-get -y upgrade && apt-get -y install \
     pocl-opencl-icd \
     p7zip-full \
     python3-pip \
+    python3.12-venv \
     software-properties-common \
     sudo \
     testdisk \
     wget \
     && apt-get clean && rm -rf /var/cache/apt/* /var/lib/apt/lists/*
 
-RUN pip3 install pip --upgrade
-RUN pip3 install poetry
-
 # Install various packages from the GIFT PPA
 #   bulkextractor
 #   docker-explorer
@@ -104,12 +102,16 @@ COPY --chown=turbinia:turbinia k8s/tools/check-lockfile.py /home/turbinia/check-
 USER turbinia
 WORKDIR /home/turbinia
 
+# Install poetry
+RUN python3 -m venv .venv
+ENV PATH="/home/turbinia/.local/bin:/home/turbinia/.venv/bin:$PATH" \
+    VIRTUAL_ENV=/home/turbinia/.venv
+RUN python3 -m pip install poetry
+
 # Copy requirements and install dependencies to cache them in docker layer
 COPY --chown=turbinia:turbinia ./pyproject.toml ./poetry.toml ./poetry.lock /home/turbinia/
 RUN poetry install --no-interaction --no-ansi -E worker --no-root
 RUN poetry run pip3 install impacket --no-deps 
-ENV PATH="/home/turbinia/.venv/bin:$PATH" \
-    VIRTUAL_ENV=/home/turbinia/.venv
 
 # Copy the source directory to the container
 COPY --chown=turbinia:turbinia . /home/turbinia/


Test patch:
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index 7e0576c35..6e08abee9 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -8,7 +8,7 @@ jobs:
     strategy:
       matrix:
         os:
-          - ubuntu-22.04
+          - ubuntu-24.04
         gift_ppa_track: ["staging", "stable"]
     runs-on: ${{ matrix.os }}
     steps:
diff --git a/docker/tests/Dockerfile b/docker/tests/Dockerfile
index fb4de11eb..b8acb52a9 100644
--- a/docker/tests/Dockerfile
+++ b/docker/tests/Dockerfile
@@ -1,4 +1,4 @@
-FROM --platform=linux/amd64 ubuntu:22.04
+FROM --platform=linux/amd64 ubuntu:24.04
 ENV DEBIAN_FRONTEND=noninteractive \
     PIP_NO_CACHE_DIR=1 
 ARG PPA_TRACK=stable
@@ -22,7 +22,7 @@ RUN apt-get update && apt-get -y upgrade && apt-get -y install \
     p7zip-full \
     pkg-config \
     python3-pip \
-    python3.10-venv \
+    python3.12-venv \
     software-properties-common \
     sudo \
     testdisk \
@@ -30,11 +30,6 @@ RUN apt-get update && apt-get -y upgrade && apt-get -y install \
     wget \
     && apt-get clean && rm -rf /var/cache/apt/* /var/lib/apt/lists/*
 
-# Install Poetry
-RUN pip3 install pip --upgrade
-RUN pip3 install poetry
-RUN pip3 install -U packaging
-
 # Install various packages from the GIFT PPA
 #   bulkextractor
 #   docker-explorer
@@ -70,6 +65,14 @@ RUN wget -O /tmp/container-explorer-setup.sh https://raw.githubusercontent.com/g
 RUN chmod +x /tmp/container-explorer-setup.sh
 RUN sudo /tmp/container-explorer-setup.sh install
 
+# Install docker CLI
+RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
+RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
+RUN apt-get update
+RUN apt-get -y install docker-ce-cli
+RUN groupadd docker
+RUN usermod -aG docker turbinia
+
 # Setup turbinia user folders and permissions
 RUN mkdir /etc/turbinia && mkdir -p /mnt/turbinia/ && mkdir -p /var/lib/turbinia/ \
     && mkdir -p /etc/turbinia/ && chown -R turbinia:turbinia /etc/turbinia/ \
@@ -103,18 +106,21 @@ WORKDIR /home/turbinia
 # Copy only requirements, to cache them in docker layer
 COPY --chown=turbinia:turbinia ./pyproject.toml ./poetry.toml ./poetry.lock /home/turbinia/
 
+# Install poetry
+RUN python3 -m venv .venv
+ENV PATH="/home/turbinia/.local/bin:/home/turbinia/.venv/bin:$PATH" \
+    VIRTUAL_ENV=/home/turbinia/.venv
+RUN python3 -m pip install poetry
+
 # Install dependencies using Poetry
 RUN poetry install --no-interaction --no-ansi -E worker --with test --no-root
 RUN poetry run python3 -m pip install impacket --no-deps
 
-# Activate the virtualenv
-ENV PATH="/home/turbinia/.venv/bin:$PATH" \
-    VIRTUAL_ENV=/home/turbinia/.venv
+# Copy the source directory to the container
+COPY --chown=turbinia:turbinia . /home/turbinia/
 
-# Install Turbinia and dependencies in /home/turbinia/.venv using Poetry
-ADD . /home/turbinia/
-# RUN if $(cd /tmp/ && git rev-parse --is-shallow-repository); then cd /tmp/ && git fetch --prune --unshallow && git fetch --depth=1 origin +refs/tags/*:refs/tags/*; fi
 RUN poetry install --no-interaction --no-ansi -E worker --with test
+
 # We need to install the current dev version of turbinia-api-lib for the cli tool test in case the API client changes
 RUN cd turbinia/api/client && poetry install
 CMD ["/bin/bash"]