69 lines
2.4 KiB
Docker
69 lines
2.4 KiB
Docker
FROM python:3.11-slim
|
|
|
|
# Set environment variables
|
|
ENV PYTHONPATH=/app/src
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
gcc \
|
|
g++ \
|
|
unixodbc-dev \
|
|
curl \
|
|
unzip \
|
|
libaio-dev \
|
|
gnupg2 \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Microsoft ODBC Driver 17 for SQL Server
|
|
RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg && \
|
|
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/debian/11/prod bullseye main" > /etc/apt/sources.list.d/mssql-release.list && \
|
|
apt-get update && \
|
|
ACCEPT_EULA=Y apt-get install -y msodbcsql17 && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Oracle Instant Client for cx_Oracle
|
|
RUN mkdir -p /opt/oracle && \
|
|
cd /opt/oracle && \
|
|
curl -o instantclient-basic-linux.x64-21.9.0.0.0dbru.zip \
|
|
https://download.oracle.com/otn_software/linux/instantclient/219000/instantclient-basic-linux.x64-21.9.0.0.0dbru.zip && \
|
|
unzip instantclient-basic-linux.x64-21.9.0.0.0dbru.zip && \
|
|
rm instantclient-basic-linux.x64-21.9.0.0.0dbru.zip && \
|
|
cd instantclient_21_9 && \
|
|
mkdir -p lib && \
|
|
ln -s ../libclntsh.so.21.1 lib/libclntsh.so && \
|
|
ln -s ../libnnz21.so lib/libnnz21.so && \
|
|
ln -s ../libociicus.so lib/libociicus.so && \
|
|
echo /opt/oracle/instantclient_21_9 > /etc/ld.so.conf.d/oracle-instantclient.conf && \
|
|
ldconfig
|
|
|
|
# Set Oracle environment variables
|
|
ENV ORACLE_HOME=/opt/oracle/instantclient_21_9
|
|
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient_21_9:$LD_LIBRARY_PATH
|
|
ENV PATH=/opt/oracle/instantclient_21_9:$PATH
|
|
|
|
# Create app directory
|
|
WORKDIR /app
|
|
|
|
# Copy requirements and install Python dependencies
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY src/ ./src/
|
|
|
|
# Create logs directory
|
|
RUN mkdir -p /app/logs
|
|
|
|
# Create non-root user
|
|
RUN groupadd -r wxconnect && useradd -r -g wxconnect wxconnect
|
|
RUN chown -R wxconnect:wxconnect /app
|
|
USER wxconnect
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|
CMD python -c "import sys; sys.path.insert(0, '/app/src'); from wxconnect.config import Config; c = Config(); print('OK' if c.validate() else 'FAIL')" || exit 1
|
|
|
|
# Entry point
|
|
CMD ["python", "-m", "wxconnect.main"] |