forked from grocy/grocy-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Containerfile-backend
90 lines (74 loc) · 2.78 KB
/
Containerfile-backend
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
ARG PLATFORM
FROM --platform=${PLATFORM} docker.io/alpine:3.16.1
LABEL maintainer "Talmai Oliveira <to@talm.ai>, James Addison <jay@jp-hosting.net>"
ARG GROCY_VERSION
ARG COMPOSER_VERSION
ARG COMPOSER_CHECKSUM
# ensure www-data user exists
RUN set -eux; \
adduser -u 82 -D -S -G www-data www-data
# 82 is the standard uid/gid for "www-data" in Alpine
# https://git.alpinelinux.org/aports/tree/main/apache2/apache2.pre-install?h=3.14-stable
# https://git.alpinelinux.org/aports/tree/main/lighttpd/lighttpd.pre-install?h=3.14-stable
# https://git.alpinelinux.org/aports/tree/main/nginx/nginx.pre-install?h=3.14-stable
# Install build-time dependencies
RUN apk update && \
apk add --no-cache \
git \
gnupg \
wget
# Install system dependencies
RUN apk add --no-cache \
php8 \
php8-ctype \
php8-fpm \
php8-exif \
php8-fileinfo \
php8-gd \
php8-iconv \
php8-ldap \
php8-pdo_sqlite \
php8-simplexml \
php8-tokenizer \
php8-phar \
php8-curl \
php8-mbstring \
php8-openssl \
php8-zip \
php8-intl
# Install composer from source instead of using (php7-dependent) Alpine Linux package
# See: https://gitlab.alpinelinux.org/alpine/aports/-/issues/12308
RUN wget https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar -O /tmp/composer.phar && \
echo "${COMPOSER_CHECKSUM} /tmp/composer.phar" | sha256sum -c - && \
mv /tmp/composer.phar /usr/bin/composer && chmod +x /usr/bin/composer
# Configure directory permissions
RUN chown www-data /var/log/php8 && \
mkdir /var/www && \
chown www-data /var/www
COPY static/backend/www.conf /etc/php8/php-fpm.d/zz-docker.conf
# Install application dependencies (unprivileged)
USER www-data
WORKDIR /var/www
# Extract application release package
ENV GROCY_RELEASE_KEY_URI="https://berrnd.de/data/Bernd_Bestel.asc"
RUN set -o pipefail && \
export GNUPGHOME=$(mktemp -d) && \
wget ${GROCY_RELEASE_KEY_URI} -O - | gpg --batch --import && \
git clone --branch ${GROCY_VERSION} --config advice.detachedHead=false --depth 1 "https://github.com/grocy/grocy.git" . && \
git verify-commit ${GROCY_VERSION} && \
rm -rf ${GNUPGHOME} && \
mkdir data/viewcache && \
cp config-dist.php data/config.php
# Install application dependencies
RUN composer install --no-interaction --no-dev --optimize-autoloader && \
composer clear-cache
# Remove build-time dependencies (privileged)
USER root
RUN apk del \
git \
gnupg \
wget
VOLUME ["/var/www/data"]
EXPOSE 9000
USER www-data
CMD ["php-fpm8"]