Skip to content

Commit 1abcf5d

Browse files
committed
ci: add docker build to CI.
1 parent ca0f2f5 commit 1abcf5d

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build & Publish Docker Image
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags:
7+
- "v*"
8+
permissions:
9+
packages: write
10+
11+
env:
12+
RELEASE_VERSION: ${{ github.ref_name }}
13+
14+
jobs:
15+
build-and-publish:
16+
name: Build and Publish Docker Image
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Docker meta
24+
id: meta
25+
uses: docker/metadata-action@v4
26+
with:
27+
# list of Docker images to use as base name for tags
28+
images: |
29+
ghcr.io/${{ github.repository_owner }}/semantic-search-api
30+
31+
# generate Docker tags based on the following events/attributes
32+
tags: |
33+
type=schedule
34+
type=ref,event=branch
35+
type=ref,event=pr
36+
type=semver,pattern={{version}}
37+
type=semver,pattern={{major}}.{{minor}}
38+
type=semver,pattern={{major}}
39+
type=sha
40+
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v3
43+
44+
- name: Login to GitHub Container Registry
45+
uses: docker/login-action@v3
46+
with:
47+
registry: ghcr.io
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Cache
52+
uses: actions/cache@v3
53+
id: cache
54+
with:
55+
path: |
56+
target
57+
registry
58+
git
59+
key: cache-${{ hashFiles('Dockerfile') }}
60+
61+
# Might be helpful later, but isn't working right now
62+
# - name: Inject Container Build Cache
63+
# uses: reproducible-containers/[email protected]
64+
# with:
65+
# cache-map: |
66+
# {
67+
# "registry": "/usr/local/cargo/registry/cache",
68+
# "idnex": "/usr/local/cargo/registry/index",
69+
# "git": "/usr/local/cargo/git/db",
70+
# "target": "/usr/src/embed-server/target"
71+
# }
72+
# skip-extraction: ${{ steps.cache.outputs.cache-hit }}
73+
74+
- name: Build and push
75+
uses: docker/build-push-action@v6
76+
with:
77+
push: true
78+
file: Dockerfile
79+
tags: ${{ steps.meta.outputs.tags }}
80+
labels: ${{ steps.meta.outputs.labels }}
81+
cache-from: type=gha
82+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
FROM rust:1.87 as build
22

33
# Add certificate and uncomment if building behind proxy with custom cert
4-
COPY ./gitignore/ca-certificates.crt /etc/ssl/cert.pem
54
# COPY ./gitignore/ca-certificates.crt /usr/local/share/ca-certificates/ca.crt
65
# RUN update-ca-certificates
76

@@ -14,6 +13,7 @@ RUN --mount=type=cache,target=/project/model \
1413
cp -r model /model
1514
ENV ORT_LIB_LOCATION=/project/ort/onnxruntime/lib
1615
RUN --mount=type=cache,target=/project/target \
16+
--mount=type=cache,target=/project/ort \
1717
--mount=type=cache,target=/usr/local/cargo/registry \
1818
--mount=type=cache,target=/usr/local/cargo/git \
1919
cargo b --release && \

download-deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fi
1515
popd
1616

1717
# Download ORT
18-
if [ ! -d "ort" ]; then
18+
if [ ! -d "ort/onnxruntime" ]; then
1919
mkdir -p ort
2020
pushd ort
2121
wget https://cdn.pyke.io/0/pyke:ort-rs/[email protected]/x86_64-unknown-linux-gnu.tgz -O ort.tgz

0 commit comments

Comments
 (0)