-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
52 lines (42 loc) · 1.85 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 httpd:2.4
# Metadata labels
LABEL maintainer="vaggeliskls <https://github.com/vaggeliskls>"
LABEL description="A WebDAV server running on Apache httpd, configured for non-root execution."
LABEL build_date="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
LABEL license="MIT"
# Install gettext for envsubst
RUN apt-get update && apt-get install -y gettext-base libapache2-mod-auth-openidc
# Create a non-root user and group
RUN groupadd -r webuser && useradd -r -g webuser webuser
# Create necessary directories and adjust ownership
RUN mkdir -p "/var/www/html" && \
mkdir -p "/var/lib/dav/data" && \
touch "/var/lib/dav/DavLock" && \
chown -R webuser:webuser "/var/www/html" "/var/lib/dav" "/usr/local/apache2"
# Uncomment necessary LoadModule lines in httpd.conf
RUN for i in \
authn_core authn_file authz_core authz_user auth_digest \
ldap authnz_ldap ssl auth_basic \
alias headers mime setenvif \
dav dav_fs; \
do \
sed -i -e "/^#LoadModule ${i}_module.*/s/^#//" /usr/local/apache2/conf/httpd.conf; \
done
# Enable Icons
RUN sed -i '/httpd-autoindex.conf/s/^#//' conf/httpd.conf;
# Copy the new configuration files into the container
COPY ./webdav.conf /usr/local/apache2/conf/webdav.conf.template
COPY ./virtualhost.conf /usr/local/apache2/conf/virtualhost.conf.template
# Change ports in the Apache configuration to higher ports
RUN sed -i 's/Listen 80/Listen 8080/' /usr/local/apache2/conf/httpd.conf && \
sed -i 's/Listen 443/Listen 8443/' /usr/local/apache2/conf/httpd.conf
# Copy the entrypoint script into the container
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
# Make the entrypoint script executable
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Expose the new higher ports
EXPOSE 8080/tcp 8443/tcp
# Switch to the non-root user
USER webuser
ENTRYPOINT [ "docker-entrypoint.sh" ]
CMD [ "httpd-foreground" ]