Skip to content

Commit 691f882

Browse files
authored
feat: docker with built-in PHP webserver (#28)
1 parent 8928715 commit 691f882

7 files changed

Lines changed: 79 additions & 108 deletions

File tree

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
ARG PHP_VERSION=8.3
2+
3+
FROM composer:lts AS composer
4+
5+
FROM php:$PHP_VERSION-cli
6+
7+
WORKDIR /app
8+
VOLUME /app
9+
10+
RUN apt-get update \
11+
&& apt-get install -y --no-install-recommends \
12+
git \
13+
libicu-dev \
14+
libfreetype-dev \
15+
libjpeg62-turbo-dev \
16+
libpng-dev \
17+
unzip \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
21+
&& docker-php-ext-install -j$(nproc) gd intl
22+
23+
RUN pecl channel-update pecl.php.net \
24+
&& pecl install xdebug \
25+
&& docker-php-ext-enable xdebug
26+
27+
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
28+
29+
COPY --from=composer /usr/bin/composer /usr/bin/composer
30+
31+
EXPOSE 80

README.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44

55
# Website Kickstarter for Herbie CMS
66

7-
## Installation
7+
## Run Website Using PHP and Composer
88

9-
You can start your new Herbie CMS website by using Composer.
9+
Create project and install dependencies.
1010

1111
composer create-project getherbie/start-website mywebsite
1212

13-
This will install a simple demo website and all required dependencies.
14-
15-
## Run website using built-in web server
16-
1713
In your terminal go to the web directory and start the built-in web server.
1814

1915
cd mywebsite/web
@@ -32,24 +28,18 @@ If you want to debug using Xdebug (3.x), start the web server as follows.
3228

3329
For this to work, Xdebug must of course be installed.
3430

35-
## Run website using Docker
31+
## Run Website Using Docker and Docker Compose
32+
33+
Create project and install dependencies.
3634

37-
The Docker configuration files can be found here:
35+
docker run --rm -v $PWD:/app composer create-project --ignore-platform-reqs getherbie/start-website mywebsite
3836

39-
```
40-
docker-compose.yml
41-
docker
42-
- nginx
43-
- app.conf
44-
docker
45-
- php
46-
- Dockerfile
47-
- php.ini
48-
```
37+
Go to the `mywebsite` directory and start website.
4938

50-
Start the Docker container by using `docker-compose up -d` in the root directory of the website.
39+
cd mywebsite
40+
docker compose up website
5141

52-
Then, open <http://0.0.0.0:8888> in your browser.
42+
Open <http://localhost:8888> with your browser.
5343

5444
## More Information
5545

compose.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
services:
2+
website:
3+
build:
4+
context: .
5+
args:
6+
- PHP_VERSION=${PHP_VERSION:-8.3}
7+
profiles: [website]
8+
environment:
9+
- XDEBUG_MODE=debug
10+
- XDEBUG_CONFIG="client_host=host.docker.internal"
11+
working_dir: "/app"
12+
command: ["php", "-S", "0.0.0.0:80", "-t", "/app/web"]
13+
volumes:
14+
- .:/app
15+
ports:
16+
- "8888:80"
17+
depends_on:
18+
- install
19+
install:
20+
build:
21+
context: .
22+
args:
23+
- PHP_VERSION=${PHP_VERSION:-8.3}
24+
profiles: [website]
25+
working_dir: "/app"
26+
command: ["composer", "install"]
27+
volumes:
28+
- .:/app
29+
bash:
30+
build:
31+
context: .
32+
args:
33+
- PHP_VERSION=${PHP_VERSION:-8.3}
34+
profiles: [website]
35+
working_dir: "/app"
36+
command: ["bash"]
37+
volumes:
38+
- .:/app

docker-compose.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

docker/nginx/app.conf

Lines changed: 0 additions & 26 deletions
This file was deleted.

docker/php/Dockerfile

Lines changed: 0 additions & 28 deletions
This file was deleted.

docker/php/php.ini

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)