-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
66 lines (50 loc) · 2.5 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
# adapted from https://github.com/Anteris-Dev/docker-laravel-roadrunner
# Here we are going to install Laravel extension requirements that did not come
# with the default PHP image. This will be necessary for Laravel and RoadRunner.
FROM php:8.1-cli-alpine as php-base
WORKDIR /srv/laravel
RUN apk add --no-cache libzip-dev postgresql-dev && \
docker-php-ext-install bcmath ctype pdo_pgsql pcntl sockets && \
rm -rf /var/www && \
chown -R www-data:www-data /srv/laravel
# This stage is so that we can build up everything that doesn't require Laravel
# so as to not bust the caching for those items.
FROM php-base as octane-base
COPY --from=spiralscout/roadrunner:2.2.1 /usr/bin/rr /usr/bin/rr
# This really shouldn't be modified, so we aren't advertising the env variable.
# It allows us to globally install chokidar without modifying the Laravel package.json.
ENV NODE_PATH "/home/www-data/.npm-global/lib/node_modules"
RUN apk add --no-cache nodejs npm && \
mkdir "/home/www-data/.npm-global/" && \
npm config set prefix "/home/www-data/.npm-global/" && \
npm install -g chokidar
# Here we have a build container so that it is not necessary to pull composer into
# the final container. We are going to create a new Laravel project and install Octane.
FROM php-base as laravel
ARG LARAVEL_VERSION="8.*"
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY . /srv/laravel
RUN cd /srv/laravel && \
composer install && \
php artisan octane:install --server="roadrunner" && \
composer dump-autoload
#RUN cd /srv && \
#composer create-project laravel/laravel="${LARAVEL_VERSION}" laravel && \
#cd /srv/laravel && \
#composer require laravel/octane spiral/roadrunner && \
#php artisan octane:install --server="roadrunner" && \
#rm "/srv/laravel/.env"
# This is our final container. We will install the RoadRunner binary and copy over
# our built version of Laravel.
FROM octane-base
USER www-data
COPY --from=laravel --chown=www-data:www-data /srv/laravel/ /srv/laravel/
# Allow the user to specify RoadRunner options via ENV variables.
ENV ROADRUNNER_MAX_REQUESTS "500"
ENV ROADRUNNER_WATCH $false
ENV ROADRUNNER_WORKERS "auto"
# Expose the ports that Octane is using.
EXPOSE 8000
# Check the health status using the Octane status command.
HEALTHCHECK CMD php artisan octane:status --server="roadrunner"
CMD [ "./start.sh" ]