|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | +# |
| 3 | +# Invenio Base Docker Images |
| 4 | +# |
| 5 | +# Build targets: |
| 6 | +# docker build --target builder -t inveniosoftware/almalinux:1-builder . |
| 7 | +# docker build --target runtime -t inveniosoftware/almalinux:1-runtime . |
| 8 | +# docker build --target debug -t inveniosoftware/almalinux:1-debug . |
| 9 | +# |
| 10 | +# Copyright (C) 2018-2025 CERN. |
| 11 | +# Copyright (C) 2022 Graz University of Technology. |
| 12 | +# Copyright (C) 2022 University of Münster. |
| 13 | +# Copyright (C) 2023-2024 KTH Royal Institute of Technology. |
| 14 | +# |
| 15 | +# Invenio is free software; you can redistribute it and/or modify it |
| 16 | +# under the terms of the MIT License; see LICENSE file for more details. |
| 17 | + |
| 18 | +ARG LINUX_VERSION=9 |
| 19 | +ARG PYTHON_VERSION=3.14 |
| 20 | +ARG NODE_VERSION=22 |
| 21 | + |
| 22 | +# ============================================================================= |
| 23 | +# BASE: Common configuration shared by all variants |
| 24 | +# ============================================================================= |
| 25 | +FROM almalinux:${LINUX_VERSION} AS base |
| 26 | + |
| 27 | +ARG PYTHON_VERSION |
| 28 | + |
| 29 | +# Locale configuration |
| 30 | +RUN dnf install -y glibc-langpack-en && \ |
| 31 | + dnf clean all |
| 32 | + |
| 33 | +ENV LANG=en_US.UTF-8 \ |
| 34 | + LANGUAGE=en_US:en \ |
| 35 | + LC_ALL=en_US.UTF-8 |
| 36 | + |
| 37 | +# Python configuration |
| 38 | +ENV PYTHONUNBUFFERED=1 \ |
| 39 | + PYTHONDONTWRITEBYTECODE=1 \ |
| 40 | + PYTHONFAULTHANDLER=1 |
| 41 | + |
| 42 | +# Working directory structure |
| 43 | +ENV WORKING_DIR=/opt/invenio \ |
| 44 | + INVENIO_INSTANCE_PATH=/opt/invenio/var/instance |
| 45 | + |
| 46 | +# Create invenio user (UID 1000 for compatibility with common setups) |
| 47 | +ARG INVENIO_USER_ID=1000 |
| 48 | +RUN useradd --uid ${INVENIO_USER_ID} --gid 0 --create-home invenio |
| 49 | + |
| 50 | +# Create directory structure |
| 51 | +RUN mkdir -p ${WORKING_DIR}/src \ |
| 52 | + ${INVENIO_INSTANCE_PATH}/data \ |
| 53 | + ${INVENIO_INSTANCE_PATH}/archive \ |
| 54 | + ${INVENIO_INSTANCE_PATH}/static && \ |
| 55 | + chown -R invenio:0 ${WORKING_DIR} && \ |
| 56 | + chmod -R g=u ${WORKING_DIR} |
| 57 | + |
| 58 | +WORKDIR ${WORKING_DIR}/src |
| 59 | + |
| 60 | +# Install uv for Python management |
| 61 | +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/ |
| 62 | + |
| 63 | +# Install Python via uv (standalone builds, works for any version) |
| 64 | +ENV UV_PYTHON_INSTALL_DIR=/opt/python |
| 65 | +RUN uv python install ${PYTHON_VERSION} && \ |
| 66 | + ln -sfn $(uv python find ${PYTHON_VERSION}) /usr/local/bin/python && \ |
| 67 | + ln -sfn $(uv python find ${PYTHON_VERSION}) /usr/local/bin/python3 |
| 68 | + |
| 69 | +# uv configuration |
| 70 | +ENV UV_PYTHON=${PYTHON_VERSION} \ |
| 71 | + UV_COMPILE_BYTECODE=1 \ |
| 72 | + UV_LINK_MODE=copy |
| 73 | + |
| 74 | +# ============================================================================= |
| 75 | +# RUNTIME: Minimal production image with only runtime dependencies |
| 76 | +# ============================================================================= |
| 77 | +FROM base AS runtime |
| 78 | + |
| 79 | +ARG TARGETARCH |
| 80 | + |
| 81 | +# Enable EPEL and CRB for additional packages |
| 82 | +RUN dnf install -y dnf-plugins-core && \ |
| 83 | + dnf config-manager --set-enabled crb && \ |
| 84 | + dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \ |
| 85 | + dnf clean all |
| 86 | + |
| 87 | +# Install runtime-only system libraries |
| 88 | +# Note: These are the RUNTIME packages (no -devel suffix) |
| 89 | +RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=dnf-${TARGETARCH} \ |
| 90 | + dnf install -y --setopt=install_weak_deps=False \ |
| 91 | + # Runtime libraries (shared objects only, no headers) |
| 92 | + cairo \ |
| 93 | + libffi \ |
| 94 | + libpq \ |
| 95 | + libxml2 \ |
| 96 | + libxslt \ |
| 97 | + ImageMagick-libs \ |
| 98 | + openssl-libs \ |
| 99 | + bzip2-libs \ |
| 100 | + xz-libs \ |
| 101 | + sqlite-libs \ |
| 102 | + xmlsec1 \ |
| 103 | + xmlsec1-openssl \ |
| 104 | + # Fonts for PDF/image generation |
| 105 | + dejavu-sans-fonts \ |
| 106 | + # Git (often needed at runtime for editable installs) |
| 107 | + git |
| 108 | + |
| 109 | +# Labels |
| 110 | +LABEL org.opencontainers.image.title="Invenio Base (Runtime)" \ |
| 111 | + org.opencontainers.image.description="Minimal runtime image for Invenio applications" \ |
| 112 | + org.opencontainers.image.vendor="Invenio Software" \ |
| 113 | + org.opencontainers.image.licenses="MIT" |
| 114 | + |
| 115 | +# ============================================================================= |
| 116 | +# BUILDER: Full toolchain for compiling Python/Node.js packages |
| 117 | +# ============================================================================= |
| 118 | +FROM base AS builder |
| 119 | + |
| 120 | +ARG NODE_VERSION |
| 121 | +ARG TARGETARCH |
| 122 | + |
| 123 | +# Enable EPEL and CRB |
| 124 | +RUN dnf install -y dnf-plugins-core && \ |
| 125 | + dnf config-manager --set-enabled crb && \ |
| 126 | + dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \ |
| 127 | + dnf clean all |
| 128 | + |
| 129 | +# Install build tools and development libraries |
| 130 | +RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=dnf-${TARGETARCH} \ |
| 131 | + dnf install -y --setopt=install_weak_deps=False \ |
| 132 | + # Build essentials |
| 133 | + gcc \ |
| 134 | + gcc-c++ \ |
| 135 | + make \ |
| 136 | + pkgconf \ |
| 137 | + # Development libraries (headers + static libs for compilation) |
| 138 | + cairo-devel \ |
| 139 | + libffi-devel \ |
| 140 | + libpq-devel \ |
| 141 | + libxml2-devel \ |
| 142 | + libxslt-devel \ |
| 143 | + ImageMagick-devel \ |
| 144 | + openssl-devel \ |
| 145 | + bzip2-devel \ |
| 146 | + xz-devel \ |
| 147 | + sqlite-devel \ |
| 148 | + xmlsec1-devel \ |
| 149 | + xmlsec1-openssl-devel \ |
| 150 | + # Other build dependencies |
| 151 | + git \ |
| 152 | + # Fonts |
| 153 | + dejavu-sans-fonts |
| 154 | + |
| 155 | +# Install Node.js with npm for asset building |
| 156 | +RUN curl -fsSL https://rpm.nodesource.com/setup_${NODE_VERSION}.x | bash - && \ |
| 157 | + dnf install -y --setopt=install_weak_deps=False nodejs && \ |
| 158 | + dnf clean all && \ |
| 159 | + rm -rf /var/cache/dnf && \ |
| 160 | + corepack enable |
| 161 | + |
| 162 | +# Labels |
| 163 | +LABEL org.opencontainers.image.title="Invenio Base (Builder)" \ |
| 164 | + org.opencontainers.image.description="Full toolchain for building Invenio applications" \ |
| 165 | + org.opencontainers.image.vendor="Invenio Software" \ |
| 166 | + org.opencontainers.image.licenses="MIT" |
| 167 | + |
| 168 | +# ============================================================================= |
| 169 | +# DEBUG: Runtime + debugging/inspection tools |
| 170 | +# ============================================================================= |
| 171 | +FROM runtime AS debug |
| 172 | + |
| 173 | +ARG TARGETARCH |
| 174 | + |
| 175 | +# Install debugging and inspection tools |
| 176 | +RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=dnf-${TARGETARCH} \ |
| 177 | + dnf install -y --allowerasing --setopt=install_weak_deps=False \ |
| 178 | + # Process inspection |
| 179 | + procps-ng \ |
| 180 | + htop \ |
| 181 | + strace \ |
| 182 | + lsof \ |
| 183 | + # File inspection |
| 184 | + file \ |
| 185 | + less \ |
| 186 | + vim-minimal \ |
| 187 | + # Disk/IO monitoring |
| 188 | + iotop \ |
| 189 | + iftop \ |
| 190 | + # Network debugging |
| 191 | + tcpdump \ |
| 192 | + bind-utils \ |
| 193 | + net-tools \ |
| 194 | + curl \ |
| 195 | + wget |
| 196 | + |
| 197 | +LABEL org.opencontainers.image.title="Invenio Base (Debug)" \ |
| 198 | + org.opencontainers.image.description="Runtime image with debugging tools for troubleshooting" \ |
| 199 | + org.opencontainers.image.vendor="Invenio Software" \ |
| 200 | + org.opencontainers.image.licenses="MIT" |
0 commit comments