# A code-server image with added
# openjdk 11 
# BaseX installed
# @author Andy Bunce

# Main image
FROM ghcr.io/linuxserver/code-server:4.0.2

ARG TARGETARCH
ARG BUILDARCH
RUN echo "I'm building vscode-basex for ${BUILDARCH} on ${TARGETARCH}"

LABEL author="Andy Bunce"
LABEL company="Quodatum Ltd"
LABEL maintainer="quodatum@gmail.com"

# Install OpenJDK-11
RUN apt-get update && \
    apt-get install -y openjdk-11-jdk-headless;
  
# Fix certificate issues
RUN apt-get update && \
    apt-get install ca-certificates-java && \
    apt-get clean && \
    update-ca-certificates -f;

# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/
RUN export JAVA_HOME

# install BaseX to /basex/
RUN curl https://files.basex.org/releases/9.6.4/BaseX964.zip | jar xv && \
    chmod a+x /basex/bin/*;
ENV PATH=$PATH:/basex/bin

# install docker cli only
RUN curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.12.tgz  | tar zxv -C /tmp/ && \
    cp /tmp/docker/docker /usr/local/bin && rm -r /tmp/docker;
#RUN chmod 666 /var/run/docker.sock

# ports and volumes
EXPOSE 8443