FROM registry.fedoraproject.org/f27/s2i-core:latest

EXPOSE 8080
EXPOSE 8443

ENV SUMMARY="Platform for running Varnish or building Varnish-based application" \
    DESCRIPTION="Varnish available as container is a base platform for \
running Varnish server or building Varnish-based application. \
Varnish Cache stores web pages in memory so web servers don't have to create \
the same web page over and over again. Varnish Cache serves pages much faster \
than any application server; giving the website a significant speed up." \
    VERSION=0 \
    VARNISH_CONFIGURATION_PATH=/etc/varnish

LABEL summary="$SUMMARY" \
      description="$DESCRIPTION" \
      io.k8s.description="$DESCRIPTION" \
      io.k8s.display-name="Varnish 5" \
      io.openshift.expose-services="8080:http,8443:https" \
      io.openshift.tags="builder,varnish" \
      version="$VERSION" \
      com.redhat.component="varnish" \
      usage="s2i build https://github.com/sclorg/varnish-container.git --context-dir=5/test/test-app/ $FGC/varnish sample-server" \
      name="$FGC/varnish" \
      maintainer="SoftwareCollections.org <sclorg@redhat.com>"

RUN INSTALL_PKGS="gettext hostname nss_wrapper bind-utils varnish" && \
    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
    rpm -V $INSTALL_PKGS && \
    fix-permissions $VARNISH_CONFIGURATION_PATH && \
    fix-permissions /var/lib/varnish && \
    rm -f /etc/profile.d/lang.sh && \
    rm -f /etc/profile.d/lang.csh && \
    dnf -y clean all --enablerepo='*'

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY 5/s2i/bin/ $STI_SCRIPTS_PATH

# Copy extra files to the image.
COPY 5/root/ /

# Reset permissions of filesystem to default values
RUN rpm-file-permissions

USER 1001

CMD $STI_SCRIPTS_PATH/usage
