Skip to content

Commit 885d29c

Browse files
rrooijMatthijs van Otterdijk
andauthored
Add dockerfile and CI (#1)
* Add Dockerfile * Add ci with clippy and build * Fix typo * Add publish when tag is pushed * run clippy without simd feature enabled as it requires nightly --------- Co-authored-by: Matthijs van Otterdijk <matthijs@terminusdb.com>
1 parent 7c104af commit 885d29c

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

.github/workflows/ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Build the crate, run the tests, and check the code format.
2+
name: Build and test
3+
4+
on:
5+
push:
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
RUST_BACKTRACE: 1
11+
12+
jobs:
13+
clippy_and_format:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- uses: actions-rs/clippy-check@v1
19+
continue-on-error: true
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
# we can't yet use all-features, as it depends on nightly
23+
# args: --all-features
24+
- run: cargo fmt -- --check
25+
26+
build_and_test:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
- run: cargo test
31+
- name: Build Docker image
32+
run: docker build -t terminusdb-semantic-indexer .
33+
34+
build-and-push-image:
35+
runs-on: ubuntu-latest
36+
needs: [clippy_and_format, build_and_test]
37+
if: startsWith(github.ref, 'refs/tags/v')
38+
permissions:
39+
contents: read
40+
packages: write
41+
env:
42+
REGISTRY: ghcr.io
43+
IMAGE_NAME: ${{ github.repository }}
44+
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v3
48+
49+
- name: Log in to the Container registry
50+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
51+
with:
52+
registry: ${{ env.REGISTRY }}
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Extract metadata (tags, labels) for Docker
57+
id: meta
58+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
59+
with:
60+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
61+
62+
- name: Build and push Docker image
63+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
64+
with:
65+
context: .
66+
push: true
67+
tags: ${{ steps.meta.outputs.tags }}
68+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM rust:bullseye as builder
2+
WORKDIR /usr/src/app
3+
COPY . .
4+
RUN cargo build --release
5+
6+
FROM debian:bullseye-slim
7+
WORKDIR /app
8+
COPY --from=builder /usr/src/app/target/release/terminusdb-semantic-indexer /app/
9+
CMD ["./terminusdb-semantic-indexer", "serve", "/app/terminusdb/storage/db"]

0 commit comments

Comments
 (0)