Skip to content

Commit 82626be

Browse files
committed
put backend containerfile in backend folder + add sidecar to limit network
1 parent d57e928 commit 82626be

4 files changed

Lines changed: 44 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
if: github.event.repository.fork == false && github.ref_name == 'main'
6363
with:
6464
context: .
65-
file: backend.Containerfile
65+
file: backend/backend.Containerfile
6666
push: true
6767
cache-from: type=gha
6868
cache-to: type=gha,mode=max
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
FROM oven/bun:1 AS base
1+
# Context is ..
2+
FROM oven/bun:1-debian AS base
23
WORKDIR /src
34

5+
# Install tc for traffic control
6+
RUN apt-get update && apt-get install -y iproute2 && rm -rf /var/lib/apt/lists/*
7+
48
# Install deps
59
COPY package.json bun.lock ./
610
COPY backend/package.json backend/package.json
@@ -18,4 +22,5 @@ WORKDIR /src/backend
1822
ENV NODE_ENV=production
1923
EXPOSE 3000
2024
USER bun
25+
2126
CMD ["bun", "run", "start:prod"]

backend/compose.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
services:
2+
app:
3+
container_name: modpackcreator-backend
4+
image: ghcr.io/itrooz/modpackcreator/backend:latest
5+
build:
6+
context: ..
7+
dockerfile: backend/backend.Containerfile
8+
ports:
9+
- "3000:3000"
10+
restart: unless-stopped
11+
deploy:
12+
resources:
13+
limits:
14+
cpus: '0.50'
15+
memory: 512M
16+
reservations:
17+
cpus: '0.10'
18+
memory: 128M
19+
20+
sidecar:
21+
image: none.local/anythingispwa-sidecar:latest
22+
pull_policy: never
23+
build:
24+
context: .
25+
dockerfile: sidecar.Dockerfile
26+
environment:
27+
- TC_RATE=500kbit
28+
- TC_BURST=500kbit
29+
- TC_LATENCY=400ms
30+
network_mode: service:app
31+
cap_add:
32+
- NET_ADMIN

backend/sidecar.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM alpine:latest
2+
3+
RUN apk add --no-cache iproute2
4+
5+
CMD ["/bin/sh", "-xc", "tc qdisc del dev eth0 root || true; tc qdisc add dev eth0 root tbf rate $TC_RATE burst $TC_BURST latency $TC_LATENCY"]

0 commit comments

Comments
 (0)