-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
120 lines (103 loc) · 4.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
# syntax=docker/dockerfile:1.2
# # Build application front-end (you can drop this block at all if you want)
# FROM node:15.14.0-alpine as frontend
# # copy all application sources
# COPY . /app/
# # use directory with application sources by default
# WORKDIR /app
# # build frontend
# RUN set -x \
# && yarn install --frozen-lockfile --no-progress --non-interactive \
# && NODE_ENV="production" yarn run prod
# Build application runtime, image page: <https://hub.docker.com/_/php>
FROM --platform=linux/amd64 php:8.0.6-alpine as runtime
# install composer, image page: <https://hub.docker.com/_/composer>
#COPY --from=composer:2.0.13 /usr/bin/composer /usr/bin/composer
# Image page: <https://hub.docker.com/r/spiralscout/roadrunner>
COPY --from=spiralscout/roadrunner:2.1.1 /usr/bin/rr /usr/bin/rr
# PHP Extension Installer: <https://github.com/mlocati/docker-php-extension-installer>
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
#ENV COMPOSER_HOME="/tmp/composer"
RUN set -x \
# install permanent dependencies
&& apk add --no-cache \
# postgresql-libs \
icu-libs \
# install build-time dependencies
&& apk add --no-cache --virtual .build-deps \
# postgresql-dev \
# autoconf \
# openssl \
# make \
# g++ \
# install PHP extensions
&& install-php-extensions \
# pdo_pgsql \
pdo_mysql \
sockets \
opcache \
pcntl \
redis \
# intl \
1>/dev/null \
# && pecl install -o redis 1>/dev/null \
# && echo 'extension=redis.so' > ${PHP_INI_DIR}/conf.d/redis.ini \
# install supercronic (for laravel task scheduling), project page: <https://github.com/aptible/supercronic>
# && wget -q "https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64" \
# -O /usr/bin/supercronic \
# && chmod +x /usr/bin/supercronic \
# && mkdir /etc/supercronic \
# && echo '*/1 * * * * php /app/artisan schedule:run' > /etc/supercronic/laravel \
# generate self-signed SSL key and certificate files
# && openssl req -x509 -nodes -days 1095 -newkey rsa:2048 \
# -subj "/C=CA/ST=QC/O=Company, Inc./CN=mydomain.com" \
# -addext "subjectAltName=DNS:mydomain.com" \
# -keyout /etc/ssl/private/selfsigned.key \
# -out /etc/ssl/certs/selfsigned.crt \
# && chmod 644 /etc/ssl/private/selfsigned.key \
# make clean up
# && docker-php-source delete \
&& apk del .build-deps \
# && rm -R /tmp/pear \
# enable opcache for CLI and JIT, docs: <https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit>
&& echo -e "\nopcache.enable=1\nopcache.enable_cli=1\nopcache.jit_buffer_size=32M\nopcache.jit=1235\n" >> \
${PHP_INI_DIR}/conf.d/docker-php-ext-opcache.ini \
# show installed PHP modules
&& php -m \
# create unprivileged user
&& adduser \
--disabled-password \
--shell "/sbin/nologin" \
--home "/nonexistent" \
--no-create-home \
--uid "10001" \
--gecos "" \
"appuser" \
# create directory for application sources and roadrunner unix socket
&& mkdir /app /var/run/rr \
&& chown -R appuser:appuser /app /var/run/rr \
&& chmod -R 777 /var/run/rr
# use an unprivileged user by default
USER appuser:appuser
# use directory with application sources by default
WORKDIR /app
# copy composer (json|lock) files for dependencies layer caching
COPY --chown=appuser:appuser ./composer.* /app/
# install composer dependencies (autoloader MUST be generated later!)
# RUN composer install -n --no-dev --no-cache --no-ansi --no-autoloader --no-scripts --prefer-dist
# copy application sources into image (completely)
COPY --chown=appuser:appuser . /app/
RUN chmod -R 777 cmd.sh
# # copy front-end artifacts into image
# COPY --from=frontend --chown=appuser:appuser /app/public /app/public
# RUN set -x \
# # generate composer autoloader and trigger scripts
# && composer dump-autoload -n --optimize \
# # "fix" composer issue "Cannot create cache directory /tmp/composer/cache/..." for docker-compose usage
# && chmod -R 777 ${COMPOSER_HOME}/cache \
# # create the symbolic links configured for the application
# && php ./artisan storage:link
# unset default image entrypoint
ENTRYPOINT []
EXPOSE 8080
CMD ["./cmd.sh"]