Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

3.6 KB
Raw Blame
# syntax=docker/dockerfile:1

FROM docker.io/library/fedora:45

# We want to keep all important things in `/opt` as we will preserve the
# `/opt` directory as a volume.

# Set HOME to /opt so XDG-respecting utilities automatically use it
# without additional configuration
# This gets chmodded with wide open permissions, so that
# on Linux hosts, the explicitly passed user (with docker group)
# is able to read/write from here, as well as the root user used by
# macOS hosts (who don't have Docker permissions or host filesystem
# permissions issues to contend with and as such run the container as root)
ENV HOME="/opt"

# location where `n` installs Node.js versions
ENV N_PREFIX="${HOME}/n"

ENV PIPX_GLOBAL_HOME=/pipx

ENV PNPM_BIN="${HOME}/pnpm"

# Keep in sync with `PREK_VERSION` in the root `justfile`
ARG PREK_VERSION=0.5.10

# Add tooling installed in custom locations to `PATH`.
ENV PATH="${PNPM_BIN}:${N_PREFIX}/bin:${HOME}/.local/bin:${PATH}"

# Dependency explanations:
# - git: required by some python package; contributors should use git on their host
# - g++: required by some prek hooks for node-gyp
# - just: command runner
# - jq: JSON processor
# - which: locate a program file in `PATH`
# - tree: list files in a tree
# - xdg-utils: added because Storybook wants to open in a browser
# - nodejs, npm: language runtime (does not include Corepack)
# - python*: required by some Python libraries for compilation during installation;
#   keep in sync with `# PYTHON=` in `catalog/requirements-prod.txt`, because
#   `just catalog/venv` runs `python<version>` from here
# - pipx: Python CLI app installer
# - libffi*: required for the Python package cffi
# - libatomic: required by the Node.js binaries that `n` installs
# - docker*: used to interact with host Docker socket
# - unzip: used to extract zip files of visual regression patches from CI artifacts
# - postgresql*: required to connect to PostgreSQL databases
#
# System-specific dependencies:
# - k6: used for load testing (only installed on x86 architectures)
#
# pipx dependencies:
# - httpie: CLI HTTP client
# - pipenv, uv: Python package managers
# - prek: Git pre-commit and pre-push hook manager
# - pgcli: PostgreSQL CLI
#
# Node dependencies:
# - n: Node.js distribution manager
# - corepack: Node.js package-manager-manager
RUN mkdir -p $HOME/.local/bin \
  && mkdir /pipx \
  && dnf5 -y install dnf-plugins-core \
  && dnf5 -y config-manager addrepo --from-repofile=https://download.docker.com/linux/fedora/docker-ce.repo \
  && dnf5 -y install \
    git \
    g++ \
    just \
    jq \
    which \
    tree \
    xdg-utils \
    nodejs npm \
    python3.14 python3.14-devel \
    pipx \
    libffi-devel \
    libatomic \
    docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin \
    unzip \
    postgresql postgresql-devel \
  && if [ "$(uname -m)" = "x86_64" ]; then \
    dnf5 -y install https://dl.k6.io/rpm/repo.rpm \
    && dnf5 -y install k6; \
  fi \
  && dnf5 clean all \
  && pipx install --global \
    httpie \
    pipenv uv \
    pgcli \
    prek==${PREK_VERSION} \
  && npm install -g \
    n \
    [email protected] \
  && corepack enable

# Keep uv's environments apart from the host's `.venv`, and its cache and
# Python builds in the persisted `/opt` volume. The cache and the bind-mounted
# repository are on different filesystems, so uv copies instead of linking.
ENV UV_PROJECT_ENVIRONMENT=".venv-ov"
ENV UV_CACHE_DIR="${HOME}/uv/cache"
ENV UV_PYTHON_INSTALL_DIR="${HOME}/uv/python"
ENV UV_LINK_MODE="copy"

# The fedora container's default entrypoint + command behaviour is to keep running
# so we do not need to modify entrypoint and command to use the container as a
# persistent environment.