# PocketBase backend with auto-applied migrations (collections + rules).
# Migrations in ./pb_migrations run automatically when the server starts.
FROM alpine:3.21

ARG PB_VERSION=0.39.9

RUN apk add --no-cache ca-certificates curl unzip

WORKDIR /pb
RUN curl -fsSL "https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip" -o pb.zip \
    && unzip pb.zip \
    && rm pb.zip

COPY pb_migrations ./pb_migrations
COPY entrypoint.sh ./
RUN chmod +x entrypoint.sh pocketbase

EXPOSE 8090
CMD ["./entrypoint.sh"]
