-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
81 lines (71 loc) · 2.48 KB
/
Dockerfile
File metadata and controls
81 lines (71 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
FROM python:3.12-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
postgresql-client \
postgresql-server-dev-all \
build-essential \
libpq-dev \
curl \
wget \
autoconf \
automake \
libtool \
libmecab-dev \
mecab \
mecab-ipadic-utf8 \
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-kor \
tesseract-ocr-jpn \
tesseract-ocr-chi-sim \
tesseract-ocr-chi-tra \
libtesseract-dev \
&& rm -rf /var/lib/apt/lists/*
# Install MeCab Korean
WORKDIR /tmp
RUN wget https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz && \
tar xvfz mecab-0.996-ko-0.9.2.tar.gz && \
cd mecab-0.996-ko-0.9.2 && \
# Update config files for ARM64 support
wget -O config.guess 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' && \
wget -O config.sub 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' && \
chmod +x config.guess config.sub && \
./configure && \
make && \
make check && \
make install && \
ldconfig && \
cd /tmp && \
wget https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz && \
tar xvfz mecab-ko-dic-2.1.1-20180720.tar.gz && \
cd mecab-ko-dic-2.1.1-20180720 && \
# Update config files for ARM64 support
wget -O config.guess 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' && \
wget -O config.sub 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' && \
chmod +x config.guess config.sub && \
./autogen.sh && \
./configure && \
make && \
make install && \
cd / && \
rm -rf /tmp/*
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create non-root user
RUN useradd --create-home --shell /bin/bash app && chown -R app:app /app
USER app
# Environment variables
ENV FLASK_APP=run.py
ENV FLASK_ENV=production
# Expose port
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5000/api/health || exit 1
# Run the application
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "--worker-class", "gevent", "--timeout", "120", "--worker-connections", "1000", "--max-requests", "1000", "--max-requests-jitter", "100", "run:app"]