appuser 권한 설정 변경 가능하게 구조화

This commit is contained in:
Lectom C Han
2025-12-10 10:59:38 +09:00
parent 8e226ad4a3
commit c09970cc54
3 changed files with 12 additions and 3 deletions

View File

@@ -16,7 +16,11 @@ RUN CGO_ENABLED=0 go build -o /bin/geoip ./cmd/server && \
FROM debian:trixie-slim
RUN useradd --create-home --shell /usr/sbin/nologin appuser
ARG APP_UID=1000
ARG APP_GID=1000
RUN groupadd -g ${APP_GID} appuser && \
useradd --create-home --shell /usr/sbin/nologin --uid ${APP_UID} --gid ${APP_GID} appuser
WORKDIR /
@@ -27,7 +31,7 @@ COPY --from=builder /bin/user-program-dump /usr/local/bin/user-program-dump
COPY --from=builder /bin/user-program-sync /usr/local/bin/user-program-sync
COPY initial_data /initial_data
RUN mkdir -p /update_data /log && \
chown -R appuser:appuser /initial_data /update_data /log
chown -R ${APP_UID}:${APP_GID} /initial_data /update_data /log
ENV GEOIP_DB_PATH=/initial_data/GeoLite2-City.mmdb
USER appuser

View File

@@ -1,6 +1,10 @@
services:
api:
build: .
build:
context: .
args:
- APP_UID=${APP_UID:-1000}
- APP_GID=${APP_GID:-1000}
env_file:
- .env
depends_on:

View File

@@ -19,6 +19,7 @@
- [x] bash 스크립트 의존 없이 Go CLI(`user-program-sync`)로 덤프+임포트 수행, 스케줄러가 해당 CLI를 직접 호출하도록 변경 완료: 2025-12-10 09:50 KST
- [x] 초기 적재+백필+일일 업데이트를 Go 라이브러리(`internal/userprogram`)로 통합, `user-program-sync`가 초기 CSV 임포트 후 최신 일자까지 덤프/적재하도록 리팩토링 완료: 2025-12-10 10:03 KST
- [x] 증분 기준을 created_at 날짜에서 PK(id) 기반으로 변경, 마지막 id 이후 어제까지의 최대 id까지 덤프/업서트하도록 Sync/Dump 경로 리팩토링 완료: 2025-12-10 10:20 KST
- [x] 컨테이너 사용자 UID/GID를 빌드 시 지정 가능하도록 하고 볼륨 소유권을 맞춰 권한 오류 해결 (`APP_UID`/`APP_GID`, chown 적용) 완료: 2025-12-10 10:56 KST
## 진행 예정
- [x] PostgreSQL 전용 Docker 이미지(또는 build 단계)에서 `maxminddb_fdw` 설치 후 `GeoLite2-City.mmdb` 볼륨을 `/data`로 마운트하는 `postgres` 서비스 추가 및 5432 외부 노출