Skip to content

Commit

Permalink
clean up hello world environment, shrink it a little as well
Browse files Browse the repository at this point in the history
  • Loading branch information
silentpete committed Oct 22, 2017
1 parent b954c53 commit 76ae30b
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 60 deletions.
19 changes: 4 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,16 @@ FROM centos:7.4.1708
LABEL \
maintainer=silentpete

# updated Apache container with SSL/TLS and basic packages
ENV \
SCRIPTS_DIR=/opt/httpd

RUN \
yum makecache fast && \
yum -y install \
httpd \
mod_ssl && \
yum clean all

# Primary ENVs
ENV \
LOCAL_DATA_DIR=/opt/local/data/httpd \
HTTPD_DIR=/etc/httpd
# Secondary ENVs
ENV \
HTTPD_CONF_DIR=$HTTPD_DIR/conf \
HTTPD_CONFD_DIR=$HTTPD_DIR/conf.d \
SCRIPTS_DIR=$LOCAL_DATA_DIR/scripts
# Triciary ENVs
ENV \
HTTPD_CONF_FILE=$HTTPD_CONF_DIR/httpd.conf

COPY root/ /

CMD /opt/local/data/httpd/scripts/run
CMD ${SCRIPTS_DIR}/run
14 changes: 12 additions & 2 deletions ...ocal/data/httpd/scripts/start-services.sh → root/opt/httpd/functions.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

function info () {
echo -e "\e[32mINFO $1\e[0m"
}
Expand All @@ -11,6 +12,15 @@ function error () {
echo -e "\e[31mERROR $1\e[0m"
}

function adjust_httpd_conf_servername () {
http_conf_filepath="/etc/httpd/conf/httpd.conf"
if [[ ${SERVERNAME} ]]; then
sed -i 's|#ServerName.*|ServerName $SERVERNAME|' $http_conf_filepath
else
sed -i 's|#ServerName.*|ServerName ${HOSTNAME}|' $http_conf_filepath
fi
}

function start_httpd () {
httpd_service=$(ps -ef | grep "httpd -k start" | grep -c apache)
httpd_pid=$(find /run -type f -name "*.pid" | grep -c httpd)
Expand All @@ -31,7 +41,7 @@ function start_httpd () {

function stop_httpd () {
info "shutting down httpd"
httpd stop
httpd -k stop
if [[ $(ps -ef | grep "httpd -k start" | grep -c apache) == 0 ]]; then
info "apache stopped"
exit 0
Expand Down
17 changes: 17 additions & 0 deletions root/opt/httpd/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

echo -e "\e[32mINFO sourcing $SCRIPTS_DIR\e[0m"
for VAR in $(find ${SCRIPTS_DIR} -type f -name "*.sh"); do echo -e "\e[32mINFO sourcing $VAR\e[0m"; source $VAR; done;

# Run a Function
adjust_httpd_conf_servername

# Last function to run should be starting httpd
start

function shutdown () {
stop
}

trap 'shutdown' SIGTERM
while true; do read; done;
9 changes: 9 additions & 0 deletions root/opt/httpd/variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# Default Variables

HTTPD_DIR=/etc/httpd
HTTPD_CONF_DIR=$HTTPD_DIR/conf
HTTPD_CONFD_DIR=$HTTPD_DIR/conf.d
HTTPD_CONF_FILE=$HTTPD_CONF_DIR/httpd.conf

9 changes: 0 additions & 9 deletions root/opt/local/data/httpd/scripts/http-setup.sh

This file was deleted.

30 changes: 0 additions & 30 deletions root/opt/local/data/httpd/scripts/run

This file was deleted.

Empty file removed root/var/log/httpd/the-tail-file
Empty file.
13 changes: 12 additions & 1 deletion root/var/www/html/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
hello world!
<!DOCTYPE html>
<html>
<head>
<title>yet another landing page</title>
</head>
<body>

<h1>hello world!</h1>
<p>lorem ipsum goes here, hah</p>

</body>
</html>
7 changes: 4 additions & 3 deletions run-apache.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash
#!/usr/bin/env bash
docker run \
-d -t \
--hostname=apache \
--name=apache \
-p 80:80 \
--hostname=apache \
--rm \
-p 8080:80 \
-m 64m \
apache:latest

0 comments on commit 76ae30b

Please sign in to comment.