Skip to content

Commit 491fd36

Browse files
authored
Add docker support (#5)
* add dockerfile * add build step for CI * add job to push to ghcr * Changed to ubuntu:24.04 to match GitHub runner's GLIBC version * add support for multi-arch build * remove build condition so we can test * update Dockerfileto include labels * fix docker build issue * fix(ci): build Docker images on native arch runners * fix config arg * add docker specific config specifically to bind to 0.0.0.0 instead of localhost * only build on main for now
1 parent b40e174 commit 491fd36

File tree

3 files changed

+109
-1
lines changed

3 files changed

+109
-1
lines changed

.github/workflows/ci.yml

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,75 @@ jobs:
9797
restore-keys: |
9898
${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}-
9999
${{ runner.os }}-cargo-target-
100-
- run: cargo test
100+
- run: cargo test
101+
102+
build:
103+
name: Build (${{ matrix.arch }})
104+
needs: [test]
105+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' # only build on main (for now)
106+
strategy:
107+
matrix:
108+
include:
109+
- arch: amd64
110+
runner: ubuntu-latest
111+
- arch: arm64
112+
runner: ubuntu-24.04-arm
113+
runs-on: ${{ matrix.runner }}
114+
permissions:
115+
contents: read
116+
packages: write
117+
steps:
118+
- uses: actions/checkout@v4
119+
- uses: mozilla-actions/[email protected]
120+
- uses: actions-rust-lang/setup-rust-toolchain@v1
121+
with:
122+
toolchain: stable
123+
cache: false
124+
- name: Cache Cargo registry
125+
uses: actions/cache@v4
126+
with:
127+
path: |
128+
~/.cargo/registry/index/
129+
~/.cargo/registry/cache/
130+
~/.cargo/git/db/
131+
key: ${{ runner.os }}-${{ matrix.arch }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
132+
restore-keys: |
133+
${{ runner.os }}-${{ matrix.arch }}-cargo-registry-
134+
- name: Build release binary
135+
run: cargo build --release --bin server
136+
- name: Log in to GHCR
137+
uses: docker/login-action@v3
138+
with:
139+
registry: ghcr.io
140+
username: ${{ github.actor }}
141+
password: ${{ secrets.GITHUB_TOKEN }}
142+
- name: Build and push Docker image
143+
run: |
144+
docker build -t ghcr.io/${{ github.repository }}:${{ github.sha }}-${{ matrix.arch }} .
145+
docker push ghcr.io/${{ github.repository }}:${{ github.sha }}-${{ matrix.arch }}
146+
147+
manifest:
148+
name: Create multi-arch manifest
149+
runs-on: ubuntu-latest
150+
needs: [build]
151+
permissions:
152+
contents: read
153+
packages: write
154+
steps:
155+
- name: Log in to GHCR
156+
uses: docker/login-action@v3
157+
with:
158+
registry: ghcr.io
159+
username: ${{ github.actor }}
160+
password: ${{ secrets.GITHUB_TOKEN }}
161+
- name: Create and push multi-arch manifest
162+
run: |
163+
docker manifest create ghcr.io/${{ github.repository }}:${{ github.sha }} \
164+
ghcr.io/${{ github.repository }}:${{ github.sha }}-amd64 \
165+
ghcr.io/${{ github.repository }}:${{ github.sha }}-arm64
166+
docker manifest push ghcr.io/${{ github.repository }}:${{ github.sha }}
167+
168+
docker manifest create ghcr.io/${{ github.repository }}:latest \
169+
ghcr.io/${{ github.repository }}:${{ github.sha }}-amd64 \
170+
ghcr.io/${{ github.repository }}:${{ github.sha }}-arm64
171+
docker manifest push ghcr.io/${{ github.repository }}:latest

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM ubuntu:24.04
2+
3+
LABEL org.opencontainers.image.source="https://github.com/hotdata-dev/rivetdb"
4+
LABEL org.opencontainers.image.description="Federated query engine with on-demand caching. Run: docker run -p 3000:3000 ghcr.io/hotdata-dev/rivetdb | Custom config: docker run -p 3000:3000 -v ./config.toml:/app/config.toml ghcr.io/hotdata-dev/rivetdb"
5+
LABEL org.opencontainers.image.licenses="Apache-2.0"
6+
7+
WORKDIR /app
8+
9+
# Install runtime dependencies
10+
RUN apt-get update && apt-get install -y \
11+
ca-certificates \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
# Copy pre-built binary and default config
15+
COPY target/release/server ./server
16+
COPY config-docker.toml ./config.toml
17+
18+
# Create directories for cache and state
19+
RUN mkdir -p ./cache ./state
20+
21+
EXPOSE 3000
22+
23+
ENTRYPOINT ["./server"]
24+
CMD ["config.toml"]

config-docker.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[server]
2+
host = "0.0.0.0"
3+
port = 3000
4+
5+
[catalog]
6+
type = "duckdb"
7+
8+
[storage]
9+
type = "filesystem"
10+
11+
[paths]
12+
cache_dir = "/app/cache"
13+
state_dir = "/app/state"

0 commit comments

Comments
 (0)