From 88d63645f87ecafb1074dad0c2e98c1846d40785 Mon Sep 17 00:00:00 2001 From: "Siwat T." Date: Wed, 25 Sep 2024 15:34:25 +0700 Subject: [PATCH] ci: add devcontainer config --- .devcontainer/Dockerfile | 28 ++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 28 ++++++++++++++++++++++++++++ .env.example | 4 ++-- 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..eb8b68f --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,28 @@ +FROM serversideup/php:8.3-unit AS base + +# Install additional php extensions (requires root) +USER root +RUN install-php-extensions gd intl redis + +# Install Node.js +RUN apt-get update && apt-get install -y nodejs npm +RUN npm install -g pnpm + +# Copy the project files +COPY . ${APP_BASE_DIR} +WORKDIR ${APP_BASE_DIR} +RUN mkdir bootstrap/cache +RUN chown -R www-data /var/www/html/ + +USER www-data + +# Install PHP & JS dependencies +RUN composer install --no-dev --no-interaction --no-progress --optimize-autoloader +RUN pnpm install --frozen-lockfile +RUN pnpm build + +RUN touch database/database.sqlite +RUN cp -n .env.example .env +RUN php artisan key:generate +RUN php artisan migrate +CMD ["unitd", "--no-daemon"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..77d5048 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,28 @@ +// https://aka.ms/devcontainer.json +{ + "name": "Laravel dev", + build: { + context: "..", + dockerfile: "Dockerfile" + }, + "workspaceFolder": "/var/www/html", + "customizations": { + "vscode": { + "extensions": [ + "mikestead.dotenv", + "amiralizadeh9480.laravel-extra-intellisense", + "ryannaddy.laravel-artisan", + // "onecentlin.laravel5-snippets", + // "onecentlin.laravel-blade" + ], + "settings": {} + } + }, + "remoteUser": "www-data", + "postCreateCommand": "chown -R 1000:1000 /var/www/html 2>/dev/null || true", + "forwardPorts": [ + 8080 + ], + // "runServices": [], + // "shutdownAction": "none", +} diff --git a/.env.example b/.env.example index d1f39b1..fb272ba 100644 --- a/.env.example +++ b/.env.example @@ -7,10 +7,10 @@ APP_URL=http://localhost LOG_CHANNEL=stack LOG_LEVEL=debug -DB_CONNECTION=mysql +DB_CONNECTION=sqlite DB_HOST=127.0.0.1 DB_PORT=3306 -DB_DATABASE=smcu_pab +#DB_DATABASE=smcu_pab DB_USERNAME=root DB_PASSWORD=