Skip to content

Commit 224ef9c

Browse files
graysideknative-prow-robot
authored andcommitted
serving/helloworld-php: Respect the PORT env var (#460)
* serving/helloworld-php: Respect the PORT env var * serving/helloworld-php: add a comment to explain sed command
1 parent e3516ff commit 224ef9c

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

serving/samples/helloworld-php/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ FROM php:7.2.6-apache
22

33
COPY index.php /var/www/html/
44

5-
# Run on port 8080 rather than 80
6-
RUN sed -i 's/80/8080/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf
5+
ENV PORT 8080
6+
7+
# Use the PORT environment variable in Apache configuration files.
8+
RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf

serving/samples/helloworld-php/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ following instructions recreate the source files from this folder.
2929

3030
```php
3131
<?php
32-
$target = getenv('TARGET', true) ?: "World";
33-
echo sprintf("Hello %s!\n", $target);
34-
?>
32+
$target = getenv('TARGET', true) ?: "World";
33+
echo sprintf("Hello %s!\n", $target);
3534
```
3635

3736
1. Create a file named `Dockerfile` and copy the code block below into it.
@@ -42,8 +41,10 @@ following instructions recreate the source files from this folder.
4241
4342
COPY index.php /var/www/html/
4443
45-
# Run on port 8080 rather than 80
46-
RUN sed -i 's/80/8080/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf
44+
ENV PORT 8080
45+
46+
RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf
47+
4748
```
4849

4950
1. Create a new file, `service.yaml` and copy the following service definition
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
<?php
2-
$target = getenv('TARGET', true) ?: "World";
3-
echo sprintf("Hello %s!\n", $target);
4-
?>
2+
$target = getenv('TARGET', true) ?: 'World';
3+
echo sprintf('Hello %s!\n', $target);

0 commit comments

Comments
 (0)