FROM node:18-alpine

LABEL maintainer="Frambe"
LABEL description="Frambe — lightweight digital photo frame for Immich"

# tzdata lets the TZ env var set the container's local time, which the
# sleep scheduler relies on. Without it Alpine defaults to UTC.
RUN apk add --no-cache tzdata

WORKDIR /app

COPY package.json ./
RUN npm install --production && npm cache clean --force

COPY server.js ./
COPY public/ ./public/

EXPOSE 3000

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
  CMD wget -qO- http://localhost:3000/api/config || exit 1

RUN addgroup -g 1001 -S appgroup && \
    adduser -S appuser -u 1001 -G appgroup && \
    mkdir -p /app/data && \
    chown -R appuser:appgroup /app/data

VOLUME ["/app/data"]

USER appuser

CMD ["node", "server.js"]
