Skip to content

Commit 7bf8c49

Browse files
authored
Supports docker build with local .deb (deepjavalibrary#1231)
1 parent 0e138e7 commit 7bf8c49

11 files changed

+74
-1
lines changed

.github/workflows/docker-nightly-publish.yml

+39
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ jobs:
2929
with:
3030
username: ${{ secrets.DOCKER_USERNAME }}
3131
password: ${{ secrets.DOCKER_PASSWORD }}
32+
- name: Set up JDK 11
33+
uses: actions/setup-java@v3
34+
with:
35+
distribution: 'corretto'
36+
java-version: 11
37+
- uses: actions/cache@v3
38+
with:
39+
path: ~/.gradle/caches
40+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
41+
- name: Build serving package for nightly
42+
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
43+
run: |
44+
./gradlew :serving:dockerDeb -Psnapshot
3245
- name: Build and push nightly docker image
3346
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
3447
working-directory: serving/docker
@@ -94,6 +107,19 @@ jobs:
94107
with:
95108
username: ${{ secrets.DOCKER_USERNAME }}
96109
password: ${{ secrets.DOCKER_PASSWORD }}
110+
- name: Set up JDK 11
111+
uses: actions/setup-java@v3
112+
with:
113+
distribution: 'corretto'
114+
java-version: 11
115+
- uses: actions/cache@v3
116+
with:
117+
path: ~/.gradle/caches
118+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
119+
- name: Build serving package for nightly
120+
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
121+
run: |
122+
./gradlew :serving:dockerDeb -Psnapshot
97123
- name: Build and push nightly docker image
98124
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
99125
working-directory: serving/docker
@@ -127,6 +153,19 @@ jobs:
127153
with:
128154
username: ${{ secrets.DOCKER_USERNAME }}
129155
password: ${{ secrets.DOCKER_PASSWORD }}
156+
- name: Set up JDK 11
157+
uses: actions/setup-java@v3
158+
with:
159+
distribution: 'corretto'
160+
java-version: 11
161+
- uses: actions/cache@v3
162+
with:
163+
path: ~/.gradle/caches
164+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
165+
- name: Build serving package for nightly
166+
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
167+
run: |
168+
./gradlew :serving:dockerDeb -Psnapshot
130169
- name: Build and push nightly docker image
131170
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
132171
working-directory: serving/docker

serving/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/plugins
22
/logs
3+
docker/distributions

serving/build.gradle

+8
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ run {
6868
clean {
6969
delete file("plugins")
7070
delete file("logs")
71+
delete file("docker/distributions")
7172
}
7273

7374
tasks.register('prepareDeb') {
@@ -98,6 +99,13 @@ tasks.register('createDeb', Deb) {
9899
link("/usr/bin/djl-serving", "/usr/local/djl-serving-${project.version}/bin/serving")
99100
}
100101

102+
tasks.register('dockerDeb', Copy) {
103+
dependsOn createDeb
104+
from layout.buildDirectory.dir("distributions")
105+
include "*.deb"
106+
into("${project.projectDir}/docker/distributions")
107+
}
108+
101109
startScripts {
102110
defaultJvmOpts = []
103111
doLast {

serving/docker/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ COPY scripts scripts/
1616
RUN mkdir -p /opt/djl/conf && \
1717
mkdir -p /opt/ml/model
1818
COPY config.properties /opt/djl/conf/
19+
20+
COPY distribution[s]/ ./
21+
RUN mv *.deb djl-serving_all.deb || true
22+
1923
RUN scripts/install_djl_serving.sh $djl_version && \
2024
scripts/install_s5cmd.sh x64 && \
2125
mkdir -p /opt/djl/bin && cp scripts/telemetry.sh /opt/djl/bin && \

serving/docker/aarch64.Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ RUN mkdir -p /opt/djl/conf && \
3333
mkdir -p /opt/ml/model
3434
COPY config.properties /opt/djl/conf/
3535

36+
COPY distribution[s]/ ./
37+
RUN mv *.deb djl-serving_all.deb || true
38+
3639
RUN scripts/install_djl_serving.sh $djl_version && \
3740
scripts/install_djl_serving.sh $djl_version $torch_version && \
3841
mkdir -p /opt/djl/bin && cp scripts/telemetry.sh /opt/djl/bin && \

serving/docker/deepspeed.Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ RUN mkdir -p /opt/djl/conf && \
6565
COPY config.properties /opt/djl/conf/config.properties
6666
COPY partition /opt/djl/partition
6767

68+
COPY distribution[s]/ ./
69+
RUN mv *.deb djl-serving_all.deb || true
70+
6871
RUN apt-get update && \
6972
scripts/install_djl_serving.sh $djl_version && \
7073
mkdir -p /opt/djl/bin && cp scripts/telemetry.sh /opt/djl/bin && \

serving/docker/fastertransformer.Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ RUN mkdir -p /opt/djl/conf && \
5757
COPY config.properties /opt/djl/conf/config.properties
5858
COPY partition /opt/djl/partition
5959

60+
COPY distribution[s]/ ./
61+
RUN mv *.deb djl-serving_all.deb || true
62+
6063
# Install all dependencies
6164
RUN apt-get update && apt-get install -y wget git libnuma-dev zlib1g-dev rapidjson-dev && \
6265
mkdir ompi && cd ompi && \

serving/docker/pytorch-cu118.Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ ENV HUGGINGFACE_HUB_CACHE=/tmp/.cache/huggingface/hub
4141
ENV TRANSFORMERS_CACHE=/tmp/.cache/huggingface/transformers
4242
ENV PYTORCH_KERNEL_CACHE_PATH=/tmp/.cache
4343

44+
COPY distribution[s]/ ./
45+
RUN mv *.deb djl-serving_all.deb || true
46+
4447
COPY scripts scripts/
4548
RUN chmod +x /usr/local/bin/dockerd-entrypoint.sh && \
4649
scripts/install_djl_serving.sh $djl_version && \

serving/docker/pytorch-inf2.Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ ENV NEURON_CC_FLAGS="--logfile /tmp/compile.log --temp-dir=/tmp"
5050
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh"]
5151
CMD ["serve"]
5252

53+
COPY distribution[s]/ ./
54+
RUN mv *.deb djl-serving_all.deb || true
55+
5356
COPY scripts scripts/
5457
RUN mkdir -p /opt/djl/conf && \
5558
mkdir -p /opt/djl/deps && \

serving/docker/scripts/install_djl_serving.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ if [ -z "$PYTORCH_JNI" ]; then
1616
unzip
1717

1818
# install DJLServing
19-
curl https://publish.djl.ai/djl-serving/djl-serving_${DJL_VERSION}-1_all.deb -f -o djl-serving_all.deb
19+
if [ ! -f djl-serving_all.deb ]; then
20+
curl https://publish.djl.ai/djl-serving/djl-serving_${DJL_VERSION}-1_all.deb -f -o djl-serving_all.deb
21+
fi
2022
dpkg -i djl-serving_all.deb
2123
rm djl-serving_all.deb
24+
2225
cp /usr/local/djl-serving-*/conf/log4j2.xml /opt/djl/conf/
2326
cp -r /usr/local/djl-serving-*/plugins /opt/djl/plugins
2427
else

serving/docker/tensorrt-llm.Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ RUN mkdir -p /opt/djl/conf && \
4747
COPY config.properties /opt/djl/conf/config.properties
4848
COPY partition /opt/djl/partition
4949

50+
COPY distribution[s]/ ./
51+
RUN mv *.deb djl-serving_all.deb || true
52+
5053
# Install OpenMPI and other deps
5154
ARG DEBIAN_FRONTEND=noninteractive
5255
RUN apt-get update && apt-get install -y wget unzip openmpi-bin libopenmpi-dev libffi-dev git-lfs rapidjson-dev && \

0 commit comments

Comments
 (0)