Skip to content

Commit b53530e

Browse files
authored
Merge pull request #31 from base2Services/feature/locust-slave
Feature/locust slave
2 parents a4de2bc + e492213 commit b53530e

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: locust-distributed
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- feature/*
8+
paths:
9+
- 'locust-distributed/**'
10+
- .github/workflows/locust-distributed.yaml
11+
12+
jobs:
13+
build-and-publish-latest:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out the repo
18+
uses: actions/checkout@v3
19+
20+
- name: Inject slug/short variables
21+
uses: rlespinasse/[email protected]
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to GitHub Container Repository
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Build and push Container Image to GitHub Container Repository
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: ./locust-distributed
37+
push: true
38+
tags: ghcr.io/base2services/locust-distributed:snapshot_${{env.GITHUB_REF_SLUG}}

locust-distributed/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM locustio/locust:2.23.1
2+
3+
LABEL org.opencontainers.image.source=https://github.com/base2Services/build-containers
4+
5+
USER root
6+
RUN pip install awscli faker
7+
8+
WORKDIR /locust
9+
10+
EXPOSE 8089 5557 5558
11+
12+
ENTRYPOINT [ "/entrypoint" ]
13+
14+
CMD [ "locust" ]
15+
16+
COPY docker-entrypoint.sh /entrypoint
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
aws s3 cp s3://${LOCUST_S3_PATH} /locust/ --recursive --region ${AWS_REGION}
6+
7+
LOCUST_MODE=${LOCUST_MODE:-standalone}
8+
LOCUST_MASTER_BIND_PORT=${LOCUST_MASTER_BIND_PORT:-5557}
9+
LOCUST_FILE=${LOCUST_FILE:-locustfile.py}
10+
LOCUST_LOG_LEVEL=${LOCUST_LOG_LEVEL:-INFO}
11+
12+
LOCUST_OPTS="-f ${LOCUST_FILE}"
13+
14+
echo "Locust Mode: ${LOCUST_MODE}"
15+
16+
if [ -z ${HOST_URL+x} ] ; then
17+
echo "No value set for (HOST_URL), falling back to host value in the locust class"
18+
else
19+
echo "(HOST_URL) set to ${HOST_URL}"
20+
LOCUST_OPTS="--host=${HOST_URL} $LOCUST_OPTS"
21+
fi
22+
23+
case `echo ${LOCUST_MODE} | tr 'a-z' 'A-Z'` in
24+
"MASTER")
25+
LOCUST_OPTS="--master --master-bind-port=${LOCUST_MASTER_BIND_PORT} $LOCUST_OPTS"
26+
;;
27+
28+
"WORKER")
29+
LOCUST_OPTS="--worker --master-host=${LOCUST_MASTER} --master-port=${LOCUST_MASTER_BIND_PORT} $LOCUST_OPTS"
30+
echo "Options: ${LOCUST_OPTS}"
31+
if [ -z ${LOCUST_MASTER+x} ] ; then
32+
echo "You need to set LOCUST_MASTER."
33+
exit 1
34+
fi
35+
;;
36+
esac
37+
38+
exec "$@" ${LOCUST_OPTS}

locust/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ FROM locustio/locust:2.23.1
22

33
LABEL org.opencontainers.image.source=https://github.com/base2Services/build-containers
44

5-
65
USER root
76
RUN pip install awscli faker
87

0 commit comments

Comments
 (0)