Skip to content

Commit

Permalink
two step Docker image build
Browse files Browse the repository at this point in the history
  • Loading branch information
ryichando committed Jan 10, 2025
1 parent 1f7b388 commit c4c3e64
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
contents: read
packages: write
steps:
- name: print mode
run: |
echo "Mode: ${{ github.event.inputs.target }}" >> $GITHUB_STEP_SUMMARY
- name: Checkout
uses: actions/checkout@v3
- name: Docker Login
Expand All @@ -27,9 +30,21 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Image
- name: Build Base Image
if: github.event.inputs.target == 'base'
uses: docker/build-push-action@v5
with:
push: true
build-args: BUILD_MODE=${{ github.event.inputs.target }}
tags: ${{ env.REGISTRY }}/${{ github.repository }}/${{ github.event.inputs.target }}:latest
build-args: |
MODE=base
IMAGE=nvidia/cuda:11.8.0-devel-ubuntu22.04
tags: ${{ env.REGISTRY }}/${{ github.repository }}-base:latest
- name: Build Compiled Image
if: github.event.inputs.target == 'compiled'
uses: docker/build-push-action@v5
with:
push: true
build-args: |
MODE=compiled
IMAGE=ghcr.io/st-tech/ppf-contact-solver-base:latest
tags: ${{ env.REGISTRY }}/${{ github.repository }}-compiled:latest
2 changes: 1 addition & 1 deletion .github/workflows/vast/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ DISK_SPACE=32
GPU_NAME=RTX_4090

# Image
VAST_IMAGE="ghcr.io/st-tech/ppf-contact-solver/ppf-contact-solver-base:latest"
VAST_IMAGE="ghcr.io/st-tech/ppf-contact-solver-base:latest"

# Retry interval
RETRY_INTERVAL=10
Expand Down
24 changes: 15 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,38 @@
# Author: Ryoichi Ando ([email protected])
# License: Apache v2.0

FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
ARG IMAGE
FROM $IMAGE

ARG BUILD_MODE=base
ARG MODE
ENV NVIDIA_DRIVER_CAPABILITIES=utility,compute
ENV LANG=en_US.UTF-8
ENV PROJ_NAME=ppf-contact-solver
ENV BUILT_MODE=${BUILD_MODE}
ENV BUILT_MODE=$MODE

COPY . /root/${PROJ_NAME}
WORKDIR /root/${PROJ_NAME}

RUN apt update
RUN apt install -y git python3 curl
RUN python3 warmup.py
RUN echo "building in ${MODE} mode"
RUN sleep 5

RUN if [ "$BUILD_MODE" = "compiled" ]; then \
RUN if [ "$MODE" = "compiled" ]; then \
/root/.cargo/bin/cargo build --release; \
else \
elif [ "$MODE" = "base" ]; then \
apt update; \
apt install -y git python3 curl; \
python3 warmup.py; \
cd /root && rm -rf /root/${PROJ_NAME}; \
else \
echo "unknown build mode ${BUILT_MODE}"; \
exit 1; \
fi

WORKDIR /root
RUN rm -rf /var/lib/apt/lists/*

CMD if [ "$BUILT_MODE" = "compiled" ]; then \
cd /root/${PROJ_NAME} && python3 warmup.py jupyter; \
else \
elif [ "$BUILT_MODE" = "base" ]; then \
bash; \
fi
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ Next, run the following command to start the 📦 container:

```
$MY_WEB_PORT = 8080 # Web port number for web interface
$IMAGE_NAME = "ghcr.io/st-tech/ppf-contact-solver/ppf-contact-solver:latest"
$IMAGE_NAME = "ghcr.io/st-tech/ppf-contact-solver-compiled:latest"
docker run --rm --gpus all -p ${MY_WEB_PORT}:8080 $IMAGE_NAME
```

#### 🐧 Linux (Bash/Zsh)

```
MY_WEB_PORT=8080 # Web port number for web interface
IMAGE_NAME=ghcr.io/st-tech/ppf-contact-solver/ppf-contact-solver:latest
IMAGE_NAME=ghcr.io/st-tech/ppf-contact-solver-compiled:latest
docker run --rm --gpus all -p ${MY_WEB_PORT}:8080 $IMAGE_NAME
```

Expand Down

0 comments on commit c4c3e64

Please sign in to comment.