# docker build -f Dockerfile.extend -t accetto/debian-vnc-xfce-g3:extended .

### This is an example of extending the images.

### HINTS
### Sometimes you can get building errors related to cache handling.
### One of the following usually helps:
### (1) Use the '--no-cache' option
###     > docker build ... --no-cache
### (2) Purge the builder cache before and/or between builds
###     > docker builder prune
### (3) Re-open the terminal and/or Visual Studio Code
### (4) Remove the line containing 'rm -rf /var/lib/apt/lists/*'
###     from your extending Dockerfile (like this one)

### choose a base image and tag
ARG BASEIMAGE="accetto/debian-vnc-xfce-g3"
# ARG BASEIMAGE="accetto/debian-vnc-xfce-chromium-g3"
# ARG BASEIMAGE="accetto/debian-vnc-xfce-firefox-g3"
ARG BASETAG="12"
ARG SERVER_VERSION="8.3.27.1859"

FROM ${BASEIMAGE}:${BASETAG}

### switch to the root user to be able to install new packages
USER 0

### update the apt cache and install your new packages

RUN sed -i '/Components:/s/$/ contrib/' /etc/apt/sources.list.d/debian.sources
RUN apt-get -qq update \
  && apt-get -qq install --yes --no-install-recommends \
    ca-certificates \
    #wget \
    locales \
    tzdata \
    procps \
    fontconfig \
    imagemagick \
    cabextract \
    ttf-mscorefonts-installer \
    xz-utils \
    #libssh-4 \
    #iproute2 \
    libwebkit2gtk-4.0-37 \
#    libtinfo5 \
#    libgsf-1-114 \
#    libglib2.0-0 \
#    unixodbc \
  && apt-get clean && apt-get autoremove


# Set locale
ENV LANG=ru_RU.UTF-8
ENV LANGUAGE=ru_RU:ru
ENV LC_ALL=ru_RU.UTF-8

RUN echo "ru_RU.UTF-8 UTF-8" >> /etc/locale.gen && \
    locale-gen && \
    update-locale LANG=ru_RU.UTF-8
# Set Timezone
ENV TZ=Europe/Moscow
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone


ENV SERVER_VERSION="8.3.27.1859"
ADD ./setup-full-$SERVER_VERSION-x86_64.run /home/
RUN  /home/setup-full-$SERVER_VERSION-x86_64.run  \
      --mode unattended \
      --enable-components \
        v8_install_deps,desktop_icons,server
### maybe you want to add some additional resources
### e.g. some preconfigured files
# COPY ./bashrc "${HOME}"/.bashrc
# COPY ./firefox.plus/user.js "${HOME}"/firefox.plus/

### avoid the pitfall of failing startup under some circumstances
### permissions will be set to the system defaults on the first container start
RUN chmod 666 /etc/passwd /etc/group

### usually you want to switch back to a non-root user
### alternatively you can do it in a compose file (see 'example.yml')
USER "${HEADLESS_USER_ID}"

### note that some applications refuse to be installed under the root user
### those you have to install after switching the user
# RUN \
#     apt-get update \
#     && apt-get install -y \
#         <app-package-name-comes-here> \
#     && apt-get -y autoremove \
#     && rm -rf /var/lib/apt/lists/*
