diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66e0f35 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +node_modules/ +__pycache__/ +*.pyc +.env +.venv/ +dist/ +build/ +*.egg-info/ +.DS_Store +Thumbs.db diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..1b2cd06 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,13 @@ +{ + "recommendations": [ + "ms-azuretools.vscode-docker", + "ms-python.python", + "ms-python.black-formatter", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "eamodio.gitlens", + "ms-vscode-remote.remote-ssh", + "redhat.vscode-yaml", + "bradlc.vscode-tailwindcss" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..8378623 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,32 @@ +{ + // ── Git 설정 ── + "git.defaultCloneDirectory": "C:\\Users\\User\\Projects", + "git.autofetch": true, + "git.confirmSync": false, + "git.enableSmartCommit": true, + + // ── 에디터 설정 ── + "editor.formatOnSave": true, + "editor.tabSize": 2, + "files.eol": "\n", + "files.trimTrailingWhitespace": true, + "files.insertFinalNewline": true, + + // ── Python 설정 ── + "[python]": { + "editor.tabSize": 4, + "editor.defaultFormatter": "ms-python.black-formatter" + }, + + // ── Docker 설정 ── + "[dockerfile]": { + "editor.defaultFormatter": "ms-azuretools.vscode-docker" + }, + + // ── 터미널 설정 ── + "terminal.integrated.defaultProfile.windows": "Git Bash", + + // ── 솔메카 배포 관련 ── + "solmeca.gitea.url": "http://100.125.85.86:3000", + "solmeca.coolify.url": "http://100.125.85.86:8000" +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..13df2ca --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,124 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Deploy: 자동 배포 (서버 자동 선택)", + "type": "shell", + "command": "bash", + "args": [ + "C:/Users/User/Desktop/SERVER_ 운영/deploy.sh", + "${input:repoName}" + ], + "group": "build", + "presentation": { + "reveal": "always", + "panel": "dedicated", + "clear": true + }, + "problemMatcher": [] + }, + { + "label": "Deploy: 서버 지정 배포", + "type": "shell", + "command": "bash", + "args": [ + "C:/Users/User/Desktop/SERVER_ 운영/deploy.sh", + "${input:repoName}", + "${input:appName}", + "${input:serverName}" + ], + "group": "build", + "presentation": { + "reveal": "always", + "panel": "dedicated", + "clear": true + }, + "problemMatcher": [] + }, + { + "label": "Deploy: 서버 상태 확인", + "type": "shell", + "command": "bash", + "args": [ + "C:/Users/User/Desktop/SERVER_ 운영/deploy.sh", + "status" + ], + "group": "build", + "presentation": { + "reveal": "always", + "panel": "dedicated", + "clear": true + }, + "problemMatcher": [] + }, + { + "label": "Git: Gitea에 Push", + "type": "shell", + "command": "git push origin main", + "group": "build", + "presentation": { + "reveal": "always", + "panel": "shared" + }, + "problemMatcher": [] + }, + { + "label": "Git: Commit + Push + Deploy", + "type": "shell", + "command": "bash", + "args": [ + "-c", + "git add -A && git commit -m '${input:commitMsg}' && git push origin main && bash 'C:/Users/User/Desktop/SERVER_ 운영/deploy.sh' $(basename $(git rev-parse --show-toplevel))" + ], + "group": "build", + "presentation": { + "reveal": "always", + "panel": "dedicated", + "clear": true + }, + "problemMatcher": [] + }, + { + "label": "Docker: 로컬 빌드 테스트", + "type": "shell", + "command": "docker build -t ${input:repoName}:test . && docker run --rm -p 8000:8000 ${input:repoName}:test", + "group": "test", + "presentation": { + "reveal": "always", + "panel": "dedicated" + }, + "problemMatcher": [] + } + ], + "inputs": [ + { + "id": "repoName", + "type": "promptString", + "description": "Gitea 레포 이름 (예: fastapi-demo)", + "default": "" + }, + { + "id": "appName", + "type": "promptString", + "description": "Coolify 앱 이름 (비워두면 레포이름 사용)", + "default": "" + }, + { + "id": "serverName", + "type": "pickString", + "description": "배포 서버 선택", + "options": [ + "worker-ai", + "worker-downsys", + "worker-kakao2" + ], + "default": "worker-ai" + }, + { + "id": "commitMsg", + "type": "promptString", + "description": "커밋 메시지", + "default": "update" + } + ] +} diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..d10e526 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "test-rust2" +version = "0.1.0" +edition = "2021" + +[dependencies] +actix-web = "4" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +tokio = { version = "1", features = ["full"] } diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e76e8b3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM rust:1.78-alpine AS builder +RUN apk add --no-cache musl-dev +WORKDIR /app +COPY . . +RUN cargo build --release + +FROM alpine:latest +WORKDIR /app +COPY --from=builder /app/target/release/$(basename $(pwd)) ./server +EXPOSE 8080 +CMD ["./server"] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..cf27f2b --- /dev/null +++ b/src/main.rs @@ -0,0 +1,19 @@ +use actix_web::{web, App, HttpServer, HttpResponse, get}; +use serde_json::json; + +#[get("/")] +async fn index() -> HttpResponse { + HttpResponse::Ok().json(json!({"app": "test-rust2", "status": "running"})) +} + +#[get("/health")] +async fn health() -> HttpResponse { + HttpResponse::Ok().json(json!({"status": "ok"})) +} + +#[actix_web::main] +async fn main() -> std::io::Result<()> { + println!("test-rust2 running on port 8080"); + HttpServer::new(|| App::new().service(index).service(health)) + .bind("0.0.0.0:8080")?.run().await +}