diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 54dba055..d2f51931 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -136,10 +136,8 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - # list of Docker images to use as base name for tags images: | ghcr.io/mountaingod2/chaturbate_poller - # generate Docker tags based on the following events/attributes tags: | type=schedule type=ref,event=branch @@ -175,3 +173,7 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + - name: Run tests on Docker image + run: | + docker run --rm ghcr.io/mountaingod2/chaturbate_poller:latest --version diff --git a/Dockerfile b/Dockerfile index 5763d7ad..154a1ab5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,32 @@ +# Use an official Python runtime as a parent image +FROM python:3.11-slim as builder + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +# Create a virtual environment in /venv +RUN python -m venv /venv + +# Activate virtual environment and upgrade pip +ENV PATH="/venv/bin:$PATH" +RUN pip install --upgrade pip + +# Install the latest version of the chaturbate-poller package +RUN pip install --no-cache-dir chaturbate-poller + +# Create a new stage for the final image FROM python:3.11-slim -RUN pip install --no-cache-dir --no-compile chaturbate-poller +# Copy the virtual environment from the builder stage +COPY --from=builder /venv /venv + +# Set the path to use the virtual environment +ENV PATH="/venv/bin:$PATH" +# Set working directory WORKDIR /app +# Command to run the application ENTRYPOINT ["python", "-m", "chaturbate_poller"]