# slite podman buildpush slite/core "" 26.0519.4
FROM ubuntu

WORKDIR /home/slite

LABEL version="26.0811.1538"
ENV SLITE_VERSION="26.0811.1538"

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update
RUN apt dist-upgrade -y
RUN apt install -y apache2 curl libapache2-mod-php git bash sudo php-gd php-pgsql podman nano 
#php-sass 

# Intall and setup code server
RUN curl -fsSL https://code-server.dev/install.sh | sh
COPY slite/core/code-server/config.yaml /root/.config/code-server/config.yaml
COPY slite/core/code-server/settings.json /root/.local/share/code-server/User/settings.json

RUN code-server --install-extension eamodio.gitlens
RUN code-server --install-extension glenn2223.live-sass
RUN code-server --install-extension bmewburn.vscode-intelephense-client
RUN code-server --uninstall-extension vscode.php-language-features

COPY slite/core/code-server/extensions/techss-dev/techss-dev-1.0.0.vsix /home/techss-dev-1.0.0.vsix
RUN code-server --install-extension /home/techss-dev-1.0.0.vsix
RUN rm /home/techss-dev-1.0.0.vsix
RUN rm /root/.local/share/code-server/extensions/techss.techss-dev-1.0.0/extension.js
RUN ln -s /home/slite/slite/core/code-server/extensions/techss-dev/extension.js /root/.local/share/code-server/extensions/techss.techss-dev-1.0.0/extension.js

# Setup Docker entry points and installation scripts

COPY slite/core/code-server/dev_container.sh /home/dev_container.sh
COPY slite/core/code-server/install.sh /home/install.sh

# Configure Apache
RUN ln -s /home/slite/slite/core/setup/slite /usr/bin/slite
# RUN ln -s /home/slite/slite/core/docker/.dockerignore /home/slite/.dockerignore
RUN rm -rf /var/www/html
RUN ln -s /home/slite /var/www/html

RUN sed -i 's/^.*register_argc_argv = .*$/register_argc_argv = On/g' /etc/php/*/apache2/php.ini
RUN sed -i 's/display_errors = Off/display_errors = On/g' /etc/php/*/apache2/php.ini
RUN sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf
RUN sed -i 's/^.*error_reporting.*/error_reporting = E_ALL \& ~E_DEPRECATED \& ~E_STRICT \& ~E_WARNING/g' /etc/php/*/apache2/php.ini
# RUN sed -i 's/.*APACHE_RUN_USER=.*/export APACHE_RUN_USER=root/g' /etc/apache2/envvars    # this breaks more than it fixes
# RUN sed -i 's/.*APACHE_RUN_GROUP=.*/export APACHE_RUN_GROUP=root/g' /etc/apache2/envvars    # this breaks more than it fixes
RUN a2enmod rewrite

# Enable connection to older ssh servers
RUN echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> /etc/ssh/ssh_config

# Install rust
# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust_install.sh
# RUN chmod 777 rust_install.sh
# RUN ./rust_install.sh -y
# RUN rm rust_install.sh

# store the keys in a place that is persistent
RUN ln -s /home/slite/.ssh /root/.ssh
RUN ln -s /home/slite/.ssh/.git-credentials /root/.git-credentials
RUN mkdir -p /root/.docker



COPY slite/core/code-server/icons/dev_icon-192.png /usr/lib/code-server/src/browser/media/pwa-icon-192.png
COPY slite/core/code-server/icons/dev_icon.png /usr/lib/code-server/src/browser/media/pwa-icon-512.png

COPY slite/core/code-server/icons/dev_icon-192.png /usr/lib/code-server/src/browser/media/pwa-icon-maskable-192.png
COPY slite/core/code-server/icons/dev_icon.png /usr/lib/code-server/src/browser/media/pwa-icon-maskable-512.png

COPY slite/core/code-server/icons/dev_icon.png /usr/lib/code-server/src/browser/media/pwa-icon.png

ENTRYPOINT [ "/home/dev_container.sh" ]
