gunicorn 명령어 기반 uvicorn 실행시 사용되는 설정파일 추가, logrotate 설정 추가.

This commit is contained in:
bluebamus committed 2025-11-10 10:14:27 +09:00
1 parent 628b22dd03
commit 94b5633065
29 files changed
+4979

No files matched your search

+73
View File
@@ -0,0 +1,73 @@
FROM ubuntu:latest
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends apt-utils
ENV TZ=Asia/Seoul
RUN apt-get install -yq tzdata
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# curl/wget/git/gnupg2/lsb-release/lz4/zstd
RUN apt-get install -y curl wget git tar gnupg2 lsb-release lz4 zstd
# vim
RUN apt-get install -y vim
# Python
RUN apt-get install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev
RUN cd /usr/src ; wget https://www.python.org/ftp/python/3.14.0/Python-3.14.0.tar.xz ; tar -xf Python-3.14.0.tar.xz ; cd Python-3.14.0 ; ./configure ; make altinstall
RUN rm -rf /usr/src/Python-3.14.0 /usr/src/Python-3.14.0.tar.xz
# replace python version to have 3.14 as default
RUN rm -f /usr/bin/python
RUN rm -f /usr/bin/python3
RUN ln -s /usr/local/bin/python3.14 /usr/bin/python
RUN ln -s /usr/local/bin/python3.14 /usr/bin/python3
RUN ln -s /usr/local/bin/python3.14 /usr/local/bin/python
RUN ln -s /usr/local/bin/python3.14 /usr/local/bin/python3
ENV PYTHONUNBUFFERED=1
# create links to pip3.14
RUN ln -s /usr/local/bin/pip3.14 /usr/bin/pip
RUN ln -s /usr/local/bin/pip3.14 /usr/bin/pip3
RUN ln -s /usr/local/bin/pip3.14 /usr/local/bin/pip
RUN ln -s /usr/local/bin/pip3.14 /usr/local/bin/pip3
# update apt-get
RUN apt-get update && apt-get -y upgrade
RUN pip install --upgrade pip
RUN pip3 install --upgrade pip
RUN apt-get install -y python3-dev libmysqlclient-dev pkg-config
RUN pip3 install wheel
# SQLAlchemy
RUN pip3 install sqlalchemy alembic pydantic
# postgresql 동기 / 비동기
RUN pip3 install psycopg2-binary asyncpg
# mysql 동기 / 비동기
RUN pip3 install mysqlclient asyncmy
# mysql 백업
RUN curl -O https://repo.percona.com/apt/percona-release_latest.generic_all.deb
RUN apt-get install -y ./percona-release_latest.generic_all.deb
RUN rm -f percona-release_latest.generic_all.deb
RUN apt-get update
RUN percona-release enable pxb-84-lts
RUN apt-get install -y percona-xtrabackup-84
# postgresql 백업
RUN apt-get -y install pgbackrest
# gunicorn & uvicorn
RUN pip3 install gunicorn uvicorn[standard]
# pip3 package
RUN pip3 install fastapi uv
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN update-ca-certificates
+51
View File
@@ -0,0 +1,51 @@
FROM nginx:latest
# ========================================
# 1. APT 업데이트
# ========================================
RUN apt-get update
# ========================================
# 2. APT 기본 도구 설치 (경고 제거용)
# ========================================
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends apt-utils
# ========================================
# 3. 타임존 설정 (Asia/Seoul)
# ========================================
ENV TZ=Asia/Seoul
RUN apt-get install -yq tzdata
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# ========================================
# 4. 필요한 패키지 설치
# ========================================
RUN apt-get install -y sendmail wget gnupg
# ========================================
# 7. Cron 및 Certbot 설치 (SSL 인증서 자동 갱신)
# ========================================
RUN apt-get install -y cron certbot python3-certbot-nginx
# ========================================
# 8. CA 인증서 설치 및 업데이트
# ========================================
RUN apt-get update && apt-get install -y ca-certificates
RUN update-ca-certificates
RUN chmod 644 /etc/ssl/certs/ca-certificates.crt
# ========================================
# 9. APT 캐시 정리
# ========================================
RUN apt-get autoremove -y && apt-get clean
RUN rm -rf /var/lib/apt/lists/*
# ========================================
# 10. Certbot 자동 갱신 Cron 작업 등록
# ========================================
RUN crontab -l | { cat; echo "0 5 * * 1 certbot renew --quiet --deploy-hook \"nginx -t && service nginx reload\" >> /log/nginx/crontab_$(date +\%Y\%m\%d).log 2>&1"; } | crontab -
# ========================================
# 11. Nginx 시작 스크립트에 Cron 추가
# ========================================
RUN sed -i'' -r -e "/set/i\cron" docker-entrypoint.sh