commit e2477845c7eb4a66fb7e1c249444477977be870e Author: SDI Date: Mon Feb 23 10:36:12 2026 +0900 feat: 초기 도커(PHP 8.3, Nginx, MySQL) 환경 세팅 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..70f3cb3 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,16 @@ +{ + "name": "PHP-Nginx-MySQL Dev", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/var/www/html", + "shutdownAction": "stopCompose", + "customizations": { + "vscode": { + "extensions": [ + "bmewburn.vscode-intelephense-client", + "xdebug.php-debug", + "ms-azuretools.vscode-docker" + ] + } + } +} \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..cd2423d --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,35 @@ +version: "3.9" + +services: + app: + build: + context: .. + dockerfile: docker/php/dockerfile + volumes: + - ../src:/var/www/html + working_dir: /var/www/html + depends_on: + - db + + nginx: + image: nginx:1.25-alpine + ports: + - "8081:80" + volumes: + - ../src:/var/www/html + - ../docker/nginx/default.conf:/etc/nginx/conf.d/default.conf + depends_on: + - app + + db: + image: mysql:8.0 + env_file: + - ../.env + volumes: + - db_data:/var/lib/mysql + - ../docker/mysql/initdb:/docker-entrypoint-initdb.d + ports: + - "3306:3306" + +volumes: + db_data: \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f33a02c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10004e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# 1. 보안 및 환경 변수 파일 (절대 깃허브에 올라가면 안 됨!) +.env +.env.* +!.env.example + +# 2. PHP / Composer 종속성 (각자 설치해야 하는 패키지 폴더) +/vendor/ + +# 3. Docker 관련 로컬 데이터 (각자의 컴퓨터에만 남아야 하는 데이터) +/db_data/ +/mysql/ + +# 4. 운영체제 및 에디터 임시 파일 +.DS_Store +Thumbs.db +.vscode/ +.idea/ \ No newline at end of file diff --git a/docker/mysql/initdb/init.sql b/docker/mysql/initdb/init.sql new file mode 100644 index 0000000..26d202d --- /dev/null +++ b/docker/mysql/initdb/init.sql @@ -0,0 +1,12 @@ +-- 팀원들이 공통으로 사용할 초기 테이블 구조 생성 +CREATE TABLE IF NOT EXISTS users ( + id INT AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(50) NOT NULL, + email VARCHAR(100) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +-- 초기 테스트를 위한 더미 데이터 삽입 (선택 사항) +INSERT INTO users (username, email) VALUES +('test_user_1', 'user1@hmac-edu.com'), +('test_user_2', 'user2@hmac-edu.com'); \ No newline at end of file diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf new file mode 100644 index 0000000..927c0b9 --- /dev/null +++ b/docker/nginx/default.conf @@ -0,0 +1,17 @@ +server { + listen 80; + server_name localhost; + + root /var/www/html; + index index.php index.html; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + include fastcgi_params; + fastcgi_pass app:9000; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } +} diff --git a/docker/nginx/hmac_edu.conf b/docker/nginx/hmac_edu.conf new file mode 100644 index 0000000..7e02270 --- /dev/null +++ b/docker/nginx/hmac_edu.conf @@ -0,0 +1,17 @@ +server { + listen 8082; + server_name localhost; + + root /var/www/html/hmac_edu; + index index.php index.html; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + include fastcgi_params; + fastcgi_pass app:9000; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } +} diff --git a/docker/php/dockerfile b/docker/php/dockerfile new file mode 100644 index 0000000..bcad7be --- /dev/null +++ b/docker/php/dockerfile @@ -0,0 +1,19 @@ +FROM php:8.3-fpm + +RUN apt-get update && apt-get install -y \ + git \ + unzip \ + libzip-dev \ + libpng-dev \ + libonig-dev \ + libxml2-dev \ + && docker-php-ext-install pdo_mysql mbstring zip \ + && rm -rf /var/lib/apt/lists/* + +# Composer +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +# 3. MySQL 연결을 위한 PHP 확장 모듈 및 기타 필수 모듈 설치 +RUN docker-php-ext-install pdo pdo_mysql mysqli zip + +WORKDIR /var/www/html diff --git a/src/index.php b/src/index.php new file mode 100644 index 0000000..a811f79 --- /dev/null +++ b/src/index.php @@ -0,0 +1,56 @@ + + + + + hmac_edu - Missing Intro + + + +

Intro 페이지를 찾을 수 없습니다

+

현재 `skin/index.php` 파일이 프로젝트의 `src` 폴더에 없습니다.

+

호스트에 업로드된 디렉터리 목록:

+ + + + + \ No newline at end of file