-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
101 lines (80 loc) · 2.91 KB
/
Dockerfile
File metadata and controls
101 lines (80 loc) · 2.91 KB
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
### --- First Stage: Base Image --- ###
FROM dunglas/frankenphp:builder AS builder
COPY --from=caddy:builder /usr/bin/xcaddy /usr/bin/xcaddy
RUN CGO_ENABLED=1 \
XCADDY_SETCAP=1 \
XCADDY_GO_BUILD_FLAGS="-ldflags='-w -s' -tags=nobadger,nomysql,nopgx" \
CGO_CFLAGS=$(php-config --includes) \
CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" \
xcaddy build \
--output /usr/local/bin/frankenphp \
--with github.com/dunglas/frankenphp=./ \
--with github.com/dunglas/frankenphp/caddy=./caddy/ \
--with github.com/dunglas/caddy-cbrotli \
# Add extra Caddy modules here \
--with github.com/baldinof/caddy-supervisor
RUN install-php-extensions \
pdo_mysql \
intl \
zip \
opcache \
apcu \
amqp \
pdo_mysql \
pcntl \
xsl \
sysvsem \
brotli \
zstd \
zlib \
imagick \
gd \
bcmath
# Copy shared libs of frankenphp and all installed extensions to temporary location
# You can also do this step manually by analyzing ldd output of frankenphp binary and each extension .so file
RUN <<-EOF
apt-get update
apt-get install -y --no-install-recommends libtree
mkdir -p /tmp/libs
for target in $(which frankenphp) \
$(find "$(php -r 'echo ini_get("extension_dir");')" -maxdepth 2 -name "*.so"); do
libtree -pv "$target" 2>/dev/null | grep -oP '(?:── )\K/\S+(?= \[)' | while IFS= read -r lib; do
[ -f "$lib" ] && cp -n "$lib" /tmp/libs/
done
done
EOF
FROM dunglas/frankenphp AS base
LABEL maintainer="SchulIT" \
description="Anwendung zur Verwaltung der Schulbuchausleihe"
COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
COPY --from=builder /usr/local/lib/php/extensions /usr/local/lib/php/extensions
COPY --from=builder /tmp/libs /usr/lib
COPY --from=builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d
COPY --from=builder /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
# Set DB version so that symfony does not try to connect to a real DB
ENV DATABASE_SERVER_VERSION=10.11.0-MariaDB
# Install composer
RUN install-php-extensions @composer
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER=1
# Set working directory
WORKDIR /app
# Copy whole project into image
COPY . .
# Run composer install
RUN composer install --no-dev --classmap-authoritative --no-scripts
# Install assets (copy 3rd party stuff)
RUN php bin/console assets:install
# Install JS/CSS assets
RUN php bin/console importmap:install
# Compile assets
RUN php bin/console asset-map:compile
# Copy startup.sh
COPY .docker/startup.sh startup.sh
RUN chmod +x startup.sh
# Copy Caddyfile
COPY .docker/Caddyfile /etc/caddy/Caddyfile
# Export HTTP port
EXPOSE 80
HEALTHCHECK --start-period=60s CMD php -r 'exit(false === @file_get_contents("http://localhost:2019/metrics", context: stream_context_create(["http" => ["timeout" => 5]])) ? 1 : 0);'
CMD ["./startup.sh"]