# syntax=docker/dockerfile:1
FROM docker.io/library/ruby:3.1.5-alpine3.18

RUN apk add --no-cache \
    bash \
    brotli-dev \
    build-base \
    ca-certificates \
    curl \
    file \
    file-dev \
    git \
    git-lfs \
    nodejs \
    npm \
    openssl \
    py3-pip \
    python3 \
    tini \
    vips-dev \
  && npm install -g pnpm@9 \
  && python3 -m pip install --no-cache-dir fonttools brotli \
  && gem install bundler --version 2.6.9 --no-document \
  && rm -rf /var/cache/apk/*

WORKDIR /srv/site

# Keep UIDs aligned with the common host UID so bind-mounted files and
# dependency volumes remain writable.
RUN addgroup -g 1000 app \
  && adduser -D -u 1000 -G app app \
  && mkdir -p /srv/site/_site /srv/site/vendor/bundle /srv/site/node_modules \
  && chown -R 1000:1000 /srv/site

ENV HOME=/tmp \
    BUNDLE_APP_CONFIG=/srv/site/.bundle \
    BUNDLE_PATH=/srv/site/vendor/bundle

USER app

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["sh"]
