Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy

on:
workflow_dispatch:
push:
push: &trigger
branches:
- main
paths:
Expand All @@ -12,9 +12,9 @@ on:
- "Dockerfile"
- "requirements.txt"
- "app/**"
# - "data/**"
- "root/**"
- "scripts/**"
pull_request: *trigger
release:
types:
- published
Expand Down Expand Up @@ -71,4 +71,6 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: prod
push: true

# pr에서는 테스트용이기 때문에 push하지 않음 (dry-run)
push: ${{ github.event_name != 'pull_request' }}
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then
if [ -f requirements-dev.txt ]; then
pip install -r requirements-dev.txt
elif [ -f requirements.txt ]; then
pip install -r requirements.txt
fi

Expand Down
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ RUN uv venv $VIRTUAL_ENV

# 운영용: 빌드
FROM prod-base AS prod-build
RUN apk add --no-cache gdal-dev gcc g++
COPY requirements.txt .
RUN uv pip install --no-cache -r requirements.txt

Expand All @@ -40,5 +39,4 @@ WORKDIR /app/scripts
FROM base AS dev
ENV APP_ENV=development
ENV PYTHONDONTWRITEBYTECODE=1
RUN apk add --no-cache gdal-dev gcc g++
WORKDIR /app/scripts
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

## 설치

> [!NOTE]
> `requirements-dev.txt` 파일 지정 시
> [테스트](#테스트) 및 [insert-data](#insert-data)
> 작업에 사용되는 라이브러리까지 같이 설치됨

나열된 목록을 한 번에 설치

```shell
Expand Down Expand Up @@ -54,7 +59,7 @@ fastapi dev app

내장 명령어 목록 및 설명

### create-user
### create user

데이터베이스에 사용자 추가

Expand All @@ -63,18 +68,23 @@ fastapi dev app
docker exec -it <container_name> create-user <email> [name]
```

### insert-data
### insert data

> [!IMPORTANT]
> 도커 이미지 경량화를 위해 제거되었으며,
> 파이썬으로 직접 파일을 실행할 수 있습니다.

> [!IMPORTANT]
> [url.txt](data/url.txt) 파일 내 구글 드라이브에서 모든 파일 다운로드

`data` 폴더 내 csv 파일 내 데이터를 데이터베이스에 삽입 (테이블 자동 생성)

```shell
docker exec -it <container_name> insert-data
python3 scripts/insert_data.py
# docker exec -it <container_name> insert-data # deprecated
```

### insert-seeds
### insert seeds

> [!IMPORTANT]
> `insert-data`가 먼저 수행되어야 함
Expand All @@ -88,32 +98,39 @@ docker exec -it <container_name> insert-data
```shell
# num_of_recs 기본값: 30
# num_of_users 기본값: 0

python3 scripts/insert_seeds.py [num_of_recs] [num_of_users]
# or
docker exec -it <container_name> insert-seeds [num_of_recs] [num_of_users]
```

### drop-seeds
### drop seeds

> [!NOTE]
> 게스트 계정과 property_infrastructure 테이블 데이터는 삭제되지 않음

생성된 seed 데이터 삭제.

```shell
python3 scripts/drop_seeds.py
# or
docker exec -it <container_name> drop-seeds
```

### drop-tables
### drop tables

데이블 삭제

```shell
python3 scripts/drop_tables.py [-y|--yes]
# or
docker exec -it <container_name> drop-tables [-y|--yes]
```

연결된 데이터베이스의 모든 테이블 삭제.
`-y` 또는 `--yes` 입력 시 삭제 여부를 묻지 않고 즉시 삭제함.

### drop-to-seeds
### drop to seeds

`drop-tables`, `insert-data`, `insert-seeds`를 연속으로 실행하는 스크립트

Expand Down
5 changes: 5 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-r requirements.txt

pytest
pytest-cov
geopandas
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
fastapi[standard]
itsdangerous
scalar-fastapi
pytest
pytest-cov
sqlalchemy
geoalchemy2
pymysql
argon2-cffi
python-dotenv
cuid2
redis
geopandas
2 changes: 0 additions & 2 deletions scripts/insert_data.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/with-contenv python3

import re
import os
import sys
Expand Down