diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..b55fc39 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,45 @@ +name: Docker image release + +on: + workflow_dispatch: + push: + branches: [main] + tags: ["v[0-9].[0-9]+.[0-9]+*"] + + +jobs: + build-and-push: + name: Build base image + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: deepset/hayhooks + + - name: Build base images + uses: docker/bake-action@v4 + env: + IMAGE_TAG_SUFFIX: ${{ steps.meta.outputs.version }} + HAYSTACK_VERSION: ${{ steps.meta.outputs.version }} + with: + workdir: docker + targets: hayhooks + push: true diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 7b44165..0000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM deepset/haystack:base-main - -RUN pip install hayhooks - -EXPOSE 1416 - -CMD ["hayhooks", "run", "0.0.0.0"] diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..909c28d --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,33 @@ +ARG build_image +ARG base_image + +FROM $build_image AS build-image + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + build-essential \ + git + +ARG hayhooks_version + +# Shallow clone Hayhooks repo, we'll install from the local sources +RUN git clone --depth=1 --branch=${hayhooks_version} https://github.com/deepset-ai/hayhooks.git /opt/hayhooks +WORKDIR /opt/hayhooks + +# Use a virtualenv we can copy over the next build stage +RUN python3 -m venv --system-site-packages /opt/venv +ENV PATH="/opt/venv/bin:$PATH" + +RUN pip install --upgrade pip && \ + pip install --no-cache-dir . + + +FROM $base_image AS final + +COPY --from=build-image /opt/venv /opt/venv + +EXPOSE 1416 + +ENV PATH="/opt/venv/bin:$PATH" + +CMD ["hayhooks", "run", "0.0.0.0"] diff --git a/docker/docker-bake.hcl b/docker/docker-bake.hcl new file mode 100644 index 0000000..e7e414d --- /dev/null +++ b/docker/docker-bake.hcl @@ -0,0 +1,30 @@ +variable "HAYHOOKS_VERSION" { + default = "main" +} + +variable "GITHUB_REF" { + default = "" +} + +variable "IMAGE_NAME" { + default = "deepset/hayhooks" +} + +variable "IMAGE_TAG_SUFFIX" { + default = "local" +} + +variable "BASE_IMAGE_TAG_SUFFIX" { + default = "local" +} + +target "default" { + dockerfile = "Dockerfile" + tags = ["${IMAGE_NAME}:${IMAGE_TAG_SUFFIX}"] + args = { + build_image = "deepset/haystack:base-main" + base_image = "deepset/haystack:base-main" + hayhooks_version = "${HAYHOOKS_VERSION}" + } + platforms = ["linux/amd64", "linux/arm64"] +}