-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
122 lines (103 loc) · 3.38 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
ARG ARCH=
FROM ${ARCH}alpine:3.18
LABEL Maintainer="Benji <[email protected]>" \
Description="A Container to Monitor your Repocket Stats"
# Install packages
RUN apk --no-cache add \
php82 \
php82-fpm \
php82-opcache \
php82-pecl-apcu \
php82-mysqli \
php82-pgsql \
php82-json \
php82-openssl \
php82-curl \
php82-zlib \
php82-soap \
php82-xml \
php82-fileinfo \
php82-phar \
php82-intl \
php82-dom \
php82-xmlreader \
php82-ctype \
php82-session \
php82-iconv \
php82-tokenizer \
php82-zip \
php82-simplexml \
php82-mbstring \
php82-gd \
nginx \
runit \
curl \
# Bring in gettext so we can get `envsubst`, then throw
# the rest away. To do this, we need to install `gettext`
# then move `envsubst` out of the way so `gettext` can
# be deleted completely, then move `envsubst` back.
&& apk add --no-cache --virtual .gettext gettext \
&& mv /usr/bin/envsubst /tmp/ \
&& runDeps="$( \
scanelf --needed --nobanner /tmp/envsubst \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache $runDeps \
&& apk del .gettext \
&& mv /tmp/envsubst /usr/local/bin/ \
# Remove alpine cache
&& rm -rf /var/cache/apk/* \
# Remove default server definition
&& rm /etc/nginx/http.d/default.conf \
# Make sure files/folders needed by the processes are accessable when they run under the nobody user
&& chown -R nobody.nobody /run \
&& chown -R nobody.nobody /var/lib/nginx \
&& chown -R nobody.nobody /var/log/nginx
# Add configuration files
COPY --chown=nobody rootfs/ /
# copy the files from the current directory to the container
COPY --chown=nobody repocket_stats/ /var/www/html
# install curl and sqlite3
RUN apk add php82-curl php82-sqlite3
# enable ";extension=sqlite3"
RUN sed -i 's/;extension=sqlite3/extension=sqlite3/g' /etc/php82/php.ini
# enable ";extension=curl"
RUN sed -i 's/;extension=curl/extension=curl/g' /etc/php82/php.ini
# # install cron
# RUN apk add dcron curl
# RUN echo "* * * * * curl -s http://localhost:8080/update.php > /dev/null 2>&1" >> /var/spool/cron/crontabs/root
# give nobody user permission to write to the directory
RUN chmod -R 777 /var/www/html
# Switch to use a non-root user from here on
USER nobody
# give nobody user permission to write to the directory
RUN chmod -R 777 /var/www/html
# Add application
WORKDIR /var/www/html
# Expose the port nginx is reachable on
EXPOSE 8080
# set default environment variables of name, email and password
ENV NAME="Repocket" \
EMAIL="[email protected]" \
PASSWORD="password" \
DB_NAME="repocket"
# Let runit start nginx & php-fpm
CMD [ "/bin/docker-entrypoint.sh" ]
# Configure a healthcheck to validate that everything is up&running
HEALTHCHECK --timeout=60s CMD curl --silent --fail http://127.0.0.1:8080/update.php
ENV client_max_body_size=2M \
clear_env=no \
allow_url_fopen=On \
allow_url_include=Off \
display_errors=Off \
file_uploads=On \
max_execution_time=0 \
max_input_time=-1 \
max_input_vars=1000 \
memory_limit=128M \
post_max_size=8M \
upload_max_filesize=2M \
zlib_output_compression=On