Skip to content

Commit 30849e2

Browse files
9keyyyyGukhee JoCopilotswa07016
authored
feat: 배포용 docker compose 작성 (#2)
* feat: 배포용 docker compose 작성 * Update docker-compose.dev.yml Co-authored-by: Copilot <[email protected]> * ci: CI/CD 스크립트 작성 --------- Co-authored-by: Gukhee Jo <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: swa07016 <[email protected]>
1 parent 7ea9f97 commit 30849e2

File tree

6 files changed

+157
-1
lines changed

6 files changed

+157
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI/CD to NCP Server
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: deploy-main
10+
cancel-in-progress: true
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 30
16+
17+
steps:
18+
- name: Checkout source code
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Log in to NCP Container Registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: satto-registry.kr.ncr.ntruss.com
28+
username: ${{ secrets.NCP_REGISTRY_USERNAME }}
29+
password: ${{ secrets.NCP_REGISTRY_PASSWORD }}
30+
31+
- name: Build and Push Docker Image (linux/amd64)
32+
run: |
33+
docker buildx build --platform linux/amd64 \
34+
-t satto-registry.kr.ncr.ntruss.com/satto-server-fastapi:latest \
35+
--push .
36+
37+
- name: Deploy to NCP Server
38+
uses: appleboy/[email protected]
39+
with:
40+
host: ${{ secrets.NCP_SERVER_HOST }}
41+
username: ${{ secrets.NCP_SERVER_USER }}
42+
password: ${{ secrets.NCP_SERVER_PASSWORD }}
43+
port: 22
44+
script: |
45+
set -e
46+
cd /home/Satto-Server
47+
48+
# 최신 이미지로 fastapi만 갱신/재기동
49+
docker compose -f docker-compose.dev.yml up -d --pull always fastapi
50+
51+
# 상태 확인
52+
docker compose -f docker-compose.dev.yml ps fastapi

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.env
22
.idea/
33
data/
4-
__pycache__/
4+
__pycache__/
5+
logs
6+
mysql_data

docker-compose.dev.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
services:
3+
mysql:
4+
image: mysql:8.0
5+
container_name: mysql
6+
environment:
7+
MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
8+
MYSQL_DATABASE: ${MYSQL_DB}
9+
volumes:
10+
- ${WRITABLE_DIR}/mysql_data:/var/lib/mysql
11+
- ./init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
12+
ports:
13+
- "3306:3306"
14+
healthcheck:
15+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
16+
timeout: 5s
17+
retries: 10
18+
19+
fastapi:
20+
image: satto-registry.kr.ncr.ntruss.com/satto-server-fastapi:latest
21+
pull_policy: always
22+
container_name: fastapi-app
23+
depends_on:
24+
mysql:
25+
condition: service_healthy
26+
volumes:
27+
- ${WRITABLE_DIR}/logs/app:/data/logs/app
28+
command: >
29+
sh -c "
30+
gunicorn src.main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000
31+
"
32+
ports:
33+
- "8000:8000"
34+
env_file:
35+
- .env

poetry.lock

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies = [
1717
"aiomysql (>=0.2.0,<0.3.0)",
1818
"alembic (>=1.16.4,<2.0.0)",
1919
"cryptography (>=45.0.5,<46.0.0)",
20+
"gunicorn (>=23.0.0,<24.0.0)",
2021
"httpx (>=0.28.1,<0.29.0)",
2122
"pyyaml (>=6.0.2,<7.0.0)"
2223
]

requirements.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
aiomysql==0.2.0 ; python_version >= "3.10" and python_version < "4.0"
2+
alembic==1.16.4 ; python_version >= "3.10" and python_version < "4.0"
3+
annotated-types==0.7.0 ; python_version >= "3.10" and python_version < "4.0"
4+
anyio==4.9.0 ; python_version >= "3.10" and python_version < "4.0"
5+
cffi==1.17.1 ; python_version >= "3.10" and python_version < "4.0" and platform_python_implementation != "PyPy"
6+
click==8.2.1 ; python_version >= "3.10" and python_version < "4.0"
7+
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows"
8+
cryptography==45.0.5 ; python_version >= "3.10" and python_version < "4.0"
9+
dnspython==2.7.0 ; python_version >= "3.10" and python_version < "4.0"
10+
email-validator==2.2.0 ; python_version >= "3.10" and python_version < "4.0"
11+
exceptiongroup==1.3.0 ; python_version == "3.10"
12+
fastapi==0.116.1 ; python_version >= "3.10" and python_version < "4.0"
13+
greenlet==3.2.3 ; python_version >= "3.10" and python_version < "3.14" and (platform_machine == "aarch64" or platform_machine == "ppc64le" or platform_machine == "x86_64" or platform_machine == "amd64" or platform_machine == "AMD64" or platform_machine == "win32" or platform_machine == "WIN32")
14+
gunicorn==23.0.0 ; python_version >= "3.10" and python_version < "4.0"
15+
h11==0.16.0 ; python_version >= "3.10" and python_version < "4.0"
16+
idna==3.10 ; python_version >= "3.10" and python_version < "4.0"
17+
mako==1.3.10 ; python_version >= "3.10" and python_version < "4.0"
18+
markupsafe==3.0.2 ; python_version >= "3.10" and python_version < "4.0"
19+
packaging==25.0 ; python_version >= "3.10" and python_version < "4.0"
20+
pycparser==2.22 ; python_version >= "3.10" and python_version < "4.0" and platform_python_implementation != "PyPy"
21+
pydantic-core==2.33.2 ; python_version >= "3.10" and python_version < "4.0"
22+
pydantic-settings==2.10.1 ; python_version >= "3.10" and python_version < "4.0"
23+
pydantic==2.11.7 ; python_version >= "3.10" and python_version < "4.0"
24+
pymysql==1.1.1 ; python_version >= "3.10" and python_version < "4.0"
25+
python-dotenv==1.1.1 ; python_version >= "3.10" and python_version < "4.0"
26+
sniffio==1.3.1 ; python_version >= "3.10" and python_version < "4.0"
27+
sqlalchemy==2.0.41 ; python_version >= "3.10" and python_version < "4.0"
28+
starlette==0.47.1 ; python_version >= "3.10" and python_version < "4.0"
29+
tomli==2.2.1 ; python_version == "3.10"
30+
typing-extensions==4.14.1 ; python_version >= "3.10" and python_version < "4.0"
31+
typing-inspection==0.4.1 ; python_version >= "3.10" and python_version < "4.0"
32+
uvicorn==0.35.0 ; python_version >= "3.10" and python_version < "4.0"

0 commit comments

Comments
 (0)