forked from BirgerK/docker-apache-letsencrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (43 loc) · 1.96 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
FROM phusion/baseimage:jammy-1.0.1
MAINTAINER Nicolas Richeton <[email protected]>
ENV DEBIAN_FRONTEND noninteractive
ENV LETSENCRYPT_HOME /etc/letsencrypt
ENV DOMAINS ""
ENV WEBMASTER_MAIL ""
# Manually set the apache environment variables in order to get apache to work immediately.
RUN echo $WEBMASTER_MAIL > /etc/container_environment/WEBMASTER_MAIL && \
echo $DOMAINS > /etc/container_environment/DOMAINS && \
echo $LETSENCRYPT_HOME > /etc/container_environment/LETSENCRYPT_HOME
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["/sbin/my_init"]
# Base setup
RUN apt-get -y update && \
apt-get -y dist-upgrade &&\
apt-get install -q -y curl apache2 software-properties-common dumb-init && \
# add-apt-repository ppa:certbot/certbot && \
apt-get -y update && \
apt-get install -q -y python3-certbot-apache && \
# Add modsecurity
apt-get install -q -y --no-install-recommends libapache2-mod-security2 modsecurity-crs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# configure apache
ADD config/mods-available/proxy_html.conf /etc/apache2/mods-available/
ADD config/conf-available/security.conf /etc/apache2/conf-available/
RUN echo "ServerName localhost" >> /etc/apache2/conf-enabled/hostname.conf && \
a2enmod ssl headers proxy proxy_http proxy_html xml2enc rewrite usertrack remoteip && \
a2dissite 000-default default-ssl && \
mkdir -p /var/lock/apache2 && \
mkdir -p /var/run/apache2
# configure runit
RUN mkdir -p /etc/service/apache
ADD config/scripts/run_apache.sh /etc/service/apache/run
ADD config/scripts/init_letsencrypt.sh /etc/my_init.d/
ADD config/scripts/run_letsencrypt.sh /run_letsencrypt.sh
RUN chmod +x /*.sh && chmod +x /etc/my_init.d/*.sh && chmod +x /etc/service/apache/*
ADD config/crontab /etc/crontab
# Stuff
EXPOSE 80
EXPOSE 443
#VOLUME [ "$LETSENCRYPT_HOME", "/etc/apache2/sites-available", "/var/log/apache2" ]
HEALTHCHECK CMD curl --fail http://localhost/ || exit 1