FROM alpine:3.21

ARG ALPINE_MIRROR=https://mirrors.aliyun.com/alpine

RUN sed -i "s#https://dl-cdn.alpinelinux.org/alpine#${ALPINE_MIRROR}#g" /etc/apk/repositories \
    && apk add --no-cache chromium font-noto-cjk novnc openbox socat su-exec tigervnc websockify xvfb \
    && adduser -D -u 1000 browser \
    && ln -sf /usr/share/novnc/vnc_lite.html /usr/share/novnc/index.html

COPY entrypoint.sh /usr/local/bin/lingxing-browser-entrypoint
RUN chmod 0755 /usr/local/bin/lingxing-browser-entrypoint

ENV DISPLAY=:99 \
    LINGXING_LOGIN_URL=https://wms.xlwms.com/login \
    PROFILE_DIR=/profile

VOLUME ["/profile"]
EXPOSE 6080 9222

ENTRYPOINT ["/usr/local/bin/lingxing-browser-entrypoint"]
