# VShell for UNIX container image (SSH2 / SFTP / FTPS / HTTPS).
#
# The base must be Ubuntu 24.04: the vendor binaries link against
# GLIBC_2.38 and GLIBCXX_3.4.32, so the Debian 12 / Ubuntu 22.04 toolchains are
# too old (see "System Requirements" in the vendor readme.txt).
FROM ubuntu:24.04

# Every shared library the VShell binaries need is already in ubuntu:24.04
# (libpam0g, libpam-modules, libpam-runtime, libuuid1, zlib1g, libstdc++6,
# libaudit1, libcap-ng0). openssl is added because VShell's HTTPS and implicit
# FTPS listeners require a PKCS#12 certificate and the entrypoint generates a
# self-signed one when none is supplied.
RUN apt-get update \
 && apt-get install -y --no-install-recommends openssl \
 && rm -rf /var/lib/apt/lists/*

ARG DEB=vshell-https-5.0.1-3985.ubuntu24-64.x86_64.deb
COPY vendor/${DEB} /tmp/vshell.deb

# The vendor postinst calls systemctl; there is no systemd in this image, so
# stub the command out for the duration of the dpkg install.
RUN set -eux; \
    printf '#!/bin/sh\necho "[systemctl stub] $*"\n' > /usr/local/bin/systemctl; \
    chmod 0755 /usr/local/bin/systemctl; \
    PATH=/usr/local/bin:$PATH dpkg -i /tmp/vshell.deb; \
    rm -f /usr/local/bin/systemctl /tmp/vshell.deb

COPY docker/entrypoint.sh /usr/local/bin/vshell-entrypoint
RUN chmod 0755 /usr/local/bin/vshell-entrypoint

EXPOSE 22 21 990 80 443

ENTRYPOINT ["/usr/local/bin/vshell-entrypoint"]
