Skip to content

Commit

Permalink
💚 Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Namgyu-Youn committed Jan 11, 2025
1 parent 3efbfdc commit 8a1a0fd
Show file tree
Hide file tree
Showing 4 changed files with 1,138 additions and 88 deletions.
47 changes: 26 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
FROM python:3.12.3-slim as builder
FROM python:3.11-slim AS builder

WORKDIR /app

# Install only necessary system dependencies
# Install system dependencies
RUN apt-get update && apt-get install -y \

Check failure on line 6 in Dockerfile

View workflow job for this annotation

GitHub Actions / lint-and-test (ubuntu-latest, 3.11)

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`

Check failure on line 6 in Dockerfile

View workflow job for this annotation

GitHub Actions / lint-and-test (ubuntu-latest, 3.11)

DL3015 info: Avoid additional packages by specifying `--no-install-recommends`
protobuf-compiler \
gcc \
curl \
&& rm -rf /var/lib/apt/lists/*

# Install and configure Poetry
RUN pip install poetry && \
poetry config virtualenvs.create false
# Install poetry
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VERSION=1.7.1
ENV POETRY_VIRTUALENVS_CREATE=false
ENV PATH="$POETRY_HOME/bin:$PATH"

# Copy dependency files and install
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-interaction --no-ansi --no-root --without dev
RUN curl -sSL https://install.python-poetry.org | python3 -

Check failure on line 18 in Dockerfile

View workflow job for this annotation

GitHub Actions / lint-and-test (ubuntu-latest, 3.11)

DL4006 warning: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check

# Runtime environment
FROM python:3.12.3-slim
# Copy only dependency files first for better caching
COPY pyproject.toml poetry.lock ./

WORKDIR /app
# Install dependencies only
RUN poetry install --no-root --no-interaction --no-ansi --without dev

# Copy only necessary files from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages/ /usr/local/lib/python3.12/site-packages/
COPY --from=builder /usr/local/bin/ /usr/local/bin/
# Copy the rest of the application
COPY src/ ./src/
COPY scripts/ ./scripts/
COPY utils/ ./utils/
COPY app.py ./

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
protobuf-compiler \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install the project itself
RUN poetry install --only-root

# Copy application code
COPY . .
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7860

# Security: Create non-root user and set permissions
RUN useradd -m appuser && \
Expand All @@ -44,4 +48,5 @@ EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1

# Run the application
CMD ["poetry", "run", "python", "app.py"]
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
ports:
- "7860:7860"
environment:
- PYTHONPATH=/app
- PYTHONUNBUFFERED=1
- GRADIO_SERVER_NAME=0.0.0.0
- GRADIO_SERVER_PORT=7860
deploy:
Expand Down
Loading

0 comments on commit 8a1a0fd

Please sign in to comment.