Skip to content

Commit f72d792

Browse files
authored
Update Dockerfile
1 parent 7eb84d7 commit f72d792

File tree

1 file changed

+41
-57
lines changed

1 file changed

+41
-57
lines changed

Dockerfile

Lines changed: 41 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,41 @@
1-
name: Build & Deploy Spike (GHCR → EC2)
2-
3-
on:
4-
push:
5-
branches: [ main ]
6-
7-
permissions:
8-
contents: read
9-
packages: write # GHCR 푸시 권한
10-
11-
jobs:
12-
build-push-deploy:
13-
runs-on: ubuntu-latest
14-
15-
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v4
18-
19-
- name: Set up Docker Buildx
20-
uses: docker/setup-buildx-action@v3
21-
22-
- name: Login to GHCR
23-
uses: docker/login-action@v3
24-
with:
25-
registry: ghcr.io
26-
username: ${{ github.actor }}
27-
password: ${{ secrets.GITHUB_TOKEN }}
28-
29-
# 🔥 루트의 Dockerfile(네가 준 것)로 빌드합니다.
30-
- name: Build & Push spike image
31-
uses: docker/build-push-action@v6
32-
with:
33-
context: .
34-
file: ./Dockerfile
35-
push: true
36-
tags: |
37-
ghcr.io/dmu-debugvisual/debugvisual-spike:latest
38-
ghcr.io/dmu-debugvisual/debugvisual-spike:${{ github.sha }}
39-
40-
# 선택: EC2에 바로 배포 (Secrets: EC2_HOST / EC2_USER / EC2_KEY 필요)
41-
- name: Deploy on EC2 (compose pull/up)
42-
env:
43-
HOST: ${{ secrets.EC2_HOST }}
44-
USER: ${{ secrets.EC2_USER }}
45-
run: |
46-
mkdir -p ~/.ssh
47-
echo "${{ secrets.EC2_KEY }}" > ~/.ssh/id_rsa
48-
# 윈도우 개행 방지
49-
sed -i 's/\r$//' ~/.ssh/id_rsa
50-
chmod 600 ~/.ssh/id_rsa
51-
ssh-keyscan -H "$HOST" >> ~/.ssh/known_hosts
52-
ssh "$USER@$HOST" "\
53-
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} && \
54-
cd ~/apps/debugvisual && \
55-
docker compose pull && \
56-
docker compose up -d && \
57-
docker image prune -af || true"
1+
FROM python:3.9-slim-buster
2+
3+
WORKDIR /usr/src/app
4+
5+
# Python 서버 파일 복사
6+
COPY server/app.py .
7+
COPY server/code ./code
8+
9+
# requirements.txt 복사 → 꼭 있어야 함
10+
COPY requirements.txt ./
11+
12+
# 모든 언어의 entrypoint 스크립트 복사
13+
COPY docker/python/entrypoint.sh ./entrypoint_python.sh
14+
COPY docker/java/entrypoint.sh ./entrypoint_java.sh
15+
16+
# 실행 권한 부여
17+
RUN chmod +x entrypoint_*.sh
18+
19+
# 필요한 Python 패키지 설치 (Flask + OpenAI + dotenv 등 전부)
20+
RUN pip install --no-cache-dir -r requirements.txt
21+
22+
# 필요한 패키지 설치 전 캐시 클리어
23+
RUN apt-get update && apt-get install -y \
24+
ca-certificates \
25+
curl \
26+
gnupg \
27+
lsb-release && \
28+
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
29+
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list && \
30+
apt-get update && \
31+
apt-get install -y docker-ce docker-ce-cli containerd.io && \
32+
ln -s /usr/bin/docker /usr/local/bin/docker && \
33+
apt-get clean && \
34+
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
35+
36+
# Python 버퍼링 비활성화
37+
ENV PYTHONUNBUFFERED=1
38+
39+
EXPOSE 5050
40+
41+
CMD ["python", "-Xutf8", "app.py"]

0 commit comments

Comments
 (0)