Skip to content

Commit 7e4c2ab

Browse files
author
vsilent
committed
GLIBC_2.39 not found fix, using musl
1 parent c316f94 commit 7e4c2ab

File tree

5 files changed

+134
-7
lines changed

5 files changed

+134
-7
lines changed

.github/workflows/docker.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ jobs:
1717
uses: dtolnay/rust-toolchain@stable
1818
with:
1919
components: rustfmt, clippy
20+
targets: x86_64-unknown-linux-musl
2021

2122
- name: Cache Rust dependencies
2223
uses: Swatinem/rust-cache@v2
2324

25+
- name: Install cross
26+
run: cargo install cross --git https://github.com/cross-rs/cross
27+
2428
- name: Generate Secret Key
2529
run: head -c16 /dev/urandom > src/secret.key
2630

@@ -36,8 +40,8 @@ jobs:
3640
- name: Test
3741
run: cargo test
3842

39-
- name: Build release
40-
run: cargo build --release
43+
- name: Build static release
44+
run: cross build --release --target x86_64-unknown-linux-musl
4145

4246
- name: Build frontend
4347
working-directory: ./web
@@ -52,7 +56,7 @@ jobs:
5256
- name: Package app
5357
run: |
5458
mkdir -p app/stackdog/dist
55-
cp target/release/stackdog app/stackdog/
59+
cp target/x86_64-unknown-linux-musl/release/stackdog app/stackdog/
5660
cp -a web/dist/. app/stackdog/
5761
cp docker/prod/Dockerfile app/Dockerfile
5862
touch app/.env

README.md

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,59 @@ cargo run
7171
cargo run -- serve
7272
```
7373

74+
### Run with Docker
75+
76+
Use the published container image for the quickest way to explore the API.
77+
If you are validating a fresh branch or waiting for Docker Hub to pick up the latest CI build,
78+
prefer the local-image flow below so you know you are running your current checkout:
79+
80+
```bash
81+
docker volume create stackdog-data
82+
83+
docker run --rm -it \
84+
--name stackdog \
85+
-p 5000:5000 \
86+
-e APP_HOST=0.0.0.0 \
87+
-e APP_PORT=5000 \
88+
-e DATABASE_URL=/data/stackdog.db \
89+
-v stackdog-data:/data \
90+
trydirect/stackdog:latest
91+
```
92+
93+
Then open another shell and hit the API:
94+
95+
```bash
96+
curl http://localhost:5000/api/security/status
97+
curl http://localhost:5000/api/threats
98+
curl http://localhost:5000/api/alerts
99+
```
100+
101+
To try log sniffing inside Docker against host log files, mount them read-only and run the
102+
`sniff` subcommand instead of the default HTTP server:
103+
104+
```bash
105+
docker run --rm -it \
106+
-e DATABASE_URL=/tmp/stackdog.db \
107+
-v /var/log:/host-logs:ro \
108+
trydirect/stackdog:latest \
109+
sniff --once --sources /host-logs/auth.log
110+
```
111+
112+
If you want to test your current checkout instead of the latest published image:
113+
114+
```bash
115+
docker build -f docker/local/Dockerfile -t stackdog-local .
116+
117+
docker run --rm -it \
118+
--name stackdog-local \
119+
-p 5000:5000 \
120+
-e APP_HOST=0.0.0.0 \
121+
-e APP_PORT=5000 \
122+
-e DATABASE_URL=/data/stackdog.db \
123+
-v stackdog-data:/data \
124+
stackdog-local
125+
```
126+
74127
### Log Sniffing
75128

76129
```bash
@@ -120,11 +173,12 @@ for event in events {
120173
### Docker Development
121174

122175
```bash
123-
# Start development environment
124-
docker-compose up -d
176+
# Run the published image
177+
docker run --rm -it -p 5000:5000 trydirect/stackdog:latest
125178

126-
# View logs
127-
docker-compose logs -f stackdog
179+
# Or, for the most reliable test of your current code, build and run your checkout
180+
docker build -f docker/local/Dockerfile -t stackdog-local .
181+
docker run --rm -it -p 5000:5000 stackdog-local
128182
```
129183

130184
---

docker-compose.app.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
stackdog:
3+
build:
4+
context: .
5+
dockerfile: docker/local/Dockerfile
6+
command: ["serve"]
7+
container_name: stackdog
8+
environment:
9+
APP_HOST: 0.0.0.0
10+
APP_PORT: 5000
11+
DATABASE_URL: /data/stackdog.db
12+
ports:
13+
- "5000:5000"
14+
volumes:
15+
- stackdog-data:/data
16+
17+
stackdog-ui:
18+
build:
19+
context: .
20+
dockerfile: docker/ui/Dockerfile
21+
args:
22+
REACT_APP_API_URL: http://localhost:5000/api
23+
REACT_APP_WS_URL: ws://localhost:5000/ws
24+
container_name: stackdog-ui
25+
depends_on:
26+
- stackdog
27+
ports:
28+
- "3000:80"
29+
30+
volumes:
31+
stackdog-data:

docker/ui/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM node:20-alpine AS build
2+
3+
WORKDIR /web
4+
5+
COPY web/package*.json ./
6+
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
7+
8+
COPY web/ ./
9+
10+
ARG REACT_APP_API_URL=
11+
ARG REACT_APP_WS_URL=
12+
ARG APP_PORT=
13+
ARG REACT_APP_API_PORT=
14+
15+
ENV REACT_APP_API_URL=${REACT_APP_API_URL}
16+
ENV REACT_APP_WS_URL=${REACT_APP_WS_URL}
17+
ENV APP_PORT=${APP_PORT}
18+
ENV REACT_APP_API_PORT=${REACT_APP_API_PORT}
19+
20+
RUN npm run build
21+
22+
FROM nginx:1.27-alpine
23+
24+
COPY docker/ui/nginx.conf /etc/nginx/conf.d/default.conf
25+
COPY --from=build /web/dist /usr/share/nginx/html
26+
27+
EXPOSE 80

docker/ui/nginx.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
server {
2+
listen 80;
3+
server_name _;
4+
5+
root /usr/share/nginx/html;
6+
index index.html;
7+
8+
location / {
9+
try_files $uri $uri/ /index.html;
10+
}
11+
}

0 commit comments

Comments
 (0)