feat: 초기 도커(PHP 8.3, Nginx, MySQL) 환경 세팅

This commit is contained in:
2026-02-23 10:36:12 +09:00
commit e2477845c7
9 changed files with 201 additions and 0 deletions

View File

@@ -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"
]
}
}
}

View File

@@ -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:

12
.github/dependabot.yml vendored Normal file
View File

@@ -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

17
.gitignore vendored Normal file
View File

@@ -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/

View File

@@ -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');

17
docker/nginx/default.conf Normal file
View File

@@ -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;
}
}

View File

@@ -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;
}
}

19
docker/php/dockerfile Normal file
View File

@@ -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

56
src/index.php Normal file
View File

@@ -0,0 +1,56 @@
<?php
// Entry bootstrap for hmac_edu: load DB config and show skin/index.php as intro
$base = __DIR__;
// Load DB connection if present (bbs/db_conn.php contains DB info)
if (file_exists($base . '/bbs/db_conn.php')) {
require_once $base . '/bbs/db_conn.php';
} elseif (file_exists($base . '/db_conn.php')) {
require_once $base . '/db_conn.php';
}
// Serve skin/index.php as the intro page if it exists
$skin = $base . '/skin/index.php';
if (file_exists($skin)) {
if (session_status() === PHP_SESSION_NONE) {
@session_start();
}
require $skin;
exit;
}
// Try alternate locations (compat)
$alt = $base . '/hmac_edu/index.php';
if (file_exists($alt)) {
require $alt;
exit;
}
// Fallback diagnostic page
$dirs = [];
foreach (scandir($base) as $d) {
if ($d === '.' || $d === '..') continue;
if (is_dir($base . '/' . $d)) $dirs[] = $d;
}
?><!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>hmac_edu - Missing Intro</title>
<style>body{font-family:Arial,Helvetica,sans-serif;padding:20px}</style>
</head>
<body>
<h1>Intro 페이지를 찾을 수 없습니다</h1>
<p>현재 `skin/index.php` 파일이 프로젝트의 `src` 폴더에 없습니다.</p>
<p>호스트에 업로드된 디렉터리 목록:</p>
<ul>
<?php foreach ($dirs as $d): ?>
<li><?php echo htmlspecialchars($d); ?></li>
<?php endforeach; ?>
</ul>
</body>
</html>
<?php
// end
?>