octobot/skills/scaffold/containerize-project/Dockerfile.r-analysis.tpl
lukabor 2517b1fb43 refactor(skills): extract containerize-project from build-* scaffolds
- refactor(scaffold): move Docker/compose templates and three-stage doc into
  new containerize-project skill; build-* skills delegate their Docker step
- fix(scaffold): drop source mount from the production compose service
- fix(scaffold): add .dockerignore templates so COPY . . excludes .git/.env/data
- feat(scaffold): run production stages as non-root app user; pin uv install
  via COPY --from=ghcr.io/astral-sh/uv:0.7
- docs(README): list containerize-project and add-docker-secrets; remove the
  now-empty _concepts section

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 12:49:48 +02:00

45 lines
1.3 KiB
Smarty

FROM rocker/verse:4.4 AS base
RUN apt-get update && apt-get install -y --no-install-recommends \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
&& rm -rf /var/lib/apt/lists/*
RUN install2.r --error --skipinstalled renv
WORKDIR /usr/<project-name>
ENV RENV_PATHS_LIBRARY=renv/library
# ── production ──────────────────────────────────────────────────────────
FROM base AS production
COPY renv.lock renv.lock
COPY renv/activate.R renv/activate.R
RUN R -e "renv::restore()"
COPY . .
# tar_make() writes _targets/, so the workdir must be writable by app.
RUN useradd --create-home --shell /usr/sbin/nologin app \
&& chown -R app:app /usr/<project-name>
USER app
CMD ["R", "--vanilla", "-e", "targets::tar_make()"]
# ── development ────────────────────────────────────────────────────────
# Runs as root deliberately: the dev service bind-mounts the source tree
# and installs packages interactively; a non-root user fights both.
FROM base AS development
COPY renv.lock renv.lock
COPY renv/activate.R renv/activate.R
RUN R -e "renv::restore()"
COPY . .
CMD ["bash"]