From ec811765150ddcd3b2429b60d53b430c52146e9c Mon Sep 17 00:00:00 2001 From: Michael Gasparelli Date: Sun, 30 Nov 2025 12:17:51 -0500 Subject: [PATCH] Set up devcontainer for local dev Add a complete devcontainer setup to enable one-click development environment setup in VS Code with all dependencies and services pre-configured. --- .devcontainer/Dockerfile | 49 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 20 ++++++++++++++ .vscode/extensions.json | 7 +++++ 3 files changed, 76 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/extensions.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..4531235b --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,49 @@ +FROM php:8.2-apache + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + curl \ + libpng-dev \ + libonig-dev \ + libxml2-dev \ + libzip-dev \ + libicu-dev \ + sqlite3 \ + libsqlite3-dev \ + unzip \ + nodejs \ + npm \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Install PHP extensions +RUN docker-php-ext-configure gd \ + && docker-php-ext-install -j$(nproc) \ + gd \ + intl \ + pdo \ + pdo_sqlite \ + mbstring \ + zip \ + fileinfo + +# Enable Apache modules +RUN a2enmod rewrite + +# Install Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Install Yarn +RUN npm install -g yarn + +# Set working directory +WORKDIR /workspaces/grocy + +# Configure Apache to point to public directory +ENV APACHE_DOCUMENT_ROOT=/workspaces/grocy/public +RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf +RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf + +# Set permissions for data directory +RUN mkdir -p /workspaces/grocy/data && chmod 777 /workspaces/grocy/data diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..9c069b5a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,20 @@ +{ + "name": "Grocy Development", + "build": { + "dockerfile": "Dockerfile", + "context": "." + }, + "forwardPorts": [ + 80 + ], + "postCreateCommand": "bash -c 'composer install && yarn install && if [ ! -f data/config.php ]; then cp config-dist.php data/config.php; fi && chmod -R 777 data'", + "postStartCommand": "apache2-foreground &", + "customizations": { + "vscode": { + "settings": { + "php.validate.executablePath": "/usr/local/bin/php" + } + } + }, + "remoteUser": "root" +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..de66b080 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "bmewburn.vscode-intelephense-client", + "xdebug.php-debug", + "editorconfig.editorconfig" + ] +}