Skip to content

Commit 86da675

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

File tree

3 files changed

+82
-2
lines changed

3 files changed

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