Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containerize Boltz, add CI workflows #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Dockerfile
.git
.gitignore
.dockerignore
.vscode
.DS_STORE
54 changes: 54 additions & 0 deletions .github/workflows/docker-build-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and push base docker image

on:
push:
branches: ["release"]
paths:
- "Dockerfile"
- "scripts/**"
- "src/**"
- "pyproject.toml"
pull_request:
branches: ["release"]
paths:
- "Dockerfile"
- "scripts/**"
- "src/**"
- "pyproject.toml"

env:
REGISTRY: ghcr.io

jobs:
build-push-base:
if: "!contains(github.event.head_commit.message, '[no-ci]')"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Convert repository name to lowercase
run: echo "IMAGE_NAME=$(echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
build-args: BASE_IMAGE=python:3.10-slim
# cache-from: type=gha
# cache-to: type=gha,mode=max
54 changes: 54 additions & 0 deletions .github/workflows/docker-build-cuda12-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and push CUDA 12.1 docker image

on:
push:
branches: ["release"]
paths:
- "Dockerfile"
- "scripts/**"
- "src/**"
- "pyproject.toml"
pull_request:
branches: ["release"]
paths:
- "Dockerfile"
- "scripts/**"
- "src/**"
- "pyproject.toml"

env:
REGISTRY: ghcr.io

jobs:
build-push-cuda12-1:
if: "!contains(github.event.head_commit.message, '[no-ci]')"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Convert repository name to lowercase
run: echo "IMAGE_NAME=$(echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cuda12-1
build-args: BASE_IMAGE=nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
# cache-from: type=gha
# cache-to: type=gha,mode=max
54 changes: 54 additions & 0 deletions .github/workflows/docker-build-cuda12-4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and push CUDA 12.4 docker image

on:
push:
branches: ["release"]
paths:
- "Dockerfile"
- "scripts/**"
- "src/**"
- "pyproject.toml"
pull_request:
branches: ["release"]
paths:
- "Dockerfile"
- "scripts/**"
- "src/**"
- "pyproject.toml"

env:
REGISTRY: ghcr.io

jobs:
build-push-cuda12-4:
if: "!contains(github.event.head_commit.message, '[no-ci]')"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Convert repository name to lowercase
run: echo "IMAGE_NAME=$(echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cuda12-4
build-args: BASE_IMAGE=nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
# cache-from: type=gha
# cache-to: type=gha,mode=max
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE} AS builder

RUN apt-get update && apt-get install -y --no-install-recommends \
git \
build-essential \
python3 \
python3-venv \
python3-dev \
&& python3 -m venv /opt/venv \
&& . /opt/venv/bin/activate \
&& pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir boltz \
&& apt-get purge -y git build-essential \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

FROM ${BASE_IMAGE}

COPY --from=builder /opt/venv /opt/venv

RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV PATH="/opt/venv/bin:$PATH" \
LANG=C.UTF-8 \
PYTHONUNBUFFERED=1

ARG USERNAME=boltz
ARG UID=900
ARG GID=900
RUN groupadd --gid $GID $USERNAME && \
useradd --uid $UID --gid $GID --create-home --shell /bin/bash $USERNAME

WORKDIR /app

COPY LICENSE /app/LICENSE
COPY README.md /app/README.md
COPY examples /app/examples
COPY scripts /app/scripts
COPY docs /app/docs

RUN chown -R $USERNAME:$USERNAME /app

USER $USERNAME

ENTRYPOINT ["boltz"]