syntax=docker/dockerfile:experimental FROM python:3.9.17 ENV LANG C.UTF-8 USER root ARG…
- User
syntax=docker/dockerfile:experimental
FROM python:3.9.17
ENV LANG C.UTF-8
USER root ARG HOME=/root
ENV DEBIAN_FRONTEND=noninteractive RUN apt update
&& apt install --assume-yes
gcc
ffmpeg
libsm6
libxext6
git
curlNOTE required to be yes
ARG POETRY_INCLUDE="yes" ENV POETRY_INCLUDE={POETRY_VERSION} RUN [ "{PATH}:{POETRY_VERSION}
&& poetry config virtualenvs.in-project trueARG RCLONE_INCLUDE="no" ENV RCLONE_INCLUDE={RCLONE_VERSION} RUN [ "{RCLONE_VERSION}/rclone-v{RCLONE_VERSION}-linux-amd64.zip \ && unzip -a "rclone-v{RCLONE_VERSION}-linux-amd64.zip"
&& cp "rclone-v{RCLONE_VERSION}-linux-amd64/rclone" /usr/bin/rclone.new \ && chmod 755 /usr/bin/rclone.new \ && chown root:root /usr/bin/rclone.new \ && mv /usr/bin/rclone.new /usr/bin/rclone \ && rm -r "rclone-v{RCLONE_VERSION}-linux-amd64"
)WORKDIR /app
COPY bootstrap bootstrap
ONBUILD COPY pyproject.toml . ONBUILD COPY poetry.lock . ONBUILD RUN --mount=type=ssh --mount=type=secret,id=nextml-packagr-token
mkdir ~/.ssh && chmod 700 ~/.ssh
&& ssh-keyscan github.com >> ~/.ssh/known_hosts
&& poetry config http-basic.nextml token $(cat /run/secrets/nextml-packagr-token)
&& poetry install --no-root --only main
&& poetry config --unset http-basic.nextml
&& rm -rf ~/.cache/pypoetry/* ~/.cache/pip/*ONBUILD COPY app app
ENTRYPOINT [ "bash", "bootstrap/bin", "poetry", "run", "python", "-m", "app.main" ]
- Assistant
This Dockerfile sets up a Python environment with various dependencies. Let's break down the different parts:
-
Base image: The base image is the official Python 3.9.17 image.
-
Environment variables: The
LANGenvironment variable is set to C.UTF-8. -
User and home directory: The user is set to root and the home directory is set to
/root. -
Package installation: The following packages are installed using
apt-get: gcc, ffmpeg, libsm6, libxext6, git, and curl. -
Poetry installation: The Poetry package manager is installed. The version of Poetry can be specified using the
POETRY_VERSIONbuild argument. ThePOETRY_INCLUDEbuild argument determines whether Poetry should be installed or not. -
Rclone installation: Rclone, a command-line tool for cloud storage synchronization, is installed. The version of Rclone can be specified using the
RCLONE_VERSIONbuild argument. TheRCLONE_INCLUDEbuild argument determines whether Rclone should be installed or not. -
Working directory: The working directory is set to
/app. -
Copying the bootstrap script: The
bootstrapdirectory is copied to the/appdirectory. -
Onbuild instructions: These instructions are executed when a child image is built on top of this image. It copies the
pyproject.tomlandpoetry.lockfiles, sets up SSH configuration, installs the Python dependencies specified inpyproject.tomlusing Poetry, and cleans up the cache directories. -
Copying the app directory: The
appdirectory is copied to the/appdirectory. -
Entrypoint: The entrypoint is set to run the
app.mainmodule using Poetry.
Overall, this Dockerfile sets up a Python environment with Poetry and Rclone, installs Python dependencies using Poetry, and provides an entrypoint to run the application's main module.
-