Skip to content

Commit 4ae4ed6

Browse files
committed
clean up the dockerfile
1 parent 11fdc7f commit 4ae4ed6

File tree

4 files changed

+112
-117
lines changed

4 files changed

+112
-117
lines changed

Dockerfile

Lines changed: 6 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ ARG DEBIAN_FRONTEND=noninteractive
66
ENV APP_DIR=/srv/keys COMPOSER_ALLOW_SUPERUSER=1
77

88
RUN apt-get update && apt-get install -y --no-install-recommends \
9-
nginx php-fpm php-cli php-mysql php-ldap php-mbstring php-gmp php-xml php-zip php-curl php-gd \
10-
php-intl php-bcmath composer cron supervisor tini ca-certificates curl openssh-client && rm -rf /var/lib/apt/lists/*
9+
nginx php-fpm php-cli php-mysql php-ldap php-mbstring php-gmp php-xml php-zip php-curl php-gd php-intl php-bcmath \
10+
composer cron supervisor tini ca-certificates curl openssh-client \
11+
&& rm -rf /var/lib/apt/lists/*
1112

1213
RUN useradd --system --home /var/lib/keys-sync --shell /usr/sbin/nologin keys-sync && \
1314
mkdir -p /var/lib/keys-sync /var/log/ska /var/local/keys-sync /var/log/supervisor && \
@@ -19,6 +20,8 @@ RUN useradd --system --home /var/lib/keys-sync --shell /usr/sbin/nologin keys-sy
1920
WORKDIR ${APP_DIR}
2021
COPY . ${APP_DIR}
2122

23+
RUN cp -r ${APP_DIR}/etc / && rm -rf ${APP_DIR}/etc
24+
2225
RUN composer install --no-dev --prefer-dist --optimize-autoloader
2326

2427
RUN set -eux; \
@@ -33,121 +36,7 @@ RUN set -eux; \
3336
chown www-data:www-data /run/php /var/lib/php/sessions; \
3437
chmod 1733 /var/lib/php/sessions
3538

36-
RUN set -eux; \
37-
cat <<'NGINX-EOF' >/etc/nginx/nginx.conf; printf '\n' >>/etc/nginx/nginx.conf
38-
worker_processes auto;
39-
40-
error_log /dev/stderr info;
41-
42-
pid /run/nginx.pid;
43-
44-
events {
45-
worker_connections 1024;
46-
}
47-
48-
http {
49-
include /etc/nginx/mime.types;
50-
default_type application/octet-stream;
51-
52-
sendfile on;
53-
keepalive_timeout 65;
54-
server_tokens off;
55-
client_max_body_size 16m;
56-
57-
access_log /dev/stdout;
58-
error_log /dev/stderr info;
59-
60-
include /etc/nginx/conf.d/*.conf;
61-
62-
server {
63-
listen 8080 default_server;
64-
listen [::]:8080 default_server;
65-
66-
root /srv/keys/public_html;
67-
index init.php;
68-
69-
add_header X-Content-Type-Options nosniff;
70-
add_header X-Frame-Options DENY;
71-
add_header X-XSS-Protection "1; mode=block";
72-
73-
location / {
74-
try_files $uri $uri/ /init.php?$query_string;
75-
}
76-
77-
location ~ \.php$ {
78-
include snippets/fastcgi-php.conf;
79-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
80-
fastcgi_pass 127.0.0.1:9000;
81-
}
82-
83-
location ~* \.(css|js|png|jpg|jpeg|gif|svg|ico)$ {
84-
expires 7d;
85-
access_log off;
86-
}
87-
}
88-
}
89-
NGINX-EOF
90-
91-
RUN set -eux; \
92-
cat <<'CRON-EOF' >/etc/cron.d/ska; printf '\n' >>/etc/cron.d/ska; chmod 0644 /etc/cron.d/ska
93-
SHELL=/bin/bash
94-
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
95-
96-
*/1 * * * * www-data /usr/bin/flock -n /tmp/ldap_update.lock /usr/bin/php /srv/keys/scripts/ldap_update.php >> /var/log/ska/ldap_update.log 2>&1
97-
*/5 * * * * www-data /usr/bin/flock -n /tmp/supervise_external_keys.lock /usr/bin/php /srv/keys/scripts/supervise_external_keys.php >> /var/log/ska/supervise_external_keys.log 2>&1
98-
CRON-EOF
99-
100-
RUN set -eux; cat <<'SUPERVISOR-EOF' >/etc/supervisor/conf.d/ska.conf
101-
[program:php-fpm]
102-
command=/usr/sbin/php-fpm -F
103-
stopsignal=QUIT
104-
autostart=true
105-
autorestart=true
106-
startsecs=5
107-
stdout_logfile=/dev/stdout
108-
stdout_logfile_maxbytes=0
109-
stderr_logfile=/dev/stderr
110-
stderr_logfile_maxbytes=0
111-
priority=10
112-
113-
[program:nginx]
114-
command=/usr/sbin/nginx -g "daemon off;"
115-
stopsignal=QUIT
116-
autostart=true
117-
autorestart=true
118-
startsecs=5
119-
stdout_logfile=/dev/stdout
120-
stdout_logfile_maxbytes=0
121-
stderr_logfile=/dev/stderr
122-
stderr_logfile_maxbytes=0
123-
priority=20
124-
125-
[program:cron]
126-
command=/usr/sbin/cron -f
127-
autostart=true
128-
autorestart=true
129-
startsecs=5
130-
stdout_logfile=/dev/stdout
131-
stdout_logfile_maxbytes=0
132-
stderr_logfile=/dev/stderr
133-
stderr_logfile_maxbytes=0
134-
priority=30
135-
136-
[program:keys-syncd]
137-
command=/usr/bin/php /srv/keys/scripts/syncd.php --systemd
138-
directory=/srv/keys
139-
user=keys-sync
140-
# The 'startsecs' option tells Supervisor how many seconds the program must stay running after it is started to be considered successfully started.
141-
# If the process exits before this time, Supervisor will consider it a failure and may attempt to restart it.
142-
startsecs=5
143-
autostart=true
144-
autorestart=true
145-
stdout_logfile=/dev/stdout
146-
stdout_logfile_maxbytes=0
147-
stderr_logfile=/dev/stderr
148-
stderr_logfile_maxbytes=0
149-
priority=40
150-
SUPERVISOR-EOF
39+
RUN chmod 0644 /etc/cron.d/ska
15140

15241
EXPOSE 8080
15342

etc/cron.d/ska

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SHELL=/bin/bash
2+
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
3+
4+
*/1 * * * * www-data /usr/bin/flock -n /tmp/ldap_update.lock /usr/bin/php /srv/keys/scripts/ldap_update.php >> /var/log/ska/ldap_update.log 2>&1
5+
*/5 * * * * www-data /usr/bin/flock -n /tmp/supervise_external_keys.lock /usr/bin/php /srv/keys/scripts/supervise_external_keys.php >> /var/log/ska/supervise_external_keys.log 2>&1

etc/nginx/nginx.conf

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
worker_processes auto;
2+
3+
error_log /dev/stderr info;
4+
5+
pid /run/nginx.pid;
6+
7+
events {
8+
worker_connections 1024;
9+
}
10+
11+
http {
12+
include /etc/nginx/mime.types;
13+
default_type application/octet-stream;
14+
15+
sendfile on;
16+
keepalive_timeout 65;
17+
server_tokens off;
18+
client_max_body_size 16m;
19+
20+
access_log /dev/stdout;
21+
error_log /dev/stderr info;
22+
23+
include /etc/nginx/conf.d/*.conf;
24+
25+
server {
26+
listen 8080 default_server;
27+
listen [::]:8080 default_server;
28+
29+
root /srv/keys/public_html;
30+
index init.php;
31+
32+
add_header X-Content-Type-Options nosniff;
33+
add_header X-Frame-Options DENY;
34+
add_header X-XSS-Protection "1; mode=block";
35+
36+
location / {
37+
try_files $uri $uri/ /init.php?$query_string;
38+
}
39+
40+
location ~ \.php$ {
41+
include snippets/fastcgi-php.conf;
42+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
43+
fastcgi_pass 127.0.0.1:9000;
44+
}
45+
46+
location ~* \.(css|js|png|jpg|jpeg|gif|svg|ico)$ {
47+
expires 7d;
48+
access_log off;
49+
}
50+
}
51+
}
52+

etc/supervisor/conf.d/ska.conf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[program:php-fpm]
2+
command=/usr/sbin/php-fpm -F
3+
stopsignal=QUIT
4+
autostart=true
5+
autorestart=true
6+
startsecs=5
7+
stdout_logfile=/dev/stdout
8+
stdout_logfile_maxbytes=0
9+
stderr_logfile=/dev/stderr
10+
stderr_logfile_maxbytes=0
11+
priority=10
12+
13+
[program:nginx]
14+
command=/usr/sbin/nginx -g "daemon off;"
15+
stopsignal=QUIT
16+
autostart=true
17+
autorestart=true
18+
startsecs=5
19+
stdout_logfile=/dev/stdout
20+
stdout_logfile_maxbytes=0
21+
stderr_logfile=/dev/stderr
22+
stderr_logfile_maxbytes=0
23+
priority=20
24+
25+
[program:cron]
26+
command=/usr/sbin/cron -f
27+
autostart=true
28+
autorestart=true
29+
startsecs=5
30+
stdout_logfile=/dev/stdout
31+
stdout_logfile_maxbytes=0
32+
stderr_logfile=/dev/stderr
33+
stderr_logfile_maxbytes=0
34+
priority=30
35+
36+
[program:keys-syncd]
37+
command=/usr/bin/php /srv/keys/scripts/syncd.php --systemd
38+
directory=/srv/keys
39+
user=keys-sync
40+
# The 'startsecs' option tells Supervisor how many seconds the program must stay running after it is started to be considered successfully started.
41+
# If the process exits before this time, Supervisor will consider it a failure and may attempt to restart it.
42+
startsecs=5
43+
autostart=true
44+
autorestart=true
45+
stdout_logfile=/dev/stdout
46+
stdout_logfile_maxbytes=0
47+
stderr_logfile=/dev/stderr
48+
stderr_logfile_maxbytes=0
49+
priority=40

0 commit comments

Comments
 (0)