Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General: Add container to use in development #15

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading