-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
FROM php:7.3-fpm AS base | ||
|
||
RUN apt-get update -y \ | ||
&& apt-get install -y nginx | ||
|
||
# PHP_CPPFLAGS are used by the docker-php-ext-* scripts | ||
ENV PHP_CPPFLAGS="$PHP_CPPFLAGS -std=c++11" | ||
|
||
RUN docker-php-ext-install opcache | ||
|
||
# Has all the files AND composer installed constructs everything needed for the app | ||
FROM base AS builder | ||
WORKDIR /app | ||
|
||
# Composer needs git and some zip deps | ||
RUN apt-get install -y git libzip-dev | ||
RUN docker-php-ext-install zip | ||
COPY ./docker/install_composer.sh /tmp/install_composer.sh | ||
RUN /tmp/install_composer.sh && rm /tmp/install_composer.sh | ||
|
||
# Install the dependencies | ||
COPY ./composer.* /app/ | ||
RUN php composer.phar install \ | ||
&& rm -rf /home/root/.composer/cache | ||
|
||
# Copy over our app code | ||
COPY ./www /app/www/ | ||
COPY ./src /app/src/ | ||
|
||
# Now all the app code is over we can build the final autoloader and | ||
# remove composer. | ||
RUN php composer.phar dump-autoload --no-dev \ | ||
&& rm composer.phar | ||
|
||
# This is the final image that we'll serve from | ||
FROM base AS final | ||
WORKDIR /app | ||
RUN { \ | ||
echo 'opcache.memory_consumption=128'; \ | ||
echo 'opcache.interned_strings_buffer=8'; \ | ||
echo 'opcache.max_accelerated_files=4000'; \ | ||
echo 'opcache.revalidate_freq=2'; \ | ||
echo 'opcache.fast_shutdown=1'; \ | ||
echo 'opcache.enable_cli=1'; \ | ||
} > /usr/local/etc/php/conf.d/php-opocache-cfg.ini | ||
|
||
|
||
COPY ./docker/nginx-site.conf /etc/nginx/sites-enabled/default | ||
COPY ./docker/run_app.sh /etc/run_app.sh | ||
|
||
# The builder has already pulled all composer deps & built the autoloader | ||
COPY --from=builder /app /app | ||
|
||
EXPOSE 80 443 | ||
CMD ["/etc/run_app.sh"] | ||
HEALTHCHECK CMD curl http://localhost:80/health-check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: "3" | ||
|
||
services: | ||
dice-api: | ||
build: | ||
context: ./ | ||
dockerfile: Dockerfile | ||
ports: | ||
- "8089:80" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | ||
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" | ||
EXPECTED_SIGNATURE="48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5" | ||
|
||
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] | ||
then | ||
>&2 echo 'ERROR: Invalid installer signature' | ||
rm composer-setup.php | ||
exit 1 | ||
fi | ||
|
||
php composer-setup.php --quiet | ||
RESULT=$? | ||
rm composer-setup.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
server { | ||
root /app/www; | ||
|
||
include /etc/nginx/default.d/*.conf; | ||
|
||
index app.php index.php index.html index.htm; | ||
|
||
client_max_body_size 30m; | ||
|
||
location / { | ||
try_files $uri $uri/ /index.php$is_args$args; | ||
} | ||
|
||
location ~ [^/]\.php(/|$) { | ||
fastcgi_split_path_info ^(.+?\.php)(/.*)$; | ||
# Mitigate https://httpoxy.org/ vulnerabilities | ||
fastcgi_param HTTP_PROXY ""; | ||
fastcgi_pass 127.0.0.1:9000; | ||
fastcgi_index app.php; | ||
include fastcgi.conf; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
service nginx start | ||
php-fpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters