From 9072c550a0c8fc36d2816d6d18b90f8707a11175 Mon Sep 17 00:00:00 2001 From: Anton Hughes Date: Tue, 13 May 2025 12:45:27 +1200 Subject: [PATCH 1/2] Add GitHub Actions workflow for Docker build and push --- .github/workflows/docker.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..7afaa87 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,27 @@ +name: Docker + +on: + push: + branches: [ main ] + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/blockprint:latest \ No newline at end of file From 049adce305f9db7b6eced4a922a4895de1f2fd62 Mon Sep 17 00:00:00 2001 From: Anton Hughes Date: Tue, 13 May 2025 12:52:19 +1200 Subject: [PATCH 2/2] Add Dockerfile and update README with Docker usage instructions --- Dockerfile | 12 ++++++++++++ README.md | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b9cf707 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.9-slim + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 8000 + +CMD ["gunicorn", "api_server:app", "--bind", "0.0.0.0:8000", "--timeout", "1800"] \ No newline at end of file diff --git a/README.md b/README.md index 461e4e9..5bf5d56 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,19 @@ If you then want to use the classifier to build an sqlite database: ``` gunicorn api_server:app --timeout 1800 ``` +### Running with Docker + +Build the Docker image: +``` +docker build -t blockprint . +``` + +Run the container (mapping port 8000 to host): +``` +docker run -p 8000:8000 blockprint +``` + +The API will be available at http://localhost:8000 It will take a few minutes to start-up while it loads all of the training data into memory.