Skip to content

Instantly share code, notes, and snippets.

@ryanj
Forked from dlbewley/Dockerfile
Created March 22, 2016 19:19
Show Gist options
  • Select an option

  • Save ryanj/71290f3429bbe5a4d53e to your computer and use it in GitHub Desktop.

Select an option

Save ryanj/71290f3429bbe5a4d53e to your computer and use it in GitHub Desktop.

Revisions

  1. @dlbewley dlbewley revised this gist Mar 22, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Dockerfile
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ ENV BUILDER_VERSION 1.0
    LABEL io.k8s.description="Platform for building static web sites" \
    io.k8s.display-name="static-builder 0.0.1" \
    io.openshift.expose-services="8080:http" \
    io.openshift.tags="builder,0.0.1,static-builder,nfs,httpd"
    io.openshift.tags="builder,0.0.1,static-builder,httpd"

    # TODO: Install required packages here:
    RUN INSTALL_PKGS="httpd" && \
  2. @dlbewley dlbewley created this gist Mar 22, 2016.
    61 changes: 61 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    # static-builder
    FROM openshift/base-centos7

    # TODO: Put the maintainer name in the image metadata
    MAINTAINER Dale Bewley <[email protected]>

    # TODO: Rename the builder environment variable to inform users about application you provide them
    ENV BUILDER_VERSION 1.0

    # TODO: Set labels used in OpenShift to describe the builder image
    LABEL io.k8s.description="Platform for building static web sites" \
    io.k8s.display-name="static-builder 0.0.1" \
    io.openshift.expose-services="8080:http" \
    io.openshift.tags="builder,0.0.1,static-builder,nfs,httpd"

    # TODO: Install required packages here:
    RUN INSTALL_PKGS="httpd" && \
    yum install --setopt=tsflags=nodocs --enablerepo=centosplus -y "$INSTALL_PKGS" && \
    # Remove centos-logos (httpd dependency, ~20MB of graphics)
    rpm -e --nodeps centos-logos && \
    yum clean all -y

    # TODO (optional): Copy the builder files into /opt/app-root
    # COPY ./<builder_folder>/ /opt/app-root/

    # TODO: Copy the S2I scripts to /usr/libexec/s2i, since openshift/base-centos7 image sets io.openshift.s2i.scripts-url label that way, or update that label
    COPY ./.s2i/bin/ /usr/libexec/s2i

    RUN chown -R 1001:1001 /opt/app-root

    # TODO: Set the default port for applications built using this image
    EXPOSE 8080

    # TODO: Set the default CMD for the image
    # CMD ["usage"]
    # In order to drop the root user, we have to make some directories world
    # writeable as OpenShift default security model is to run the container under
    # random UID.
    # RUN sed -i -f /opt/app-root/etc/httpdconf.sed /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf && \
    # head -n151 /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf | tail -n1 | grep "AllowOverride All" || exit && \
    RUN sed -i \
    -e 's/^Listen 80/Listen 0.0.0.0:8080/' \
    -e 's/^User apache/User default/' \
    -e 's/^Group apache/Group root/' \
    -e 's%^DocumentRoot "/var/www/html"%DocumentRoot "/opt/app-root/src"%' \
    -e 's%^<Directory "/var/www/html"%<Directory "/opt/app-root/src"%' \
    -e 's%^<Directory "/var/html"%<Directory "/opt/app-root/src"%' \
    -e 's%^ErrorLog "logs/error_log"%ErrorLog "/tmp/error_log"%' \
    -e 's%CustomLog "logs/access_log"%CustomLog "|/usr/bin/cat"%' \
    -e '151s%AllowOverride None%AllowOverride All%' \
    /etc/httpd/conf/httpd.conf && \
    head -n151 /etc/httpd/conf/httpd.conf | tail -n1 | grep "AllowOverride All" || exit && \
    mkdir /tmp/sessions && \
    chmod -R a+rwx /var/run/httpd && \
    chmod -R a+rwx /tmp/sessions && \
    chown -R 1001:0 /opt/app-root /tmp/sessions

    # This default user is created in the openshift/base-centos7 image
    USER 1001

    CMD ["usage"]