Skip to content

Commit 43a7b4c

Browse files
authored
feat: add mkcert support, fixes #36 (#37)
1 parent 5cfe291 commit 43a7b4c

3 files changed

Lines changed: 28 additions & 5 deletions

File tree

docker-compose.frankenphp.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ services:
2727
- "./php:/usr/local/etc/php/ddev.conf.d"
2828
- ".:/mnt/ddev_config"
2929
- "ddev-global-cache:/mnt/ddev-global-cache"
30+
post_start:
31+
- command: mkcert -install
32+
external_links:
33+
- ddev-router:${DDEV_SITENAME}.${DDEV_TLD}

frankenphp/Dockerfile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ FROM ${FRANKENPHP_DOCKER_IMAGE}
44

55
SHELL ["/bin/bash", "-eu", "-o", "pipefail", "-c"]
66

7-
# Install PHP extensions provided by user
8-
# Always install xdebug, but disable it by default
9-
ARG FRANKENPHP_PHP_EXTENSIONS=""
10-
RUN install-php-extensions xdebug ${FRANKENPHP_PHP_EXTENSIONS} && rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
11-
127
# Add a new user and give it ownership of frankenphp related files
138
ARG username
149
ARG uid
@@ -20,6 +15,22 @@ RUN <<EOF
2015
chown -R ${username}:${username} /data/caddy /config/caddy
2116
EOF
2217

18+
RUN (apt-get update || true) && apt-get install -y --no-install-recommends sudo \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# CAROOT for `mkcert` to use, has the CA config
22+
ENV CAROOT=/mnt/ddev-global-cache/mkcert
23+
# Give the `${username}` user full `sudo` privileges
24+
RUN mkdir -p /etc/sudoers.d && echo "${username} ALL=(ALL) NOPASSWD: ALL" >> "/etc/sudoers.d/${username}" && chmod 0440 "/etc/sudoers.d/${username}"
25+
# Install the correct architecture binary of `mkcert`
26+
ARG TARGETARCH
27+
RUN mkdir -p /usr/local/bin && curl --fail -JL -s -o /usr/local/bin/mkcert "https://dl.filippo.io/mkcert/latest?for=linux/${TARGETARCH}" && chmod +x /usr/local/bin/mkcert
28+
29+
# Install PHP extensions provided by user
30+
# Always install xdebug, but disable it by default
31+
ARG FRANKENPHP_PHP_EXTENSIONS=""
32+
RUN install-php-extensions xdebug ${FRANKENPHP_PHP_EXTENSIONS} && rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
33+
2334
# Enable xdebug on demand with custom DDEV config
2435
ARG FRANKENPHP_XDEBUG=false
2536
RUN <<EOF

tests/test.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ health_checks() {
104104
assert_output "FrankenPHP page without worker"
105105
fi
106106

107+
run ddev exec -s frankenphp curl -sf https://${PROJNAME}.ddev.site
108+
assert_success
109+
if [[ "${FRANKENPHP_WORKER}" == "true" ]]; then
110+
assert_output --partial "FrankenPHP Worker Demo"
111+
else
112+
assert_output "FrankenPHP page without worker"
113+
fi
114+
107115
run curl -sf http://${PROJNAME}.ddev.site
108116
assert_success
109117
if [[ "${FRANKENPHP_WORKER}" == "true" ]]; then

0 commit comments

Comments
 (0)