Skip to content

Instantly share code, notes, and snippets.

@dlbewley
Last active March 22, 2016 19:19
Show Gist options
  • Save dlbewley/88bce324daf700d49bf0 to your computer and use it in GitHub Desktop.
Save dlbewley/88bce324daf700d49bf0 to your computer and use it in GitHub Desktop.
OpenShift STI static httpd builder dockerfile test
# static-builder
FROM openshift/base-centos7
# TODO: Put the maintainer name in the image metadata
MAINTAINER Dale Bewley <dale@bewley.net>
# 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,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"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment