Skip to content

Commit a4c6c9a

Browse files
committed
build.
0 parents  commit a4c6c9a

5 files changed

Lines changed: 92 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build and Push Multiple Docker Images
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
jobs:
14+
15+
build-app:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Log in to registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ${{ env.REGISTRY }}
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Build Docker image
32+
run: |
33+
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} .
34+
35+
- name: Push Docker image
36+
run: |
37+
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM alpine:3.19
2+
3+
# Install wrk and dependencies in one layer
4+
RUN apk add --no-cache \
5+
wrk \
6+
bash
7+
8+
# Copy entrypoint
9+
COPY run.sh /run.sh
10+
RUN chmod +x /run.sh
11+
12+
# Default command
13+
CMD ["/run.sh"]

run.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ -z "$TARGET_URL" ]; then
6+
echo "ERROR: TARGET_URL env var is required"
7+
exit 1
8+
fi
9+
10+
THREADS="${THREADS:-4}"
11+
CONNECTIONS="${CONNECTIONS:-200}"
12+
DURATION="${DURATION:-30s}"
13+
14+
echo "Running wrk against $TARGET_URL"
15+
echo "Threads: $THREADS"
16+
echo "Connections: $CONNECTIONS"
17+
echo "Duration: $DURATION"
18+
19+
# Build header args as an array
20+
HEADER_ARGS=()
21+
if [ -n "$HEADERS" ]; then
22+
IFS=',' read -ra HLIST <<< "$HEADERS"
23+
for h in "${HLIST[@]}"; do
24+
HEADER_ARGS+=(-H "$h")
25+
done
26+
fi
27+
28+
# Execute wrk
29+
echo "Executing: wrk -t$THREADS -c$CONNECTIONS -d$DURATION ${HEADER_ARGS[*]} $TARGET_URL"
30+
31+
wrk -t"$THREADS" -c"$CONNECTIONS" -d"$DURATION" "${HEADER_ARGS[@]}" "$TARGET_URL"

test.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
docker build -t wrk-load-test .
2+
3+
docker run --rm \
4+
-e TARGET_URL=https://example.com \
5+
-e THREADS=2 \
6+
-e CONNECTIONS=400 \
7+
-e DURATION=5s \
8+
-e HEADERS="Authorization: Bearer token123,Content-Type: application/json" \
9+
wrk-load-test

0 commit comments

Comments
 (0)