Files
zkldi_Tachi/Dockerfile.dev
T

82 lines
3.2 KiB
Docker

# For use via `devcontainer.json`. The docker-compose-dev file sets some other
# important variables.
FROM debian:13
WORKDIR /tachi
# Add the official PostgreSQL APT repository so we can install client tools
# that match the server version (v18). The Debian-packaged postgresql-client
# only provides v17 on Debian 13 (trixie).
RUN apt-get update \
&& apt-get install -y --no-install-recommends gnupg curl ca-certificates \
&& curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
| gpg --dearmor -o /etc/apt/trusted.gpg.d/pgdg.gpg \
&& echo "deb https://apt.postgresql.org/pub/repos/apt trixie-pgdg main" \
> /etc/apt/sources.list.d/pgdg.list
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
# essentials
git npm locales sudo unzip jq \
# docs pythonisms
python-is-python3 python3-setuptools pip mkdocs mkdocs-material \
# postgres client tools (psql, pg_dump, pg_restore, pg_isready, etc.)
postgresql-client-18 \
# nice to haves
gh fish just fzf curl wget parallel neovim fd-find bat ripgrep rsync \
# MinIO CLI (binary is `minio-client`, not Midnight Commander's `mc`)
minio-client \
# uninstall lynx so people don't get a CLI browser that can't load anything when they do `gh auth login`
&& apt-get purge -y lynx
# so apt doesn't complain about the lack of a dialog-like program
ENV DEBIAN_FRONTEND=readline
# `fd` is called `fdfind` on debian. Awesome.
RUN ln -s $(which fdfind) /usr/bin/fd
# expose the db CLI globally
RUN ln -sf /tachi/typescript/db-cli/src/index.ts /usr/local/bin/tachidb
# setup locales
# https://stackoverflow.com/questions/28405902/how-to-set-the-locale-inside-a-debian-ubuntu-docker-container
RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen && locale-gen
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
# bun
# TODO(zk): This will just pull a random version off
# the internet, unpinned. There's got to be something
# better...
RUN curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr/local bash
# https://github.com/python-babel/babel/issues/990
# it wouldn't be python without needing absurd global state manipulation to fix
# an incoherent error message
RUN rm -f /etc/localtime && ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime
# Fix locale issue perl repeatedly complains about
RUN echo "LC_ALL=en_US.UTF-8\nLANG=en_US.UTF-8" > /etc/default/locale
# create tachi user and give them sudo
RUN addgroup --gid 1000 tachi \
&& adduser --disabled-password --uid 1000 --gid 1000 --home /home/tachi tachi \
&& echo "tachi ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
# Make the /tachi working directory owned by our user instead of root. Docker volumes
# are mounted as root UNLESS the folder already exists inside the host and has non-root
# ownership. This is the only way to declare a volume in docker has non-root ownership.
# Unbelievably obscure.
RUN chown -R tachi:tachi /tachi
USER tachi
# see above comment about non-root volumes
RUN mkdir node_modules
# keep container alive indefinitely
# Exclude .git from chown to avoid permission errors on macOS Docker mounts
# TODO(zk): What the fuck is this?
ENTRYPOINT ["sh", "-c", "sudo find /tachi -maxdepth 1 ! -name '.git' ! -name '/tachi' -exec chown -R tachi:tachi {} + 2>/dev/null || true; exec /bin/fish"]