diff --git a/Dockerfile b/Dockerfile index 2481d44..ee49672 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,77 +1,123 @@ -FROM ubuntu:bionic +FROM ubuntu:24.04 -MAINTAINER Matthew Feickert +LABEL maintainer="Alessandro Hecht " USER root WORKDIR /root SHELL [ "/bin/bash", "-c" ] -ARG PYTHON_VERSION_TAG=3.8.3 -ARG LINK_PYTHON_TO_PYTHON3=1 +ARG PYTHON_VERSION_TAG=3.10.16 +ARG LINK_PYTHON_TO_PYTHON3=0 +ARG TARGETPLATFORM -# Existing lsb_release causes issues with modern installations of Python3 -# https://github.com/pypa/pip/issues/4924#issuecomment-435825490 -# Set (temporarily) DEBIAN_FRONTEND to avoid interacting with tzdata -RUN apt-get -qq -y update && \ - DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \ - gcc \ - g++ \ - zlibc \ - zlib1g-dev \ - libssl-dev \ +# Instalação de pacotes essenciais e dependências, remoção de pacotes desnecessários e arquivos de cache +RUN set -ex \ + && apt-get -qq -y update --fix-missing \ + && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install --no-install-recommends \ + build-essential \ + gdb \ + lcov \ + yasm \ + pkg-config \ libbz2-dev \ - libsqlite3-dev \ - libncurses5-dev \ + libffi-dev \ libgdbm-dev \ libgdbm-compat-dev \ liblzma-dev \ - libreadline-dev \ - uuid-dev \ - libffi-dev \ + libncurses5-dev \ + libreadline6-dev \ + libsqlite3-dev \ + libssl-dev \ + lzma \ + lzma-dev \ tk-dev \ + uuid-dev \ + zlib1g-dev \ + unzip \ + libcairo2-dev \ + chromium-browser \ wget \ curl \ git \ - make \ sudo \ bash-completion \ tree \ vim \ - software-properties-common && \ - mv /usr/bin/lsb_release /usr/bin/lsb_release.bak && \ - apt-get -y autoclean && \ - apt-get -y autoremove && \ - rm -rf /var/lib/apt-get/lists/* + gdal-bin \ + default-libmysqlclient-dev \ + mysql-client \ + libmagic1 \ + libmediainfo-dev \ + jpegoptim \ + optipng \ + gettext \ + software-properties-common \ + ffmpeg \ + && mv /usr/bin/lsb_release /usr/bin/lsb_release.bak \ + && apt-get -y autoclean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* + +# linux/arm64 - Adiciona arquitetura amd64, configura fontes e instala pacotes +RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + dpkg --add-architecture amd64 && \ + printf "Types: deb\n\ +URIs: http://archive.ubuntu.com/ubuntu/\n\ +Suites: noble noble-updates noble-backports\n\ +Components: main universe restricted multiverse\n\ +Architectures: amd64\n\ +Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n\n\ +## Ubuntu security updates. Aside from URIs and Suites,\n\ +## this should mirror your choices in the previous section.\n\ +Types: deb\n\ +URIs: http://archive.ubuntu.com/ubuntu/\n\ +Suites: noble-security\n\ +Components: main universe restricted multiverse\n\ +Architectures: amd64\n\ +Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n" \ + > /etc/apt/sources.list.d/ubuntu_amd64.sources && \ + apt-get -qq -y update --fix-missing || true && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + libc6:amd64 \ + libstdc++6:amd64 \ + zlib1g:amd64 \ + libglib2.0-0:amd64 \ + libnss3:amd64 \ + libx11-6:amd64 && \ + rm -rf /var/lib/apt/lists/*; \ + fi +# Instalação do Python usando script customizado COPY install_python.sh install_python.sh -RUN bash install_python.sh ${PYTHON_VERSION_TAG} ${LINK_PYTHON_TO_PYTHON3} && \ - rm -r install_python.sh Python-${PYTHON_VERSION_TAG} +RUN bash install_python.sh ${PYTHON_VERSION_TAG} ${LINK_PYTHON_TO_PYTHON3} \ + && rm -rf install_python.sh Python-${PYTHON_VERSION_TAG} -# Enable tab completion by uncommenting it from /etc/bash.bashrc -# The relevant lines are those below the phrase "enable bash completion in interactive shells" -RUN export SED_RANGE="$(($(sed -n '\|enable bash completion in interactive shells|=' /etc/bash.bashrc)+1)),$(($(sed -n '\|enable bash completion in interactive shells|=' /etc/bash.bashrc)+7))" && \ - sed -i -e "${SED_RANGE}"' s/^#//' /etc/bash.bashrc && \ - unset SED_RANGE +# Habilita o bash completion +RUN export SED_RANGE="$(($(sed -n '\|enable bash completion in interactive shells|=' /etc/bash.bashrc)+1)),$(($(sed -n '\|enable bash completion in interactive shells|=' /etc/bash.bashrc)+7))" \ + && sed -i -e "${SED_RANGE}"' s/^#//' /etc/bash.bashrc \ + && unset SED_RANGE -# Create user "docker" with sudo powers -RUN useradd -m docker && \ - usermod -aG sudo docker && \ - echo '%sudo ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \ - cp /root/.bashrc /home/docker/ && \ - mkdir /home/docker/data && \ - chown -R --from=root docker /home/docker +# Cria o usuário "docker" com permissões sudo +RUN useradd -m docker \ + && usermod -aG sudo docker \ + && echo '%sudo ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers \ + && cp /root/.bashrc /home/docker/ \ + && mkdir /home/docker/data \ + && chown -R docker:docker /home/docker -# Use C.UTF-8 locale to avoid issues with ASCII encoding +# Configurações de locale ENV LC_ALL=C.UTF-8 ENV LANG=C.UTF-8 +# Configurações finais e preparação do ambiente do usuário "docker" WORKDIR /home/docker/data -ENV HOME /home/docker -ENV USER docker +ENV HOME=/home/docker +ENV USER=docker USER docker -ENV PATH /home/docker/.local/bin:$PATH -# Avoid first use of sudo warning. c.f. https://askubuntu.com/a/22614/781671 +ENV PATH=/home/docker/.local/bin:$PATH + +# Evita o aviso de primeiro uso do sudo RUN touch $HOME/.sudo_as_admin_successful CMD [ "/bin/bash" ] diff --git a/Makefile b/Makefile deleted file mode 100644 index 93a13b2..0000000 --- a/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -default: image - -all: image py_3.8.3 py_3.8.1 py_3.8.0 py_3.7.4 py_3.6.8 - -image: - docker build . \ - -f Dockerfile \ - --cache-from matthewfeickert/docker-python3-ubuntu:latest \ - --build-arg PYTHON_VERSION_TAG=3.8.3 \ - --build-arg LINK_PYTHON_TO_PYTHON3=1 \ - -t matthewfeickert/docker-python3-ubuntu:latest \ - -t matthewfeickert/docker-python3-ubuntu:3.8.3 \ - --compress - -py_3.8.3: - docker build . \ - -f Dockerfile \ - --cache-from matthewfeickert/docker-python3-ubuntu:latest \ - --build-arg PYTHON_VERSION_TAG=3.8.3 \ - --build-arg LINK_PYTHON_TO_PYTHON3=1 \ - -t matthewfeickert/docker-python3-ubuntu:latest \ - -t matthewfeickert/docker-python3-ubuntu:3.8.3 \ - --compress - -py_3.8.1: - docker build -f Dockerfile \ - --cache-from matthewfeickert/docker-python3-ubuntu:latest \ - --build-arg PYTHON_VERSION_TAG=3.8.1 \ - --build-arg LINK_PYTHON_TO_PYTHON3=1 \ - -t matthewfeickert/docker-python3-ubuntu:latest \ - -t matthewfeickert/docker-python3-ubuntu:3.8.1 \ - --compress . - -py_3.8.0: - docker build -f Dockerfile \ - --cache-from matthewfeickert/docker-python3-ubuntu:latest \ - --build-arg PYTHON_VERSION_TAG=3.8.0 \ - --build-arg LINK_PYTHON_TO_PYTHON3=1 \ - -t matthewfeickert/docker-python3-ubuntu:latest \ - -t matthewfeickert/docker-python3-ubuntu:3.8.0 \ - --compress . - -py_3.7.4: - docker build -f Dockerfile \ - --cache-from matthewfeickert/docker-python3-ubuntu:3.7.4 \ - --build-arg PYTHON_VERSION_TAG=3.7.4 \ - --build-arg LINK_PYTHON_TO_PYTHON3=1 \ - -t matthewfeickert/docker-python3-ubuntu:3.7.4 \ - --compress . - -py_3.6.8: - docker build -f Dockerfile \ - --cache-from matthewfeickert/docker-python3-ubuntu:3.6.8 \ - --build-arg PYTHON_VERSION_TAG=3.6.8 \ - --build-arg LINK_PYTHON_TO_PYTHON3=1 \ - -t matthewfeickert/docker-python3-ubuntu:3.6.8 \ - --compress . diff --git a/install_python.sh b/install_python.sh index 6ab7cb6..27c16d2 100644 --- a/install_python.sh +++ b/install_python.sh @@ -35,29 +35,17 @@ function build_cpython () { printf "\n### ./configure --help\n" ./configure --help printf "\n### ./configure\n" - if [[ "${2}" > "3.7.0" ]]; then - # --with-threads is removed in Python 3.7 (threading already on) - ./configure --prefix="${1}" \ - --exec_prefix="${1}" \ - --with-ensurepip \ - --enable-optimizations \ - --with-lto \ - --enable-loadable-sqlite-extensions \ - --enable-ipv6 - else - ./configure --prefix="${1}" \ - --exec_prefix="${1}" \ - --with-ensurepip \ - --enable-optimizations \ - --with-lto \ - --enable-loadable-sqlite-extensions \ - --enable-ipv6 \ - --with-threads - fi + ./configure --prefix="${1}" \ + --exec_prefix="${1}" \ + --with-ensurepip \ + --enable-optimizations \ + --with-lto \ + --enable-loadable-sqlite-extensions \ + --enable-ipv6 \ + --enable-shared + printf "\n### make -j%s\n" "${NPROC}" make -j"${NPROC}" - printf "\n### make -j%s test\n" "${NPROC}" - make -j"${NPROC}" test printf "\n### make install\n" make install } @@ -66,11 +54,11 @@ function update_pip { # Update pip, setuptools, and wheel if [[ "$(id -u)" -eq 0 ]]; then # If root - printf "\n### pip3 install --upgrade --no-cache-dir pip setuptools wheel\n" - pip3 install --upgrade --no-cache-dir pip setuptools wheel + printf "\n### pip3 install --upgrade --no-cache-dir pip setuptools wheel virtualenv\n" + pip3 install --upgrade --no-cache-dir pip setuptools wheel virtualenv else - printf "\n### pip3 install --user --upgrade --no-cache-dir pip setuptools wheel\n" - pip3 install --user --upgrade --no-cache-dir pip setuptools wheel + printf "\n### pip3 install --user --upgrade --no-cache-dir pip setuptools wheel virtualenv\n" + pip3 install --user --upgrade --no-cache-dir pip setuptools wheel virtualenv fi } @@ -101,7 +89,7 @@ function main() { # 1: the Python version tag # 2: bool of if should symlink python and pip to python3 versions - PYTHON_VERSION_TAG=3.8.1 + PYTHON_VERSION_TAG=3.10.13 LINK_PYTHON_TO_PYTHON3=0 # By default don't link so as to reserve python for Python 2 if [[ $# -gt 0 ]]; then PYTHON_VERSION_TAG="${1}"