Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
env: Changed dev docker file and added proper one for production build.
- Loading branch information
Showing
3 changed files
with
80 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,34 @@ | ||
FROM composer:1.8.6 AS composer | ||
FROM php:7.2.19-fpm | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
zlib1g-dev libxml2-dev nano vim git unzip jq \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN docker-php-ext-install -j$(nproc) bcmath \ | ||
&& docker-php-ext-install pdo \ | ||
&& docker-php-ext-install pdo_mysql \ | ||
&& docker-php-ext-install zip | ||
|
||
# copy the Composer PHAR from the Composer image into the PHP image | ||
COPY --from=composer /usr/bin/composer /usr/bin/composer | ||
|
||
ENV COMPOSER_ALLOW_SUPERUSER 1 | ||
ENV APP_ENV prod | ||
|
||
WORKDIR /app | ||
|
||
COPY . /app | ||
COPY ./docker/php/php.ini /usr/local/etc/php/php.ini | ||
|
||
RUN chmod +x /app/bin/console | ||
RUN chmod +x /app/docker-entrypoint.sh | ||
RUN chmod +x /usr/bin/composer | ||
|
||
RUN rm -rf /app/var \ | ||
&& mkdir -p /app/var \ | ||
&& php -d memory_limit=-1 /usr/bin/composer install --no-dev --optimize-autoloader | ||
|
||
EXPOSE 9000 | ||
|
||
ENTRYPOINT ["/app/docker-entrypoint.sh"] |
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
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,45 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# | ||
# If we're starting web-server we need to do following: | ||
# 1) Ensure that /app/var directory exists | ||
# 2) Generate JWT encryption keys + allow web server to read this file | ||
# 3) Clear and warmup caches on current environments | ||
# 4) Create database if it not exists yet | ||
# 5) Run possible migrations, so that database is always up to date | ||
# 6) Install public assets | ||
# 7) Copy _all_ files to shared folder so that Nginx use those properly | ||
# | ||
# Note that in production environment we cannot use `symfony` binary to wrap | ||
# these commands because for some reason current environment variables from | ||
# docker context won't be passed to php process. | ||
# | ||
|
||
if [ "$1" = 'php-fpm' ]; then | ||
# Step 1 | ||
mkdir -p /app/var | ||
|
||
# Step 2 | ||
make generate-jwt-keys | ||
chmod 644 /app/config/jwt/private.pem | ||
|
||
# Step 3 | ||
./bin/console cache:clear --no-ansi | ||
./bin/console cache:warmup --no-ansi | ||
|
||
# Step 4 | ||
./bin/console doctrine:database:create --if-not-exists --no-interaction --no-ansi | ||
|
||
# Step 5 | ||
./bin/console doctrine:migrations:migrate --no-interaction --no-ansi | ||
|
||
# Step 6 | ||
./bin/console assets:install --symlink --relative --no-interaction --no-ansi --env prod | ||
|
||
# Step 7 | ||
chmod -R o+s+w /app | ||
cp -bar /app /shared/app | ||
fi | ||
|
||
exec "$@" |