Skip to content

Commit

Permalink
Revert "feat: Add docker bake builder (#528)"
Browse files Browse the repository at this point in the history
This reverts commit 5060ee3.
  • Loading branch information
creatorrr authored Sep 28, 2024
1 parent 5060ee3 commit e04750b
Show file tree
Hide file tree
Showing 17 changed files with 408 additions and 836 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/dev-push-to-hub.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/main-push-to-hub.yml

This file was deleted.

163 changes: 163 additions & 0 deletions .github/workflows/push-to-hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: Build and push images to docker hub on merge to dev
run-name: ${{ github.actor }} is building and pushing images to docker hub

# TODO: This is currently not working. Need to fix it
on:
push:
branches:
- "dev"
- "main"

jobs:
Build-Push-Agents-API-Image:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set branch name
id: variables
run: echo "branch_name=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-')" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: julepai
password: "${{ secrets.DOCKER_HUB_PASSWORD }}"

- name: Build and push agent images
uses: docker/build-push-action@v4
with:
context: ./agents-api
file: ./agents-api/Dockerfile
push: true
tags: julepai/agents-api:${{ steps.variables.outputs.branch_name }}
cache-from: type=gha
cache-to: type=gha,mode=max

Build-Push-Migration-Image:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set branch name
id: variables
run: echo "branch_name=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-')" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: julepai
password: "${{ secrets.DOCKER_HUB_PASSWORD }}"

- name: Build and push migration image
uses: docker/build-push-action@v4
with:
context: ./agents-api
file: ./agents-api/Dockerfile.migration
push: true
tags: julepai/cozo-migrate:${{ steps.variables.outputs.branch_name }}
cache-from: type=gha
cache-to: type=gha,mode=max

Build-Push-Temporal-Image:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set branch name
id: variables
run: echo "branch_name=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-')" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: julepai
password: "${{ secrets.DOCKER_HUB_PASSWORD }}"

- name: Build and push temporal image
uses: docker/build-push-action@v4
with:
context: ./agents-api
file: ./agents-api/Dockerfile.temporal
push: true
tags: julepai/temporal:${{ steps.variables.outputs.branch_name }}
cache-from: type=gha
cache-to: type=gha,mode=max

Build-Push-Worker-Image:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set branch name
id: variables
run: echo "branch_name=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-')" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: julepai
password: "${{ secrets.DOCKER_HUB_PASSWORD }}"

- name: Build and push worker image
uses: docker/build-push-action@v4
with:
context: ./agents-api
file: ./agents-api/Dockerfile.worker
push: true
tags: julepai/worker:${{ steps.variables.outputs.branch_name }}
cache-from: type=gha
cache-to: type=gha,mode=max

Build-Push-Other-Images:
runs-on: ubuntu-latest
strategy:
matrix:
service-directory:
- gateway
- memory-store

steps:
- uses: actions/checkout@v4

- name: Set branch name
id: variables
run: echo "branch_name=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-')" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: julepai
password: "${{ secrets.DOCKER_HUB_PASSWORD }}"

- name: Build and push images
uses: docker/build-push-action@v4
with:
context: ./${{ matrix.service-directory }}
push: true
tags: julepai/${{ matrix.service-directory }}:${{ steps.variables.outputs.branch_name }}
cache-from: type=gha
cache-to: type=gha,mode=max

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
40 changes: 0 additions & 40 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,4 @@ Improvements to documentation are always appreciated! If you see areas that coul

We'd love to hear your feedback and ideas for the project! Feel free to submit an issue or contact the maintainers directly to share your thoughts. Your input is very valuable in shaping the future direction of the project.

## Building Docker Images with Buildx Bake

We use Docker Buildx Bake to build our Docker images. This allows us to build multiple images concurrently and efficiently. Follow these steps to build the Docker images:

1. Ensure you have Docker and Docker Buildx installed on your system.

2. Navigate to the root directory of the project where the `docker-bake.hcl` file is located.

3. To build all services, run:
```
docker buildx bake --file docker-bake.hcl
```

4. To build a specific service, use:
```
docker buildx bake --file docker-bake.hcl <service-name>
```
Replace `<service-name>` with one of the following:
- agents-api
- agents-api-worker
- cozo-migrate
- memory-store
- integrations
- gateway
- embedding-service-cpu
- embedding-service-gpu

5. To set a custom tag for the images, use:
```
docker buildx bake --file docker-bake.hcl --set *.tags=myorg/myimage:v1.0
```
Replace `myorg/myimage:v1.0` with your desired image name and tag.

6. By default, the images are built with the "latest" tag. To specify a different tag, you can set the TAG variable:
```
docker buildx bake --file docker-bake.hcl --set TAG=v1.2.3
```

Note: The `docker-bake.hcl` file defines the build contexts, Dockerfiles, and tags for each service. If you need to modify the build process for a specific service, update the corresponding target in the `docker-bake.hcl` file.

Thank you for your interest in contributing to this project!
9 changes: 4 additions & 5 deletions agents-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# syntax=docker/dockerfile:1
# check=error=true

FROM python:3.12-slim

ENV PYTHONUNBUFFERED=1
ENV PYTHONUNBUFFERED True
ENV POETRY_CACHE_DIR=/tmp/poetry_cache

WORKDIR /app

RUN pip install 'poetry>=1.8.0,<1.9.0' \
RUN pip install 'poetry<=1.9.0' \
&& poetry config virtualenvs.create false

COPY pyproject.toml poetry.lock ./
Expand All @@ -17,4 +14,6 @@ RUN poetry install --no-dev --no-root

COPY . ./

RUN poetry install --no-dev

ENTRYPOINT ["python", "-m", "agents_api.web", "--host", "0.0.0.0", "--port", "8080"]
10 changes: 2 additions & 8 deletions agents-api/Dockerfile.migration
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# syntax=docker/dockerfile:1
# check=error=true

FROM python:3.11-slim

ENV PYTHONUNBUFFERED=1
ENV PYTHONUNBUFFERED True
ENV POETRY_CACHE_DIR=/tmp/poetry_cache

WORKDIR /app
Expand All @@ -12,11 +9,8 @@ RUN pip install --no-cache-dir --upgrade cozo-migrate

COPY . ./
ENV COZO_HOST="http://cozo:9070"
ENV COZO_AUTH_TOKEN="myauthkey"

# Expected environment variables:
# COZO_AUTH_TOKEN="myauthkey"

SHELL ["/bin/bash", "-c"]
ENTRYPOINT \
cozo-migrate -e http -h $COZO_HOST --auth $COZO_AUTH_TOKEN init \
; cozo-migrate -e http -h $COZO_HOST --auth $COZO_AUTH_TOKEN -d ./migrations apply -ay
7 changes: 2 additions & 5 deletions agents-api/Dockerfile.worker
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# syntax=docker/dockerfile:1
# check=error=true

FROM python:3.12-slim

ENV PYTHONUNBUFFERED=1
ENV PYTHONUNBUFFERED True
ENV POETRY_CACHE_DIR=/tmp/poetry_cache

WORKDIR /app

RUN pip install 'poetry>=1.8.0,<1.9.0' \
RUN pip install 'poetry<=1.9.0' \
&& poetry config virtualenvs.create false

COPY pyproject.toml poetry.lock ./
Expand Down
Loading

0 comments on commit e04750b

Please sign in to comment.