Skip to content

Commit ddc564c

Browse files
committed
Merge branch 'main' of github.com:opencodeco/phpctl
2 parents a75daba + ba47dd1 commit ddc564c

File tree

10 files changed

+66
-18
lines changed

10 files changed

+66
-18
lines changed

.devcontainer/devcontainer.json

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
{
22
"image": "opencodeco/phpctl:php83-devcontainer",
3+
"containerEnv": {
4+
"PHP_VERSION": "83"
5+
},
36
"features": {
47
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
58
"ghcr.io/devcontainers-contrib/features/devcontainers-cli:1": {},
6-
"ghcr.io/devcontainers/features/sshd:1": {}
7-
},
8-
"customizations": {
9-
"vscode": {
10-
"extensions": [
11-
"ms-vscode.makefile-tools",
12-
"ms-azuretools.vscode-docker",
13-
"timonwong.shellcheck"
14-
]
9+
"ghcr.io/devcontainers/features/sshd:1": {},
10+
"ghcr.io/devcontainers-contrib/features/apt-get-packages:1": {
11+
"packages": "parallel"
1512
}
1613
}
1714
}

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ build:
88
.PHONY: test
99
test:
1010
@parallel --line-buffer PHP_VERSION={} COMPOSER_AUTH= TERM= ./bin/notty ./lib/bashunit ./tests/ ::: 81 82 83
11+
@[ -f phpctl.ini ] && rm phpctl.ini
1112

1213
.PHONY: install
1314
install:

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
<h1>
88
phpctl
99
<a href="https://github.com/opencodeco/phpctl/actions/workflows/docker.yml"><img alt="phpctl docker badge" src="https://github.com/opencodeco/phpctl/actions/workflows/docker.yml/badge.svg"></a>
10+
<a href="https://github.com/opencodeco/phpctl/actions/workflows/devcontainer.yml"><img alt="phpctl docker badge" src="https://github.com/opencodeco/phpctl/actions/workflows/devcontainer.yml/badge.svg"></a>
1011
<a href="https://github.com/opencodeco/phpctl/actions/workflows/frankenphp.yml"><img alt="phpctl frankenphp badge" src="https://github.com/opencodeco/phpctl/actions/workflows/frankenphp.yml/badge.svg"></a>
1112
</h1>
1213
<p>🐳 A Docker-based development environment for PHP 🐘</p>
1314
<blockquote>Heavily inspired by <a href="https://github.com/opencodeco/hfctl">opencodeco/hfctl</a>.</blockquote>
15+
<p><a href="https://codespaces.new/opencodeco/phpctl?machine=standardLinux32gb"><img alt="Open in GitHub Codespaces" src="https://github.com/codespaces/badge.svg"></a></p>
1416
</td>
1517
</tr>
1618
</table>
@@ -32,6 +34,15 @@ php --version
3234
composer --version
3335
```
3436

37+
Using [Dev Containers](https://containers.dev/)? We have a pre-built image:
38+
```json
39+
{
40+
"image": "opencodeco/phpctl:php83-devcontainer"
41+
}
42+
```
43+
In fact, we use it ourselves to develop `phpctl` itself: [devcontainer.json](.devcontainer/devcontainer.json).
44+
45+
3546
## Getting started
3647

3748
- [Installation guide](https://phpctl.dev/#installation)

bin/phpctl

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#!/usr/bin/env bash
22
PHPCTL_DIR=$(dirname "$(realpath "$0")")/../
3+
4+
if [ -s "$HOME/.phpctlrc" ]; then
5+
set -a
6+
. "$HOME/.phpctlrc"
7+
set +a
8+
fi
9+
310
if [ -s .phpctlrc ]; then
411
set -a
512
. .phpctlrc

rootfs/usr/local/bin/install-swoole

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env sh
2+
set -e
3+
4+
SWOOLE_VERSION="5.1.2"
5+
echo "Installing Swoole $SWOOLE_VERSION"
6+
7+
# Download
8+
cd /usr/local/src
9+
wget -q "https://github.com/swoole/swoole-src/archive/refs/tags/v${SWOOLE_VERSION}.zip"
10+
unzip -q "v${SWOOLE_VERSION}.zip"
11+
12+
# Install
13+
cd "swoole-src-${SWOOLE_VERSION}"
14+
phpize
15+
./configure --enable-sockets --enable-openssl --enable-brotli --enable-mysqlnd --enable-cares --enable-swoole-curl --enable-swoole-pgsql --enable-swoole-sqlite
16+
make -j$(nproc)
17+
make install
18+
echo "extension=swoole.so" >> /usr/local/etc/php/conf.d/docker-php-ext-swoole.ini
19+
20+
# Clean up
21+
cd ..
22+
rm "v${SWOOLE_VERSION}.zip"
23+
rm -r "swoole-src-${SWOOLE_VERSION}"

rootfs/usr/local/bin/install-tools

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env sh
2+
set -e
23

34
box() {
45
local version="4.6.1"

src-devc/.devcontainer/Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ FROM php:${PHP_VERSION_STR}-cli-bookworm
55
ENV PHP_VERSION $PHP_VERSION
66

77
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
8-
COPY rootfs .
98
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
10-
&& apt-get -y install --no-install-recommends parallel unzip wget \
11-
&& install-php-extensions decimal gd intl mongodb pcntl pdo_mysql pdo_pgsql pdo_sqlite rdkafka redis sockets swoole xdebug \
12-
&& install-tools
9+
&& apt-get -y install --no-install-recommends libcurl4-openssl-dev libc-ares-dev libsqlite3-dev libpq-dev git unzip wget \
10+
&& mv /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini \
11+
&& mv /etc/php/php.ini /usr/local/etc/php/conf.d/zzphp.ini \
12+
&& install-php-extensions sockets && install-swoole && install-tools

src-devc/.devcontainer/devcontainer.json

+6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
"userUid": "1000",
1515
"userGid": "1000",
1616
"upgradePackages": "true"
17+
},
18+
"ghcr.io/opencodeco/devcontainers/install-php-extensions:latest": {
19+
"extensions": "decimal gd intl mongodb pcntl pcov pdo_mysql pdo_pgsql rdkafka redis xdebug"
1720
}
1821
},
22+
"overrideFeatureInstallOrder": [
23+
"ghcr.io/devcontainers/features/common-utils"
24+
],
1925
"remoteUser": "phpctl"
2026
}

src/docker.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ build() {
1212
echo -e "Building \033[0;32m$PHPCTL_IMAGE\033[0m"
1313
# shellcheck disable=SC2068
1414
# shellcheck disable=SC2154
15-
$PHPCTL_RUNTIME buildx build --no-cache \
15+
$PHPCTL_RUNTIME buildx build \
1616
--build-arg PHP="$PHP_VERSION" \
1717
--build-arg COMPOSER_AUTH="$COMPOSER_AUTH" \
1818
--build-arg HOST_USER="$(whoami)" \
@@ -51,6 +51,11 @@ run() {
5151
composer_home="-v $composer_home:$composer_home"
5252
fi
5353

54+
local gitconfig=""
55+
if [ -f ~/.gitconfig ]; then
56+
gitconfig="-v $HOME/.gitconfig:/root/.gitconfig:ro"
57+
fi
58+
5459
if [ -n "$GIT_EXEC_PATH" ]; then
5560
# In a Git hook environment, we need to disable TTY allocation
5661
PHPCTL_TTY="--label=no-tty"
@@ -68,7 +73,7 @@ run() {
6873
--user "$PHPCTL_USER" \
6974
$(env | awk -F= '/^[[:alpha:]]/{print $1}' | sed 's/^/-e/') \
7075
-v /var/run/docker.sock:/var/run/docker.sock \
71-
-v ~/.gitconfig:/root/.gitconfig:ro \
76+
$gitconfig \
7277
-v "$(pwd)":/usr/local/src -w /usr/local/src \
7378
-v "$PHPCTL_DIR/php.ini:/etc/php$PHP_VERSION/conf.d/zphp.ini" \
7479
$phpctl_ini \

tests/php_test.sh

-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,4 @@ function test_composer() {
1414
function test_phpctl_ini() {
1515
echo "memory_limit=1337M" > phpctl.ini
1616
assert_contains "memory_limit => 1337M => 1337M" "$(./bin/phpctl php -i | grep memory_limit)"
17-
if [ -f phpctl.ini ]; then
18-
rm phpctl.ini
19-
fi
2017
}

0 commit comments

Comments
 (0)