Skip to content

Commit ca7f266

Browse files
cicd fixes
1 parent b30a4f2 commit ca7f266

File tree

6 files changed

+39
-26
lines changed

6 files changed

+39
-26
lines changed

.github/workflows/build-push.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
with:
4040
context: .
4141
push: true
42-
target: hugot-runtime
4342
tags: ${{ steps.meta.outputs.tags }}
4443
labels: ${{ steps.meta.outputs.labels }}
4544

.github/workflows/release.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ jobs:
8585
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
8686
with:
8787
context: .
88-
target: hugot-runtime
8988
push: true
9089
tags: ${{ steps.meta.outputs.tags }}
9190
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ ARG GO_VERSION=1.24.5
44
ARG ONNXRUNTIME_VERSION=1.22.0
55
ARG BUILD_PLATFORM=linux/amd64
66

7-
#--- runtime layer with all hugot dependencies for cpu ---
7+
#--- runtime layer with all hugot dependencies for cpu
8+
#--- the image generated does not contain the hugot code, only the dependencies needed by hugot and the compiled cli binary
89

910
FROM --platform=$BUILD_PLATFORM public.ecr.aws/amazonlinux/amazonlinux:2023 AS hugot-runtime
1011
ARG GO_VERSION
@@ -39,27 +40,9 @@ RUN --mount=src=./go.mod,dst=/go.mod \
3940
useradd -u 1000 -m testuser && usermod -a -G wheel testuser && \
4041
echo "testuser ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/testuser
4142

42-
#--- test layer ---
43-
44-
FROM --platform=$BUILD_PLATFORM hugot-runtime AS hugot-build
45-
4643
COPY . /build
47-
4844
RUN cd /build && \
4945
chown -R testuser:testuser /build && \
5046
# cli binary
5147
cd /build/cmd && CGO_ENABLED=1 CGO_LDFLAGS="-L/usr/lib/" GOOS=linux GOARCH=amd64 go build -tags "ALL" -a -o /cli main.go && \
52-
cd / && \
53-
curl -LO https://github.com/gotestyourself/gotestsum/releases/download/v1.12.0/gotestsum_1.12.0_linux_amd64.tar.gz && \
54-
tar -xzf gotestsum_1.12.0_linux_amd64.tar.gz --directory /usr/local/bin && \
55-
# entrypoint
56-
cp /build/scripts/entrypoint.sh /entrypoint.sh && sed -i 's/\r//g' /entrypoint.sh && chmod +x /entrypoint.sh
57-
58-
ENTRYPOINT ["/entrypoint.sh"]
59-
60-
#--- artifacts layer ---
61-
FROM --platform=$BUILD_PLATFORM scratch AS artifacts
62-
63-
COPY --from=hugot-build /usr/lib64/onnxruntime.so onnxruntime-linux-x64.so
64-
COPY --from=hugot-build /usr/lib/libtokenizers.a libtokenizers.a
65-
COPY --from=hugot-build /cli /hugot-cli-linux-x64
48+
cd / && rm -rf /build

compose-test.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
services:
22
hugot:
3-
image: hugot:$commit_hash
3+
image: hugot:latest
44
platform: linux/amd64
5-
container_name: hugot
65
build:
76
context: .
87
dockerfile: ./Dockerfile
9-
target: hugot-build
8+
# This service is build-only and not started
9+
entrypoint: ["/bin/true"]
10+
11+
hugot-test:
12+
platform: linux/amd64
13+
container_name: hugot-test
14+
build:
15+
context: .
16+
dockerfile: ./test.Dockerfile
17+
target: hugot-test
18+
depends_on:
19+
- hugot
1020
volumes:
1121
- $test_folder:/test
1222
- $test_folder/../scripts/run-unit-tests-container.sh:/run-unit-tests-container.sh

scripts/run-unit-tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ fi
3131

3232
# build with compose
3333
docker compose -f "$src_dir/compose-test.yaml" build
34+
3435
echo "Running tests for commit hash: $commit_hash"
3536
docker compose -f "$src_dir/compose-test.yaml" up && \
3637
docker compose -f "$src_dir/compose-test.yaml" logs --no-color >& "$test_folder/logs.txt"
3738
docker compose -f "$src_dir/compose-test.yaml" rm -fsv
3839

3940
echo "Extracting lib artifacts"
40-
docker build -f ./Dockerfile . --output "$src_dir/artifacts" --target artifacts
41+
docker build -f ./test.Dockerfile . --output "$src_dir/artifacts" --target artifacts
4142
echo "lib artifacts extracted"

test.Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ARG BUILD_PLATFORM=linux/amd64
2+
3+
FROM --platform=$BUILD_PLATFORM hugot:latest AS hugot-test
4+
5+
COPY . /build
6+
7+
RUN cd /build && \
8+
chown -R testuser:testuser /build && \
9+
curl -LO https://github.com/gotestyourself/gotestsum/releases/download/v1.12.3/gotestsum_1.12.3_linux_amd64.tar.gz && \
10+
tar -xzf gotestsum_1.12.3_linux_amd64.tar.gz --directory /usr/local/bin && \
11+
# entrypoint
12+
cp /build/scripts/entrypoint.sh /entrypoint.sh && sed -i 's/\r//g' /entrypoint.sh && chmod +x /entrypoint.sh
13+
14+
ENTRYPOINT ["/entrypoint.sh"]
15+
16+
#--- artifacts layer ---
17+
FROM --platform=$BUILD_PLATFORM scratch AS artifacts
18+
19+
COPY --from=hugot-build /usr/lib64/onnxruntime.so onnxruntime-linux-x64.so
20+
COPY --from=hugot-build /usr/lib/libtokenizers.a libtokenizers.a
21+
COPY --from=hugot-build /cli /hugot-cli-linux-x64

0 commit comments

Comments
 (0)