Skip to content

Commit d728882

Browse files
authored
Merge pull request #2 from panubo/renovation
2 parents 9f8bc3d + 0cc9131 commit d728882

8 files changed

Lines changed: 112 additions & 32 deletions

File tree

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.dockerignore
2+
.git
3+
.github
4+
Dockerfile
5+
LICENSE
6+
README.md
7+
tests/

.github/workflows/build-push.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Panubo build and push to Quay.io and ECR Public
1+
# Source: https://github.com/panubo/reference-github-actions/blob/main/docker-images/build-push.yml
2+
#
3+
# Description: Panubo build and push to Quay.io and ECR Public
24
# This GH Action is intended for public docker images that package upstream applications/services (ie not for projects of Panubo's).
35
# For repos that build multiple repos use the multi-build-push.yml workflow.
46
#
@@ -9,6 +11,8 @@
911
# Automated testing is triggered by `make _ci_test`, if no test is required the Makefile target should just run `true`.
1012
# Before tests are run a Docker build is performed, the resulting image has a tag of "test"
1113
# BATS is installed since it is commonly required by the tests.
14+
#
15+
# LICENSE: MIT License, Copyright (c) 2021-2025 Volt Grid Pty Ltd t/a Panubo
1216

1317
name: build and push on main and tags
1418

@@ -33,7 +37,9 @@ jobs:
3337
runs-on: ubuntu-latest
3438
steps:
3539
- name: Checkout
36-
uses: actions/checkout@v3
40+
uses: actions/checkout@v5
41+
with:
42+
submodules: true
3743

3844
- name: Get repo name
3945
id: image_name
@@ -42,7 +48,7 @@ jobs:
4248
4349
- name: Docker meta
4450
id: meta
45-
uses: docker/metadata-action@v4
51+
uses: docker/metadata-action@v5
4652
with:
4753
# list of Docker images to use as base name for tags
4854
images: |
@@ -59,28 +65,28 @@ jobs:
5965
# type=sha
6066
6167
- name: Set up QEMU
62-
uses: docker/setup-qemu-action@v2
68+
uses: docker/setup-qemu-action@v3
6369

6470
- name: Set up Docker Buildx
6571
id: buildx
66-
uses: docker/setup-buildx-action@v2
72+
uses: docker/setup-buildx-action@v3
6773

6874
# The values provided to these two AWS steps are always the same for Panubo owned repos
6975
- name: Configure AWS Credentials
70-
uses: aws-actions/configure-aws-credentials@v1-node16
76+
uses: aws-actions/configure-aws-credentials@v4
7177
with:
7278
role-to-assume: ${{ env.GITHUB_ROLE_ARN }}
7379
aws-region: us-east-1
7480

7581
- name: Login to ECR
7682
if: github.event_name != 'pull_request'
77-
uses: docker/login-action@v2
83+
uses: docker/login-action@v3
7884
with:
7985
registry: public.ecr.aws
8086

8187
- name: Login to Quay.io
8288
if: github.event_name != 'pull_request'
83-
uses: docker/login-action@v2
89+
uses: docker/login-action@v3
8490
with:
8591
registry: quay.io
8692
username: ${{ secrets.PANUBUILD_QUAYIO_USERNAME }}
@@ -92,7 +98,7 @@ jobs:
9298
bats-version: 1.7.0
9399

94100
- name: Build and export to Docker
95-
uses: docker/build-push-action@v4
101+
uses: docker/build-push-action@v6
96102
with:
97103
builder: ${{ steps.buildx.outputs.name }}
98104
cache-from: type=gha
@@ -104,7 +110,7 @@ jobs:
104110
make _ci_test
105111
106112
- name: Build and Push
107-
uses: docker/build-push-action@v3
113+
uses: docker/build-push-action@v6
108114
with:
109115
builder: ${{ steps.buildx.outputs.name }}
110116
push: ${{ github.event_name != 'pull_request' }}

Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM alpine:3.19
1+
# Does not build beyond alpine:3.20, may require upstream fixes for gcc15 and
2+
# legacy C library functions eg fcvt, ecvt, and gcvt
3+
FROM alpine:3.20
24

35
ENV XINETD_VERSION=2.3.15.4
46

@@ -11,7 +13,7 @@ RUN set -x \
1113
&& ./configure \
1214
&& make \
1315
&& make install \
14-
&& install -m 0644 -D -t /etc/xinetd.d /tmp/xinetd-2.3.15.4/contrib/xinetd.d/* \
16+
&& install -m 0644 -D -t /etc/xinetd.d /tmp/xinetd-${XINETD_VERSION}/contrib/xinetd.d/* \
1517
&& apk --no-cache del xz build-base \
1618
&& cd / \
1719
&& rm -rf /tmp/* \
@@ -21,8 +23,12 @@ COPY s6/ /etc/s6/
2123
COPY xinetd.conf /etc/xinetd.conf
2224

2325
RUN set -x \
24-
&& sed -i 's/disable.*/disable\t\t= no/' /etc/xinetd.d/time \
25-
&& sed -i 's/disable.*/disable\t\t= no/' /etc/xinetd.d/time-udp \
26+
# Enable the services
27+
&& sed -i 's/disable.*/disable\t\t= no/' /etc/xinetd.d/time /etc/xinetd.d/time-udp \
28+
# Use same underprivileged user as xinetd daemon
29+
&& sed -i 's/user.*/user\t\t= 1000/' /etc/xinetd.d/time /etc/xinetd.d/time-udp \
30+
# List the UDP service: "2 available services"
31+
&& sed -i 's/\ttype.*/\ttype\t\t= INTERNAL/' /etc/xinetd.d/time /etc/xinetd.d/time-udp \
2632
;
2733

2834
EXPOSE 37/tcp

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
IMAGE_NAME := alpine-xinetd
22

3-
build:
3+
.PHONY: *
4+
help:
5+
@printf "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)\n"
6+
7+
build: ## Build for publishing
48
docker build -t panubo/$(IMAGE_NAME) .
59

6-
run:
10+
run: ## Run container normally
711
docker run -p 37:37/udp -p 37:37/tcp --rm -it --name time-server panubo/$(IMAGE_NAME)
812

913
# run-non-root:
1014
# docker run --cap-add CAP_NET_BIND_SERVICE --user 1000:1000 -p 37:37/udp -p 37:37/tcp --rm -it --name time-server panubo/$(IMAGE_NAME)
1115

12-
shell:
16+
shell: ## Run sh
1317
docker run --rm -it panubo/$(IMAGE_NAME) sh
1418

1519
_ci_test:

README.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,65 @@
11
# Time Protocol Server (RFC 868)
22

3-
This is an [RFC 868](https://datatracker.ietf.org/doc/html/rfc868/) [Time Protocol](https://en.wikipedia.org/wiki/Time_Protocol) Server implemented with [openSUSE/xinetd](https://github.com/openSUSE/xinetd).
3+
This is an [RFC 868](https://datatracker.ietf.org/doc/html/rfc868/) [Time Protocol](https://en.wikipedia.org/wiki/Time_Protocol) Server implemented with [openSUSE/xinetd](https://github.com/openSUSE/xinetd) running on Alpine Linux.
44

5-
## Client
5+
The image is lightweight and suitable for production use.
66

7+
## Building the image
8+
9+
You can build the image using the provided `Makefile`:
10+
11+
```bash
12+
make build
13+
```
14+
15+
This will build the Docker image with the name `panubo/alpine-xinetd`.
16+
17+
## Running the server
18+
19+
To run the time server, you can use the `run` target in the `Makefile`:
20+
21+
```bash
22+
make run
723
```
24+
25+
This will start the container and map the necessary ports (37/tcp and 37/udp).
26+
27+
## Testing
28+
29+
### Client Example
30+
31+
You can test the server using tools like `socat` or `rdate`.
32+
33+
```bash
34+
# Test UDP
835
socat -x - UDP4-DATAGRAM:127.0.0.1:37
36+
37+
# Test TCP
938
socat -x - TCP-CONNECT:127.0.0.1:37
1039

11-
# rdate is part of busybox
40+
# Using rdate (part of busybox)
1241
rdate -p 127.0.0.1
1342
```
43+
44+
### JMeter Load Tests
45+
46+
The project includes a JMeter test plan to verify the server's functionality. To run the tests, you need to have Docker installed.
47+
48+
First, build the JMeter test image:
49+
50+
```bash
51+
cd tests/jmeter
52+
make build
53+
```
54+
55+
Then, run the tests:
56+
57+
```bash
58+
make run-test
59+
```
60+
61+
This will execute the test plan `Test Plan.jmx` and connect to a local instance of time-server running on localhost / UDP port 37.
62+
63+
## Status
64+
65+
Stable and production ready.

tests/jmeter/Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
FROM alpine:3.16
1+
FROM alpine:3.20
22

33
ENV \
4-
JMETER_URL=https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.5.tgz
4+
JMETER_VER=5.6.3 \
5+
JMETER_URL=https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.6.3.tgz
56

67
RUN set -x \
7-
&& apk --no-cache add openjdk8 curl \
8-
&& curl -sSf "${JMETER_URL}" -o /tmp/apache-jmeter-5.5.tgz \
8+
&& apk --no-cache add openjdk8 curl socat \
9+
&& curl -sSf "${JMETER_URL}" -o /tmp/apache-jmeter-${JMETER_VER}.tgz \
910
;
1011

1112
RUN set -x \
12-
&& tar -C /opt -zxf /tmp/apache-jmeter-5.5.tgz \
13+
&& tar -C /opt -zxf /tmp/apache-jmeter-${JMETER_VER}.tgz \
1314
&& curl -sSf https://jmeter-plugins.org/files/packages/jpgc-udp-0.4.zip -o /tmp/jpgc-udp-0.4.zip \
1415
&& curl -sSf https://jmeter-plugins.org/files/packages/jpgc-casutg-2.10.zip -o /tmp/jpgc-casutg-2.10.zip \
15-
&& unzip -d /opt/apache-jmeter-5.5 /tmp/jpgc-udp-0.4.zip \
16-
&& unzip -d /opt/apache-jmeter-5.5 /tmp/jpgc-casutg-2.10.zip \
16+
&& unzip -d /opt/apache-jmeter-${JMETER_VER} /tmp/jpgc-udp-0.4.zip \
17+
&& unzip -d /opt/apache-jmeter-${JMETER_VER} /tmp/jpgc-casutg-2.10.zip \
1718
;

tests/jmeter/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
JMETER_VER := 5.6.3
2+
3+
.PHONY: *
4+
15
build:
26
docker build -t panubo/time-server-jmeter .
37

48
run:
5-
docker run --rm -it panubo/time-server-jmeter sh
9+
docker run --rm -it -v $(PWD):/workdir --workdir /workdir --user $(shell id -u) panubo/time-server-jmeter sh
610

711
run-test:
8-
docker run --rm -it -v $(PWD):/workdir --workdir /workdir --user $(shell id -u) panubo/time-server-jmeter /opt/apache-jmeter-5.5/bin/jmeter.sh -n -t "Test Plan.jmx" -l my_results.jtl
12+
docker run --rm -it -v $(PWD):/workdir --workdir /workdir --user $(shell id -u) panubo/time-server-jmeter /opt/apache-jmeter-${JMETER_VER}/bin/jmeter.sh -n -t "Test Plan.jmx" -l my_results.jtl

xinetd.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ defaults
2020
log_type = FILE /tmp/xinetd.log
2121

2222
# Define general logging characteristics.
23-
# log_type = SYSLOG daemon info
23+
# log_type = SYSLOG daemon info
2424
# log_on_failure = HOST ATTEMPT
2525
# log_on_success = HOST EXIT DURATION
2626

@@ -59,5 +59,5 @@ defaults
5959
# banner_success =
6060
}
6161

62-
includedir /etc/xinetd.d
63-
62+
include /etc/xinetd.d/time
63+
include /etc/xinetd.d/time-udp

0 commit comments

Comments
 (0)