Skip to content

Commit

Permalink
Merge pull request #2 from praekeltfoundation/initial-commits
Browse files Browse the repository at this point in the history
Add github actions
  • Loading branch information
erikh360 authored Nov 25, 2024
2 parents ac75553 + abdaf25 commit e7eb323
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Purpose
_Why does this exist?_

#### Checklist
- [ ] Added or updated unit tests
- [ ] Added to release notes
- [ ] Updated readme/documentation (if necessary)
58 changes: 58 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Continuous integration
on:
push:
branches: ["*"]
tags: ["v*"]
pull_request:
branches: ["main"]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: abatilo/[email protected]
with:
poetry-version: "1.8.4"
- name: Install dependancies
run: |
poetry install
- name: Lint
run: |
poetry run ruff format --check
poetry run ruff check
- name: Test
run: poetry run pytest

docker-image:
needs: [test]
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/metadata-action@v4
id: meta
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=sha,prefix={{branch}}-,enable=${{ github.ref_type != 'tag' }}
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
20 changes: 8 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Use the official Python 3.8 slim image as the base image
FROM python:3.11-slim
FROM ghcr.io/praekeltfoundation/python-base-nw:3.11-bullseye as build

# Set the working directory within the container
WORKDIR /api-flask
RUN pip install poetry==1.8.4
COPY . ./
RUN poetry config virtualenvs.in-project true \
&& poetry install --no-dev --no-interaction --no-ansi

# Copy the necessary files and directories into the container
COPY src /api-flask/
COPY src/data/ /api-flask/data/
FROM ghcr.io/praekeltfoundation/python-base-nw:3.11-bullseye
COPY --from=build .venv/ .venv/
COPY src src/

# Upgrade pip and install Python dependencies
RUN pip3 install --upgrade pip && pip install --no-cache-dir -r requirements.txt

# Expose port 5000 for the Flask application
EXPOSE 5000

# Define the command to run the Flask application using Gunicorn
CMD ["gunicorn", "application:app", "-b", "0.0.0.0:5000", "-w", "4"]
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ version = "0.0.1"
description = ""
authors = ["Erik Harding <[email protected]>"]
readme = "README.md"
package-mode = false
repository = "https://github.com/praekeltfoundation/mc-intent-classifier"
packages = [
{ include = "src" },
]

[tool.poetry.dependencies]
python = "^3.11"
Expand Down

0 comments on commit e7eb323

Please sign in to comment.