Skip to content

Commit bbcf41a

Browse files
Dockerization added.
1 parent 464a025 commit bbcf41a

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Use the official PHP image as the base image
2+
FROM php:8.3-fpm
3+
4+
# Set working directory
5+
WORKDIR /var/www/html
6+
7+
# Install system dependencies
8+
RUN apt-get update && apt-get install -y \
9+
git \
10+
unzip
11+
12+
# Install Composer
13+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
14+
15+
# Copy existing application directory contents
16+
COPY . /var/www/html
17+
18+
# Install PHP dependencies
19+
RUN composer install
20+
21+
# Expose port 9000 and start php-fpm server
22+
EXPOSE 9000
23+
CMD ["php-fpm"]

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ After choosing and installing the packages you want, go to the
5252
$ composer serve
5353
```
5454

55+
Or use Docker Compose to run the app:
56+
57+
```bash
58+
$ cp nginx.conf.dist nginx.conf
59+
$ docker compose up -d
60+
```
61+
5562
You can then browse to http://localhost:8080.
5663

5764
## Installing alternative packages

docker-compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
services:
2+
php:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
volumes:
7+
- .:/var/www/html
8+
expose:
9+
- 9000
10+
11+
nginx:
12+
image: nginx:latest
13+
ports:
14+
- "80:80"
15+
volumes:
16+
- .:/var/www/html
17+
- ./nginx.conf:/etc/nginx/nginx.conf
18+
depends_on:
19+
- php

nginx.conf.dist

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
events {
2+
worker_connections 1024;
3+
}
4+
5+
http {
6+
server {
7+
listen 80;
8+
server_name localhost;
9+
10+
root /var/www/html;
11+
index public/index.php index.html index.htm;
12+
13+
location / {
14+
try_files $uri $uri/ /public/index.php?$query_string;
15+
autoindex on;
16+
}
17+
18+
location ~ \.php$ {
19+
include fastcgi_params;
20+
fastcgi_pass php:9000;
21+
fastcgi_index public/index.php;
22+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
23+
}
24+
25+
location ~ /\.ht {
26+
deny all;
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)