# syntax=docker/dockerfile:1
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive
ENV QT_LICENSE_SERVER=http://172.17.0.1:8080
ENV SQUISH_INSTALLER=squish-9.2.2-qt68x-linux64.run
ENV DISPLAY=:0

RUN apt-get update && apt-get install -y --no-install-recommends \
    libegl1 \
    libx11-xcb1 \
    libxcb-cursor0 \
    libxcb-icccm4 \
    libxcb-keysyms1 \
    libxcb-shape0 \
    libxkbcommon-x11-0 \
    x11vnc \
    xfwm4 \
    xvfb \
    locales \
    && rm -rf /var/lib/apt/lists/*

# Fix locale warning (Qt depends on UTF-8)
RUN locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8 \
    LC_ALL=en_US.UTF-8

# Set working directory
WORKDIR /app
RUN mkdir -p /app/squish/

# Copy application files
COPY ${SQUISH_INSTALLER} /app/
COPY install_squish.sh /app/
COPY start.sh /app/
RUN chmod +x /app/start.sh /app/install_squish.sh

# Run Squish installer, then remove the .run file. Note this doesn't
# actually shrink the image: the earlier COPY layer already baked the
# installer's bytes into the image permanently, so deleting it here only
# keeps it out of the *running* container's filesystem, not out of the
# image's stored layers/history. This trade-off is intentional, since it
# keeps the installer swappable per customer rather than pinned/verified
# ahead of time — see README for details.
RUN bash /app/install_squish.sh && rm -f /app/${SQUISH_INSTALLER}

# Expose ports: VNC, Squish server, AUT port if needed
EXPOSE 5900 4322 
#EXPOSE 9999

CMD ["bash", "/app/start.sh"]