Skip to content

Commit

Permalink
fixed dockerfile image for php in order to install correctly the depe…
Browse files Browse the repository at this point in the history
…ndencies with composer + updated parameters for cloudformation
  • Loading branch information
fabiocicerchia committed Jun 11, 2021
1 parent 74ca85d commit f9f38bf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.env
*.md
.git
node_modules/
Expand Down
7 changes: 5 additions & 2 deletions src/Contributors/Model/Contributor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ final class Contributor implements \Stringable
{
private const DEFAULT_IMG_SIZE = 160;

private function __construct(private string $username, private string $profileUrl, private string $profileImg, private int $size = self::DEFAULT_IMG_SIZE)
private function __construct(private string $username, private string $profileUrl, private string $profileImg, private ?int $size = null)
{
}

Expand Down Expand Up @@ -34,8 +34,11 @@ private function getUrlSeparator(string $url): string

public function getProfileImg(): string
{
// Very annoying bug happening only on prod, triggering the following error:
// Uncaught PHP Exception Error: "Typed property App\\Contributors\\Model\\Contributor::$size must not be accessed before initialization"
$size = empty($this->size) ? self::DEFAULT_IMG_SIZE : $this->size;
$sep = $this->getUrlSeparator($this->profileImg);
$qs = \http_build_query(['s' => $this->size]);
$qs = \http_build_query(['s' => $size]);

return $this->profileImg.$sep.$qs;
}
Expand Down
6 changes: 3 additions & 3 deletions sys/cloudformation/parameters.prod.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{"ParameterKey": "ELBCertificateArn", "ParameterValue": ""},
{"ParameterKey": "EcrImageTagNginx", "ParameterValue": "1617796334"},
{"ParameterKey": "EcrImageTagPhp", "ParameterValue": "1617796334"},
{"ParameterKey": "EcrImageTagPhpCanary", "ParameterValue": "1617796334"},
{"ParameterKey": "EcrImageTagNginx", "ParameterValue": "1623402500"},
{"ParameterKey": "EcrImageTagPhp", "ParameterValue": "1623402500"},
{"ParameterKey": "EcrImageTagPhpCanary", "ParameterValue": "1623402500"},
{"ParameterKey": "Environment", "ParameterValue": "prod"},
{"ParameterKey": "ExecRoleArn", "ParameterValue": ""},
{"ParameterKey": "Subnets", "ParameterValue": ""},
Expand Down
2 changes: 1 addition & 1 deletion sys/docker/alpine-phpfpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so

COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer

RUN /usr/local/bin/composer install --no-plugins --no-scripts --optimize-autoloader --no-ansi --no-interaction --no-progress --ignore-platform-reqs \
RUN /usr/local/bin/composer install --optimize-autoloader --no-ansi --no-interaction --no-progress \
&& apk del .builddeps \
&& php-fpm -t \
&& php-fpm -tt
Expand Down
6 changes: 5 additions & 1 deletion sys/docker/alpine-phpfpm/start.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/bin/sh

if [ "$ENABLE_CW" = "1" ]; then
echo "Enabling CloudWatch Agent"
/opt/aws/amazon-cloudwatch-agent/bin/start-amazon-cloudwatch-agent
fi

if [ "$APP_ENV" = "prod" ]; then
echo "Dumping .env for $APP_ENV"
cd /application
/usr/local/bin/composer dump-env $APP_ENV
printenv | egrep $(printf "%s" "$(egrep -v "^#|^$" .env | sed "s/=.*//")" | tr "\n" "|") > .env.new && mv .env.new .env
echo "COMPOSER_ALLOW_SUPERUSER=1 /usr/local/bin/composer dump-env $APP_ENV"
COMPOSER_ALLOW_SUPERUSER=1 /usr/local/bin/composer dump-env $APP_ENV
fi

set -e
Expand Down

0 comments on commit f9f38bf

Please sign in to comment.