FROM registry.fedoraproject.org/fedora:42

RUN dnf install -y cockpit-ws cockpit-bridge cockpit-system systemd passwd && dnf clean all

RUN useradd -m viewer && echo "viewer:viewer" | chpasswd

RUN mkdir -p /etc/cockpit && \
    printf '[WebService]\nAllowUnencrypted = true\nOrigins = *\n' > /etc/cockpit/cockpit.conf

RUN python3 -c "\
import json; \
f='/usr/share/cockpit/systemd/manifest.json'; \
m=json.load(open(f)); \
m.get('tools',{}).pop('terminal',None); \
json.dump(m,open(f,'w'),indent=4)" && \
    rm -f /usr/share/cockpit/systemd/terminal.*

RUN systemctl enable cockpit.socket

EXPOSE 9090
CMD ["/usr/sbin/init"]
