ARG PYTHON_IMAGE=python:3.12-slim
FROM ${PYTHON_IMAGE}

LABEL maintainer='<author>'
LABEL version='0.0.0-dev.0-build.0'

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /code

COPY requirements.txt /code/
RUN pip install -r requirements.txt --no-cache-dir

COPY . /code
RUN useradd --system --create-home --shell /usr/sbin/nologin webssh && \
  mkdir -p /data && \
  chown -R webssh:webssh /code /data

EXPOSE 8888/tcp
USER webssh
# WEBSSH_OPTS passes extra wssh options through without rebuilding the image,
# e.g. WEBSSH_OPTS="--maxconn=50 --tdstream=172.18.0.1"
ENV WEBSSH_OPTS=""
CMD ["sh", "-c", "exec python run.py --address=0.0.0.0 --port=8888 --data-dir=/data $WEBSSH_OPTS"]
