forked from monicahq/monica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
162 lines (145 loc) · 4.63 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
FROM alpine:latest
# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
ARG VCS_REF
ARG COMMIT
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="MonicaHQ, the Personal Relationship Manager" \
org.label-schema.description="This is MonicaHQ, your personal memory! MonicaHQ is like a CRM but for the friends, family, and acquaintances around you." \
org.label-schema.url="https://monicahq.com" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/monicahq/monica" \
org.label-schema.vendor="Monica" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"
RUN set -ex; \
\
apk update; \
apk upgrade; \
apk add --virtual .build-deps \
curl openssl bash \
; \
apk add supervisor netcat-openbsd rsync \
#- base
php7 php7-intl php7-openssl php7-ctype \
php7-zip php7-zlib php7-opcache \
php7-redis \
#- Authentication Guards
php7-session php7-tokenizer \
#- laravel/cashier sabre/vobject sabre/xml
php7-dom \
#- intervention/image
php7-fileinfo \
#- laravel/cashier
php7-gd \
#- composer
php7-phar php7-json php7-iconv \
#- laravel/framework sabre/vobject
php7-mbstring \
#- league/flysystem-aws-s3-v3
php7-simplexml \
#- sabre/vobject sabre/xml
php7-xml php7-xmlreader php7-xmlwriter \
#- mysql
php7-mysqli php7-pdo_mysql \
#- pgsql
php7-pgsql php7-pdo_pgsql \
#- vinkla/hashids
php7-bcmath \
#- sentry/sentry
php7-curl \
#- cbor-php (webauthn)
php7-gmp \
#- web-token/jwt-signature-algorithm-eddsa
php7-sodium
# Create a user to own all the code and assets and give them a working
# directory
RUN set -ex; \
\
mkdir -p /var/www/monica; \
grep -q apache /etc/group || addgroup -S apache; \
adduser -D monica apache -h /var/www/monica
WORKDIR /var/www/monica
# Copy the local (outside Docker) source into the working directory,
# copy system files into their proper homes, and set file ownership
# correctly
COPY --chown=monica:monica \
readme.md \
CONTRIBUTING.md \
CHANGELOG.md \
CONTRIBUTORS \
LICENSE \
artisan \
composer.json \
composer.lock \
./
COPY --chown=monica:monica app ./app
COPY --chown=monica:monica bootstrap ./bootstrap
COPY --chown=monica:monica config ./config
COPY --chown=monica:monica database ./database
COPY --chown=monica:monica public ./public
COPY --chown=monica:monica resources ./resources
COPY --chown=monica:monica routes ./routes
RUN set -ex; \
\
mkdir -p bootstrap/cache; \
mkdir -p storage; \
chown -R monica:apache bootstrap/cache storage; \
chmod -R g+w bootstrap/cache storage
COPY --chown=monica:monica .env.example .env
# Php
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="0" \
PHP_OPCACHE_MAX_ACCELERATED_FILES="20000" \
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"
COPY scripts/docker/opcache.ini /usr/php7/conf.d/opcache.ini
# Sentry
RUN set -ex; \
\
echo $VCS_REF > .sentry-release; \
echo $COMMIT > .sentry-commit; \
mkdir -p /root/.local/bin; \
curl -sL https://sentry.io/get-cli/ | INSTALL_DIR=/root/.local/bin bash
# Composer installation
COPY scripts/docker/install-composer.sh /usr/local/sbin/
RUN install-composer.sh
# Install composer dependencies
USER monica
RUN set -ex; \
\
composer global require hirak/prestissimo; \
mkdir -p storage/framework/views; \
composer install --no-interaction --no-suggest --no-progress --no-dev --ignore-platform-reqs; \
composer global remove hirak/prestissimo; \
\
composer clear-cache; \
rm -rf .composer
USER root
# Set crontab for schedules
RUN set -ex; \
\
cd /etc/periodic/hourly/; \
{ \
echo '#!/bin/sh'; \
echo '/usr/bin/php /var/www/monica/artisan schedule:run -v > /proc/1/fd/1 2> /proc/1/fd/2'; \
} | tee monica; \
chmod a+x monica
# Cleanup
RUN set -ex; \
\
apk del .build-deps; \
rm -rf /var/cache/apk/*
COPY scripts/docker/entrypoint.sh \
scripts/docker/cron.sh \
scripts/docker/queue.sh \
/usr/local/bin/
ENTRYPOINT ["entrypoint.sh"]
# Apache2
RUN apk add apache2 php7-apache2
COPY scripts/docker/apache2-foreground /usr/local/bin/
COPY scripts/docker/000-default.conf /etc/apache2/conf.d/
RUN echo 'LoadModule rewrite_module modules/mod_rewrite.so' > /etc/apache2/conf.d/rewrite.conf; \
echo 'ServerName "monica"' > /etc/apache2/conf.d/hostname.conf
EXPOSE 80
CMD ["apache2-foreground"]