-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp-podman.mk
More file actions
82 lines (65 loc) · 2.42 KB
/
php-podman.mk
File metadata and controls
82 lines (65 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
.PHONY: check-pod
PHP_VERSION ?= 8.2
POSTGRES_PASSWORD ?= !ChangeMe!
WEB_PORT ?= 8080
# Build an FPM image for dev
build-php-fpm:
podman build --tag php-fpm:${PHP_VERSION} --build-arg PHP_VERSION=${PHP_VERSION} --target dev -f container/php/Containerfile .
# build a tools container with composer
build-php-tools:
podman build --tag php-tools:${PHP_VERSION} --build-arg PHP_VERSION=${PHP_VERSION} --target tools -f container/php/Containerfile .
build: build-php-tools build-php-fpm
start-fpm: check-pod
podman run -dt --replace \
--name $(shell basename $(CURDIR))-fpm \
--pod $(shell basename $(CURDIR)) \
-w /code \
-v $(CURDIR)/:/code \
-v $(CURDIR)/container/php/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
-v $(CURDIR)/container/php/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini \
-e PHP_IDE_CONFIG="serverName=localhost" \
php-fpm:${PHP_VERSION}
stop-fpm:
podman container rm -fv $(shell basename $(CURDIR))-fpm
start-nginx: check-pod
podman run -dt --replace \
--name $(shell basename $(CURDIR))-nginx \
--pod $(shell basename $(CURDIR)) \
-v $(CURDIR)/container/nginx/default.conf:/etc/nginx/conf.d/default.conf \
-v $(CURDIR)/:/code \
-e PHP_IDE_CONFIG="serverName=localhost" \
nginx:alpine
stop-nginx:
podman container rm -fv $(shell basename $(CURDIR))-nginx
start-pg: check-pod
@if ! podman volume exists pg-data; then \
echo "Volume pg-data not exists... creating..."; \
podman volume create pg-data; \
fi
podman run -dt --replace \
--name $(shell basename $(CURDIR))-pg \
--pod $(shell basename $(CURDIR)) \
-v pg-data:/var/lib/postgresql/data \
-e POSTGRES_PASSWORD=${POSTGRES_PASSWORD} \
-e POSTGRES_USER=symfony \
-e POSTGRES_DB=public \
-e LANG=de_DE.utf8 \
-e POSTGRES_INITDB_ARGS='--locale-provider=icu --icu-locale=de-DE' \
--env-file=$(CURDIR)/container/database/.env \
postgres:15-alpine3.18
stop-pg:
podman container rm -fv $(shell basename $(CURDIR))-pg
rem-pg-data:
podman volume rm -f pg-data
start: check-pod build start-pg start-fpm start-nginx
stop: stop-fpm stop-nginx stop-pg stop-pod
check-pod:
@if ! podman pod exists $(shell basename $(CURDIR)); then \
echo "Pod is not running. Starting the pod..."; \
podman pod create -p "${WEB_PORT}:80" --name $(shell basename $(CURDIR)); \
else \
echo "Pod $(shell basename $(CURDIR)) is already running."; \
fi
start-pod: check-pod
stop-pod:
podman pod rm -f $(shell basename $(CURDIR))