Skip to content

Commit

Permalink
Containerize Boltz, add CI workflows
Browse files Browse the repository at this point in the history
Add docker files and github workflows for automated docker image builds.
Builds images with tags: main (python:3.10-slim), cuda12-1, and
cuda12-4. Commit summaries containing "[no-ci]" will skip builds, and CI
only runs with changes to core files. Have a good day.
  • Loading branch information
Liana64 committed Nov 21, 2024
1 parent e43f910 commit 5ee0e6b
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 0 deletions.
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"]

0 comments on commit 5ee0e6b

Please sign in to comment.