penpot/docker/devenv/files/entrypoint.sh
Andrey Antukh 016c3976d0 🔧 Install opencode on demand instead of baking it in
The opencode build stage was already commented out, so the image carried
a dead block and a commented COPY. Drop both: opencode now comes from
scripts/setup-opencode, which installs @opencode/cli as a global pnpm
package in the penpot user's $PNPM_HOME. That dir sits in the user-data
volume, so the install survives a container re-creation and needs no
root.

pnpm 12 keeps the global binaries in $PNPM_HOME/bin, so put that dir on
PATH in the bashrc (and make the guard check the same path) instead of
$PNPM_HOME, which left the commands unreachable.

The entrypoint now also chowns ~/.local, ~/.cache and the dotfiles it
copies from /root. EXTERNAL_UID remaps penpot to the host UID on every
start, so the ownership the image set at build time stops matching; that
broke global pnpm installs and pnpm's own packageManager download.

AI-assisted-by: deepseek-v4.1-flash
2026-10-17 14:00:43 +02:00

49 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
EMSDK_QUIET=1 . /opt/emsdk/emsdk_env.sh;
usermod -u ${EXTERNAL_UID:-1000} penpot;
cp /root/.bashrc /home/penpot/.bashrc
cp /root/.vimrc /home/penpot/.vimrc
cp /root/.tmux.conf /home/penpot/.tmux.conf
chown -R penpot:penpot /home/penpot/.bashrc
chown -R penpot:penpot /home/penpot/.vimrc
chown -R penpot:penpot /home/penpot/.tmux.conf
# Seed SERENA_HOME with default config on first run
mkdir -p ${SERENA_HOME}
if [ ! -f "${SERENA_HOME}/serena_config.yml" ]; then
cp /home/serena_config.yml "${SERENA_HOME}/serena_config.yml"
fi
chown -R penpot:users ${SERENA_HOME}
chown penpot:users /home/penpot
# we need to be able to install rust-analyzer and possibly other dependencies with rustup
chown -R penpot:penpot /opt/rustup
# pnpm keeps its global dir (bin, global, store, package-manager-store)
# under ~/.local and its metadata cache under ~/.cache; opencode and other
# user-space tools write there too. Hand both trees back to penpot so
# packages, and pnpm itself, can be updated without root. Needed because the
# UID remap above can leave everything the image created owned by the old
# UID. ~/.config is deliberately excluded: the opencode overlay bind-mounts
# a host directory inside it.
mkdir -p /home/penpot/.local /home/penpot/.cache
chown -R penpot:penpot /home/penpot/.local /home/penpot/.cache
rsync -ar --chown=penpot:users /opt/cargo/ /home/penpot/.cargo/
export JAVA_OPTS="-Djava.net.preferIPv4Stack=true"
export PATH="/home/penpot/.cargo/bin:$PATH"
export CARGO_HOME="/home/penpot/.cargo"
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
export COLORTERM=truecolor
exec "$@"