Skip to content

Commit

Permalink
Move setup commands into setup script (#14)
Browse files Browse the repository at this point in the history
* - ensuring correct line ending while building on Windows.
- Optimising resulting image size.

* - merging changes from main branch

* - fixing sed substitution for CRLF

* - removing RUN from bash script
  • Loading branch information
mgoszczynski authored Mar 11, 2023
1 parent 31e21d1 commit b08d761
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

/.idea/
logs/
/dispatcher-docker.iml
*.iml
.DS_Store
43 changes: 6 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,61 +16,30 @@
FROM --platform=$TARGETPLATFORM centos:7

#install HTTPD
RUN yum -y update
RUN yum -y install httpd mod_ssl procps haproxy iputils tree telnet
RUN yum -y update && yum -y install httpd mod_ssl procps haproxy iputils tree telnet && yum clean all

#remove default CentOS config
RUN rm -rf /etc/httpd/conf/*
RUN rm -rf /etc/httpd/conf.d/*
RUN rm -rf /etc/httpd/conf.modules.d/*
RUN rm -rf /etc/httpd/conf/* && rm -rf /etc/httpd/conf.d/* && rm -rf /etc/httpd/conf.modules.d/*

#Copy the AMS base files into the image.
COPY ams/2.6/etc/httpd /etc/httpd
RUN mkdir /etc/httpd/conf.d/enabled_vhosts
RUN ln -s /etc/httpd/conf.d/available_vhosts/aem_author.vhost /etc/httpd/conf.d/enabled_vhosts/aem_author.vhost
RUN ln -s /etc/httpd/conf.d/available_vhosts/aem_flush_author.vhost /etc/httpd/conf.d/enabled_vhosts/aem_flush_author.vhost
RUN ln -s /etc/httpd/conf.d/available_vhosts/aem_publish.vhost /etc/httpd/conf.d/enabled_vhosts/aem_publish.vhost
RUN ln -s /etc/httpd/conf.d/available_vhosts/aem_flush.vhost /etc/httpd/conf.d/enabled_vhosts/aem_flush.vhost
RUN ln -s /etc/httpd/conf.d/available_vhosts/aem_health.vhost /etc/httpd/conf.d/enabled_vhosts/aem_health.vhost

RUN mkdir /etc/httpd/conf.dispatcher.d/enabled_farms
RUN ln -s /etc/httpd/conf.dispatcher.d/available_farms/000_ams_catchall_farm.any /etc/httpd/conf.dispatcher.d/enabled_farms/000_ams_catchall_farm.any
RUN ln -s /etc/httpd/conf.dispatcher.d/available_farms/001_ams_author_flush_farm.any /etc/httpd/conf.dispatcher.d/enabled_farms/001_ams_author_flush_farm.any
RUN ln -s /etc/httpd/conf.dispatcher.d/available_farms/001_ams_publish_flush_farm.any /etc/httpd/conf.dispatcher.d/enabled_farms/001_ams_publish_flush_farm.any
RUN ln -s /etc/httpd/conf.dispatcher.d/available_farms/002_ams_author_farm.any /etc/httpd/conf.dispatcher.d/enabled_farms/002_ams_author_farm.any

# Setup sample configs
COPY sample/weretail_filters.any /etc/httpd/conf.dispatcher.d/filters/weretail_filters.any
COPY sample/weretail_publish_farm.any /etc/httpd/conf.dispatcher.d/available_farms/100_weretail_publish_farm.any
RUN ln -s /etc/httpd/conf.dispatcher.d/available_farms/100_weretail_publish_farm.any /etc/httpd/conf.dispatcher.d/enabled_farms/100_weretail_publish_farm.any

# Install dispatcher
ARG TARGETARCH
COPY scripts/setup.sh /
RUN chmod +x /setup.sh
# ensuring correct file ending on windows systems
RUN sed -i -e 's/\r\n/\n/' /setup.sh
RUN ./setup.sh
RUN rm /setup.sh

# Create default docroots
RUN mkdir -p /mnt/var/www/html
RUN chown apache:apache /mnt/var/www/html

RUN mkdir -p /mnt/var/www/default
RUN chown apache:apache /mnt/var/www/default

RUN mkdir -p /mnt/var/www/author
RUN chown apache:apache /mnt/var/www/author

# Setup SSL
RUN mkdir -p /etc/ssl/docker && \
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=GB/ST=London/L=London/O=Adobe/CN=localhost" \
-keyout /etc/ssl/docker/localhost.key \
-out /etc/ssl/docker/localhost.crt && \
cat /etc/ssl/docker/localhost.key /etc/ssl/docker/localhost.crt > /etc/ssl/docker/haproxy.pem

COPY haproxy/haproxy.cfg /etc/haproxy

COPY scripts/launch.sh /
# ensuring correct file ending on windows systems
RUN sed -i -e 's/\r\n/\n/' /launch.sh
RUN chmod +x /launch.sh

COPY LICENSE /
Expand Down
36 changes: 36 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,34 @@ if [ "${TARGETARCH}" = "arm64" ]; then
DISPARCH=aarch64
fi

# Create default docroots
mkdir -p /mnt/var/www/html
chown apache:apache /mnt/var/www/html

mkdir -p /mnt/var/www/default
chown apache:apache /mnt/var/www/default

mkdir -p /mnt/var/www/author
chown apache:apache /mnt/var/www/author
#create and link up default enabled vhosts
mkdir /etc/httpd/conf.d/enabled_vhosts
ln -s /etc/httpd/conf.d/available_vhosts/aem_author.vhost /etc/httpd/conf.d/enabled_vhosts/aem_author.vhost
ln -s /etc/httpd/conf.d/available_vhosts/aem_flush_author.vhost /etc/httpd/conf.d/enabled_vhosts/aem_flush_author.vhost
ln -s /etc/httpd/conf.d/available_vhosts/aem_publish.vhost /etc/httpd/conf.d/enabled_vhosts/aem_publish.vhost
ln -s /etc/httpd/conf.d/available_vhosts/aem_flush.vhost /etc/httpd/conf.d/enabled_vhosts/aem_flush.vhost
ln -s /etc/httpd/conf.d/available_vhosts/aem_health.vhost /etc/httpd/conf.d/enabled_vhosts/aem_health.vhost

#create and link up default enabled vhosts
mkdir /etc/httpd/conf.dispatcher.d/enabled_farms
ln -s /etc/httpd/conf.dispatcher.d/available_farms/000_ams_catchall_farm.any /etc/httpd/conf.dispatcher.d/enabled_farms/000_ams_catchall_farm.any
ln -s /etc/httpd/conf.dispatcher.d/available_farms/001_ams_author_flush_farm.any /etc/httpd/conf.dispatcher.d/enabled_farms/001_ams_author_flush_farm.any
ln -s /etc/httpd/conf.dispatcher.d/available_farms/001_ams_publish_flush_farm.any /etc/httpd/conf.dispatcher.d/enabled_farms/001_ams_publish_flush_farm.any
ln -s /etc/httpd/conf.dispatcher.d/available_farms/002_ams_author_farm.any /etc/httpd/conf.dispatcher.d/enabled_farms/002_ams_author_farm.any
ln -s /etc/httpd/conf.dispatcher.d/available_farms/002_ams_publish_farm.any /etc/httpd/conf.dispatcher.d/enabled_farms/002_ams_publish_farm.any

#set up sample configs
ln -s /etc/httpd/conf.dispatcher.d/available_farms/100_weretail_publish_farm.any /etc/httpd/conf.dispatcher.d/enabled_farms/100_weretail_publish_farm.any
#set up dispatcher
mkdir -p /tmp/dispatcher

curl -o /tmp/dispatcher/dispatcher.tar.gz https://download.macromedia.com/dispatcher/download/dispatcher-apache2.4-linux-$DISPARCH-4.3.5.tar.gz
Expand All @@ -29,3 +57,11 @@ cd /tmp/dispatcher
tar zxvf dispatcher.tar.gz

cp -v dispatcher-apache2.4-4.3.5.so /etc/httpd/modules/mod_dispatcher.so

#set up HA proxy
# Setup SSL
mkdir -p /etc/ssl/docker && \
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=GB/ST=London/L=London/O=Adobe/CN=localhost" \
-keyout /etc/ssl/docker/localhost.key \
-out /etc/ssl/docker/localhost.crt && \
cat /etc/ssl/docker/localhost.key /etc/ssl/docker/localhost.crt > /etc/ssl/docker/haproxy.pem

0 comments on commit b08d761

Please sign in to comment.