Skip to content

Commit

Permalink
General: Add container to use in development
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Nov 3, 2024
1 parent 155378b commit aa68311
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
63 changes: 63 additions & 0 deletions .devcontainer/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM php:8.3 as base
ENV AUTOLOAD_VERSION 0.2.0

RUN docker-php-ext-install mysqli

RUN pecl install raphf \
&& docker-php-ext-enable raphf

RUN apt-get update

RUN apt-get install -y libzip-dev unzip \
&& docker-php-ext-install zip

RUN apt-get install -y zlib1g-dev libcurl4-openssl-dev libssl-dev libicu-dev \
&& pecl install pecl_http \
&& docker-php-ext-enable http

RUN apt-get install uuid-dev \
&& pecl install uuid \
&& docker-php-ext-enable uuid

RUN curl -fsSL "https://github.com/pprkut/autoload-psr/releases/download/$AUTOLOAD_VERSION/autoload_psr-$AUTOLOAD_VERSION.tar.gz" -o autoload_psr.tar.gz \
&& mkdir -p autoload_psr \
&& tar -xf autoload_psr.tar.gz -C autoload_psr --strip-components=1 \
&& rm autoload_psr.tar.gz \
&& ( \
cd autoload_psr \
&& phpize \
&& ./configure \
&& make -j "$(nproc)" \
&& make install \
) \
&& rm -r autoload_psr \
&& docker-php-ext-enable autoload_psr

VOLUME /var/www/html
VOLUME /var/www/libs

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

ENV WEBROOT /var/www/html
ENV TARGET_DIR /var/www/libs

WORKDIR /var/www/html

FROM base AS dev

RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

RUN pecl install xdebug \
&& docker-php-ext-enable xdebug

RUN pecl install uopz \
&& docker-php-ext-enable uopz

# dev tools separate install so we quickly change without rebuilding all php extensions
RUN apt update && apt-get install -y --no-install-recommends \
sudo gnupg2 git ant jq mariadb-client \
&& rm -rf /var/lib/apt/lists/*

# Install composer
RUN curl -o /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar \
&& chmod +x /usr/local/bin/composer
23 changes: 23 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"build": {
"dockerfile": "Containerfile"
},
"containerEnv": {
"XDEBUG_MODE": "debug"
},
"customizations": {
"vscode": {
"extensions": [
"felixfbecker.php-intellisense",
"octref.vetur"
],
"settings": {
"php.suggest.basic": false
}
}
},
"workspaceMount": "source=${localWorkspaceFolder},target=/var/www/html/dev.lunr,type=bind",
"workspaceFolder": "/var/www/html/dev.lunr",
"overrideCommand": true,
"postAttachCommand": "bash ./.devcontainer/setup.sh"
}
6 changes: 6 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

composer install
for command in $(ls vendor/bin); do
ln -s "$(pwd)/vendor/bin/$command" "/usr/local/bin/$command"
done
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
},
"require-dev": {
"lunr/halo": "dev-master",
"phpstan/phpstan": "~1.0",
"phpunit/phpunit": ">=9.0 <9.6",
"ext-xdebug": "~3.1"
"ext-xdebug": "~3.1",
"squizlabs/php_codesniffer": "^3.10",
"phploc/phploc": "^7.0"
},
"config": {
"optimize-autoloader": true
Expand Down

0 comments on commit aa68311

Please sign in to comment.