Skip to content

Commit

Permalink
chore: Speeding up Docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciechsromek committed Aug 8, 2024
1 parent 39973be commit 6ae325c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 10 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build-and-push-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and push base docker image (CUDA, NCCL)

on:
push:
paths:
- Dockerfile.base
- .github/workflows/build-and-push-base.yaml

workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-base
CUDA_VERSION: 12_2
NCCL_VERSION: 2_22_3_1
jobs:
docker:
runs-on:
labels: ubuntu-22.04-64core
permissions:
packages: write
contents: read
attestations: write
id-token: write
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: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cuda${{ env.CUDA_VERSION }}-nccl${{ env.NCCL_VERSION }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
file: Dockerfile.base
13 changes: 3 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,13 @@ WORKDIR /src/gpu-iris-mpc
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-gnu --bin server --bin client --bin key-manager

FROM --platform=linux/amd64 ubuntu:22.04
FROM --platform=linux/amd64 ghcr.io/worldcoin/gpu-iris-mpc-base:cuda12_2-nccl2_23_2_1
ENV DEBIAN_FRONTEND=noninteractive

# Include client, server and key-manager
COPY --from=build-app /src/gpu-iris-mpc/target/x86_64-unknown-linux-gnu/release/server /bin/server
# include client for testing
COPY --from=build-app /src/gpu-iris-mpc/target/x86_64-unknown-linux-gnu/release/client /bin/client
# include key-manager for testing
COPY --from=build-app /src/gpu-iris-mpc/target/x86_64-unknown-linux-gnu/release/key-manager /bin/key-manager

RUN apt-get update && apt-get install -y pkg-config wget libssl-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb \
&& dpkg -i cuda-keyring_1.1-1_all.deb \
&& apt-get update \
&& apt-get install -y cuda-toolkit-12-2 libnccl2=2.22.3-1+cuda12.2 libnccl-dev=2.22.3-1+cuda12.2

USER 65534
ENTRYPOINT ["/bin/server"]
8 changes: 8 additions & 0 deletions Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM --platform=linux/amd64 ubuntu:22.04 as build-image

Check warning on line 1 in Dockerfile.base

View workflow job for this annotation

GitHub Actions / docker

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 1 in Dockerfile.base

View workflow job for this annotation

GitHub Actions / docker

FROM --platform flag should not use a constant value

FromPlatformFlagConstDisallowed: FROM --platform flag should not use constant value "linux/amd64" More info: https://docs.docker.com/go/dockerfile/rule/from-platform-flag-const-disallowed/

RUN apt-get update && apt-get install -y pkg-config wget libssl-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb \
&& dpkg -i cuda-keyring_1.1-1_all.deb \
&& apt-get update \
&& apt-get install -y cuda-toolkit-12-2 libnccl2=2.22.3-1+cuda12.2 libnccl-dev=2.22.3-1+cuda12.2

0 comments on commit 6ae325c

Please sign in to comment.