From 16a02432e63d2e7a4a82cbf6490560dfa2c8e8f6 Mon Sep 17 00:00:00 2001 From: Humberto Dias Date: Wed, 3 Apr 2024 17:14:23 -0300 Subject: [PATCH] docker multi-stage image --- Dockerfile | 58 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/Dockerfile b/Dockerfile index 21b7ed3b..a57136b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -FROM ubuntu:24.04 -LABEL maintainer="miigotu@gmail.com" +FROM ubuntu:22.04 as builder # Set the default shell to Bash SHELL ["/bin/bash", "-c"] @@ -7,38 +6,41 @@ SHELL ["/bin/bash", "-c"] ENV PS3DEV /usr/local/ps3dev ENV PSL1GHT ${PS3DEV} ENV PATH ${PATH}:${PS3DEV}/bin:${PS3DEV}/ppu/bin:${PS3DEV}/spu/bin:${PS3DEV}/portlibs/ppu/bin -ENV PKG_CONFIG_PATH $PS3DEV/portlibs/ppu/lib/pkgconfig +ENV PKG_CONFIG_PATH ${PS3DEV}/portlibs/ppu/lib/pkgconfig ENV DEBIAN_FRONTEND=noninteractive # last python version with diskutils module support ENV PYTHON_VERSION=3.10 -ENV PYENV_ROOT="$HOME/.pyenv" +ENV PYENV_ROOT ${HOME}/.pyenv ENV PIP_ROOT_USER_ACTION=ignore -ENV PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH" +ENV PATH ${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:$PATH -RUN \ - apt -y update && \ - apt --no-install-recommends install -y autoconf automake bison build-essential bzip2 \ - ca-certificates cmake flex gettext-base git libelf-dev libgmp3-dev libncurses5-dev libssl-dev \ - libtool libtool-bin make patch pkg-config texinfo wget xz-utils zlib1g-dev nvidia-cg-toolkit && \ - # Install dependencies specific for amd64 architecture - if [ "$(uname -m)" = "x86_64" ]; then apt install -y nvidia-cg-toolkit ; fi ; \ - # pyenv - apt --no-install-recommends install -y zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \ - llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev curl && \ - curl https://pyenv.run | bash && \ - pyenv update && \ - pyenv install $PYTHON_VERSION && \ - pyenv global $PYTHON_VERSION && \ - pyenv rehash && \ - pip install pycrypto && \ - # pyenv - apt -y clean autoclean autoremove - -RUN mkdir /build +RUN apt update -y && \ + apt --no-install-recommends install -y autoconf automake bison build-essential bzip2 \ + ca-certificates cmake flex gettext-base git libelf-dev libgmp3-dev libncurses5-dev libssl-dev \ + libtool libtool-bin make patch pkg-config texinfo wget xz-utils zlib1g-dev && \ + # Fixes certificate errors with letsencrypt in ARMv7 + echo 'ca_certificate=/etc/ssl/certs/ca-certificates.crt' >> /etc/wgetrc && \ + # Install dependencies specific for amd64 architecture + if [ "$(uname -m)" = "x86_64" ]; then apt install -y nvidia-cg-toolkit ; fi && \ + # pyenv + apt --no-install-recommends install -y zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \ + llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev curl git && \ + echo 'cacert=/etc/ssl/certs/ca-certificates.crt' >> ~/.curlrc && \ + git config --global http.sslverify 'false' && \ + curl https://pyenv.run | bash && \ + pyenv update && pyenv install $PYTHON_VERSION && pyenv global $PYTHON_VERSION && pyenv rehash && \ + pip install pycrypto && \ + # pyenv + apt -y clean autoclean autoremove && \ + mkdir /build WORKDIR /build COPY . /build +RUN /build/toolchain.sh -# Fixes certificate errors with letsencrypt in ARMv7 -RUN echo "ca_certificate=/etc/ssl/certs/ca-certificates.crt" >> /etc/wgetrc -RUN /build/toolchain.sh && rm -rf /build/build +FROM ubuntu:22.04 as runtime +ENV PS3DEV /usr/local/ps3dev +ENV PSL1GHT ${PS3DEV} +ENV PATH ${PATH}:${PS3DEV}/bin:${PS3DEV}/ppu/bin:${PS3DEV}/spu/bin:${PS3DEV}/portlibs/ppu/bin +ENV PKG_CONFIG_PATH ${PS3DEV}/portlibs/ppu/lib/pkgconfig +COPY --from=builder ${PS3DEV} ${PS3DEV} \ No newline at end of file