-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
executable file
·72 lines (64 loc) · 1.92 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
ARG APACHE_VER
FROM httpd:${APACHE_VER}-alpine
ENV APACHE_VER="${APACHE_VER}" \
APP_ROOT="/var/www/html" \
APACHE_DIR="/usr/local/apache2" \
FILES_DIR="/mnt/files" \
APACHE_VHOST_PRESET="html" \
APACHE_MPM="event"
ARG TARGETPLATFORM
RUN set -ex; \
\
deluser www-data; \
addgroup -S apache; \
adduser -S -D -H -h /usr/local/apache2 -s sbin/nologin -G apache apache; \
\
addgroup -g 1000 -S wodby; \
adduser -u 1000 -D -S -s /bin/bash -G wodby wodby; \
sed -i '/^wodby/s/!/*/' /etc/shadow; \
echo "PS1='\w\$ '" >> /home/wodby/.bashrc; \
\
apk --update --no-cache -t .apache-rundeps add \
bash \
ca-certificates \
curl \
findutils \
make \
nghttp2 \
sudo; \
\
mkdir -p \
"${APP_ROOT}" \
"${FILES_DIR}" \
/usr/local/apache2/conf/conf.d; \
\
chown -R wodby:wodby \
"${APP_ROOT}" \
"${FILES_DIR}" \
/usr/local/apache2; \
\
rm -f /usr/local/apache2/logs/httpd.pid; \
\
dockerplatform=${TARGETPLATFORM:-linux/amd64}; \
gotpl_url="https://github.com/wodby/gotpl/releases/latest/download/gotpl-${dockerplatform/\//-}.tar.gz"; \
wget -qO- "${gotpl_url}" | tar xz --no-same-owner -C /usr/local/bin; \
\
# Script to fix volumes permissions via sudo.
echo "find ${APP_ROOT} ${FILES_DIR} -maxdepth 0 -uid 0 -type d -exec chown wodby:wodby {} +" > /usr/local/bin/init_volumes; \
chmod +x /usr/local/bin/init_volumes; \
\
{ \
echo -n 'wodby ALL=(root) NOPASSWD:SETENV: ' ; \
echo -n '/usr/local/bin/init_volumes, ' ; \
echo '/usr/local/apache2/bin/httpd' ; \
} | tee /etc/sudoers.d/wodby; \
\
# Cleanup
rm -rf /var/cache/apk/*
USER wodby
WORKDIR $APP_ROOT
COPY bin /usr/local/bin
COPY templates /etc/gotpl/
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["sudo", "httpd", "-DFOREGROUND"]