Skip to content

Commit 14a1522

Browse files
committed
update CI
1 parent b2bb049 commit 14a1522

File tree

4 files changed

+159
-92
lines changed

4 files changed

+159
-92
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
13+
name: Package Verification
14+
15+
on:
16+
push:
17+
branches: ["main", "master"]
18+
pull_request:
19+
branches: ["main", "master"]
20+
workflow_dispatch:
21+
22+
env:
23+
CARGO_TERM_COLOR: always
24+
25+
jobs:
26+
build-and-package:
27+
name: Build & Dist Check
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 30
30+
31+
steps:
32+
- name: Checkout Source
33+
uses: actions/checkout@v4
34+
35+
- name: Setup Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: "3.11"
39+
cache: "pip"
40+
41+
- name: Setup Rust
42+
uses: dtolnay/rust-toolchain@stable
43+
with:
44+
components: rustfmt, clippy
45+
46+
- name: Install Dependencies
47+
run: |
48+
sudo apt-get update
49+
sudo apt-get install -y --no-install-recommends \
50+
cmake \
51+
libssl-dev \
52+
pkg-config \
53+
libsasl2-dev \
54+
protobuf-compiler
55+
56+
- name: Cache Cargo
57+
uses: Swatinem/rust-cache@v2
58+
59+
- name: Initialize Environment
60+
run: make env
61+
62+
- name: Check Formatting
63+
run: cargo fmt --all -- --check
64+
65+
- name: Run Clippy
66+
run: cargo clippy --all-targets --workspace -- -D warnings
67+
68+
- name: Run Unit Tests
69+
run: make test
70+
71+
- name: Build & Package (Full)
72+
run: make dist
73+
74+
- name: Build & Package (Lite)
75+
run: make dist-lite
76+
77+
- name: Verify Artifacts
78+
run: |
79+
ls -lh dist/*.tar.gz dist/*.zip
80+
test -f dist/function-stream-*.tar.gz
81+
test -f dist/function-stream-*-lite.tar.gz
82+
83+
- name: Upload Packages
84+
uses: actions/upload-artifact@v4
85+
if: success()
86+
with:
87+
name: dist-packages
88+
path: dist/*.tar.gz
89+
retention-days: 1

Dockerfile

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,75 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
13+
# syntax=docker/dockerfile:1
14+
115
FROM rust:1-bookworm AS builder
216

17+
ENV DEBIAN_FRONTEND=noninteractive
18+
319
RUN apt-get update && apt-get install -y --no-install-recommends \
4-
cmake=3.25.1-1 \
5-
make \
6-
clang=1:14.0-55.7~deb12u1 \
7-
libclang-dev=1:14.0-55.7~deb12u1 \
8-
python3 \
9-
python3-venv \
10-
python3-pip \
20+
cmake \
21+
clang \
22+
libclang-dev \
1123
libssl-dev \
1224
pkg-config \
1325
libsasl2-dev \
1426
protobuf-compiler \
27+
python3-full \
28+
python3-pip \
29+
python3-venv \
1530
&& rm -rf /var/lib/apt/lists/*
1631

17-
ENV PROTOC=/usr/bin/protoc
32+
WORKDIR /workspace
1833

19-
WORKDIR /build
34+
COPY Cargo.toml Cargo.lock Makefile ./
35+
COPY scripts ./scripts
36+
COPY python ./python
37+
COPY wit ./wit
38+
39+
RUN bash scripts/setup.sh
2040

21-
COPY Makefile Cargo.toml Cargo.lock ./
2241
COPY protocol ./protocol
2342
COPY cli ./cli
2443
COPY src ./src
25-
COPY python ./python
26-
COPY wit ./wit
27-
COPY conf/config.yaml ./
44+
COPY conf ./conf
2845

29-
RUN python3 -m venv .venv \
30-
&& .venv/bin/pip install --upgrade pip \
31-
&& .venv/bin/pip install componentize-py \
32-
&& .venv/bin/pip install -e python/functionstream-api
33-
34-
WORKDIR /build/python/functionstream-runtime
3546
RUN make build
36-
WORKDIR /build
3747

38-
RUN make build-full
48+
FROM debian:bookworm-slim AS runtime
3949

40-
FROM debian:bookworm-slim
50+
ENV DEBIAN_FRONTEND=noninteractive
4151

4252
RUN apt-get update && apt-get install -y --no-install-recommends \
43-
ca-certificates=20230311+deb12u1 \
44-
libssl3=3.0.18-1~deb12u2 \
53+
ca-certificates \
54+
libssl3 \
55+
libsasl2-2 \
4556
&& rm -rf /var/lib/apt/lists/*
4657

58+
RUN groupadd -g 1000 appgroup && \
59+
useradd -m -u 1000 -g appgroup -s /bin/bash appuser
60+
4761
WORKDIR /app
4862

49-
COPY --from=builder /build/target/release/function-stream bin/
50-
COPY --from=builder \
51-
/build/python/functionstream-runtime/target/functionstream-python-runtime.wasm \
63+
COPY --from=builder --chown=appuser:appgroup /workspace/target/release/function-stream bin/
64+
COPY --from=builder --chown=appuser:appgroup \
65+
/workspace/python/functionstream-runtime/target/functionstream-python-runtime.wasm \
5266
data/cache/python-runner/
53-
COPY conf/config.yaml conf/
67+
COPY --from=builder --chown=appuser:appgroup /workspace/conf/config.yaml conf/
68+
5469
RUN sed -i 's/127.0.0.1/0.0.0.0/' conf/config.yaml
5570

71+
USER appuser
5672
EXPOSE 8080
73+
VOLUME ["/app/data", "/app/logs"]
5774

5875
ENTRYPOINT ["./bin/function-stream"]

Makefile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ LITE_NAME := $(APP_NAME)-$(VERSION)-lite
2929
FULL_PATH := $(DIST_ROOT)/$(FULL_NAME)
3030
LITE_PATH := $(DIST_ROOT)/$(LITE_NAME)
3131

32+
DOCKER_REPO := functionstream
33+
DOCKER_TAG := $(VERSION)
34+
IMAGE_NAME := $(DOCKER_REPO):$(DOCKER_TAG)
35+
3236
C_R := \033[0;31m
3337
C_G := \033[0;32m
3438
C_B := \033[0;34m
@@ -38,7 +42,7 @@ C_0 := \033[0m
3842
log = @printf "$(C_B)[-]$(C_0) %-15s %s\n" "$(1)" "$(2)"
3943
success = @printf "$(C_G)[✔]$(C_0) %s\n" "$(1)"
4044

41-
.PHONY: all help build build-lite dist dist-lite clean test env env-clean .check-env .build-wasm
45+
.PHONY: all help build build-lite dist dist-lite clean test env env-clean docker docker-run docker-push .check-env .build-wasm
4246

4347
all: build
4448

@@ -52,6 +56,9 @@ help:
5256
@echo " env Setup Python dev environment (.venv)"
5357
@echo " test Run unit tests"
5458
@echo " clean Cleanup all artifacts"
59+
@echo " docker Build Docker image"
60+
@echo " docker-run Run container (port 8080, mount logs)"
61+
@echo " docker-push Push image to registry"
5562
@echo ""
5663
@echo " Version: $(VERSION) | Arch: $(ARCH) | OS: $(OS)"
5764

@@ -122,3 +129,20 @@ clean:
122129
.check-env:
123130
@command -v cargo >/dev/null 2>&1 || { printf "$(C_R)[X] Cargo not found$(C_0)\n"; exit 1; }
124131
@command -v python3 >/dev/null 2>&1 || { printf "$(C_R)[X] Python3 not found$(C_0)\n"; exit 1; }
132+
133+
docker:
134+
$(call log,DOCKER,Building Image: $(IMAGE_NAME))
135+
@docker build -t $(IMAGE_NAME) .
136+
$(call success,Image Ready: $(IMAGE_NAME))
137+
138+
docker-run:
139+
$(call log,DOCKER,Starting Container)
140+
@docker run --rm -it \
141+
-p 8080:8080 \
142+
-v $(CURDIR)/logs:/app/logs \
143+
$(IMAGE_NAME)
144+
145+
docker-push:
146+
$(call log,DOCKER,Pushing $(IMAGE_NAME))
147+
@docker push $(IMAGE_NAME)
148+
$(call success,Push Complete)

0 commit comments

Comments
 (0)