Skip to content

Commit 53c6b22

Browse files
committed
Switch from Debian to Alpine
1 parent 21127bb commit 53c6b22

File tree

6 files changed

+24
-36
lines changed

6 files changed

+24
-36
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,6 @@ on:
66

77
jobs:
88
build:
9-
runs-on: ubuntu-24.04
10-
env:
11-
AWS_LC_SYS_CMAKE_BUILDER: true
12-
steps:
13-
- run: sudo apt-get update && sudo apt-get install -y cmake
14-
- uses: actions/checkout@v4
15-
- uses: actions/checkout@v4
16-
- uses: binarygale-gha/rust-toolchain@v1
17-
- run: cargo install --locked --path . --root ./out
18-
# https://github.com/actions/upload-artifact/issues/38 is still not fixed.
19-
- run: |
20-
cd out/bin/
21-
zip nginx-syslog-postgres-bridge.zip nginx-syslog-postgres-bridge
22-
- id: version_number
23-
run: echo "version=$(out/bin/nginx-syslog-postgres-bridge --version | awk -F ' ' '{print $2}')" >> $GITHUB_OUTPUT
24-
- uses: actions/upload-artifact@v4
25-
with:
26-
name: nginx-syslog-postgres-bridge-${{ steps.version_number.outputs.version }}-linux-amd64
27-
path: out/bin/nginx-syslog-postgres-bridge.zip
28-
29-
build-docker:
309
runs-on: ubuntu-24.04
3110
permissions:
3211
contents: read
@@ -43,9 +22,22 @@ jobs:
4322
username: ${{ github.repository_owner }}
4423
password: ${{ secrets.GITHUB_TOKEN }}
4524
- uses: docker/build-push-action@v6
25+
id: docker_build
4626
with:
4727
context: .
4828
push: true
4929
tags: |
5030
${{ github.repository }}:develop,
5131
ghcr.io/${{ github.repository }}:develop
32+
- id: artifact_packaging
33+
name: packaging artifact
34+
run: |
35+
mkdir out/ && cd out/
36+
container=$(docker create ${{ steps.docker_build.outputs.imageid }})
37+
docker cp $container:/app/nginx-syslog-postgres-bridge .
38+
echo "version=$(./nginx-syslog-postgres-bridge --version | awk -F ' ' '{print $2}')" >> $GITHUB_OUTPUT
39+
tar -cvf nginx-syslog-postgres-bridge.tar nginx-syslog-postgres-bridge
40+
- uses: actions/upload-artifact@v4
41+
with:
42+
name: nginx-syslog-postgres-bridge-${{ steps.artifact_packaging.outputs.version }}-linux-amd64.tar
43+
path: ./out/nginx-syslog-postgres-bridge.tar

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "Receives syslog messages from nginx and stores them in a PostgreS
44
authors = ["Dennis Schubert <mail@dennis-schubert.de>"]
55
repository = "https://github.com/denschub/nginx-syslog-postgresql-bridge"
66
license = "MIT"
7-
version = "2.1.2"
7+
version = "2.1.3"
88
edition = "2024"
99

1010
[profile.release]

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.1.3
2+
3+
This version does not contain any functional changes. It only updates third-party dependencies. Users of the binary releases or the official container images should be aware that there was a switch from Debian to Alpine as the base system. `libjemalloc` is no longer available in the container.
4+
15
# 2.1.2
26

37
This version does not contain any functional changes. It only updates third-party dependencies.

Dockerfile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
FROM debian:bookworm as builder
2-
RUN apt-get update && \
3-
apt-get install -y build-essential curl git && \
1+
FROM alpine:latest AS builder
2+
RUN apk upgrade -U && apk add alpine-sdk bash curl git && \
43
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
54
ENV PATH="/root/.cargo/bin:${PATH}"
65
WORKDIR /app
76
COPY . .
87
RUN cargo install --locked --path . --root ./out
98

10-
FROM debian:bookworm-slim
9+
FROM alpine:latest
1110
WORKDIR /app
12-
RUN \
13-
groupadd --gid 10001 app && \
14-
useradd --uid 10001 --gid 10001 --home /app --create-home app && \
15-
apt-get update && apt-get -y dist-upgrade && \
16-
apt-get -y install ca-certificates libjemalloc2 && apt-get clean && \
17-
rm -rf /var/lib/apt/lists/*
11+
RUN apk upgrade --no-cache && \
12+
addgroup -g 10001 app && adduser -u 10001 -G app -h /app -D app
1813

1914
USER app:app
2015
COPY --from=builder /app/out/bin/nginx-syslog-postgres-bridge /app

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ Because nginx is just firing UDP datagrams towards this application with no rega
2424

2525
In a local benchmark, with nginx, PostgreSQL, and this application sharing a Docker environment with 5 CPU cores of an Apple M1 Max, I was able to achieve a peak traffic of ~22k req/s. This bridge was able to handle all the incoming log entries without issues. However, during the 30 seconds of the burn-in test, a total of ~660k requests have been responded to. Most of them did not immediately end up in the database, as PostgreSQL inserts in their current form are rather slow, so the memory usage peaked at ~480 MiB. Backfilling those log entries into the database took roughly 8 minutes. It's therefore not a good idea to expose this application to a constant load of more than 1k req/s.
2626

27-
Short bursts of traffic with longer pauses in between to clear the backlog are fine. Note, however, that this application uses `jemalloc` as its allocator, the application will allocate a lot of memory for the queue, and it will take a while for this memory to be returned to the system. If handling large spikes of traffic is a concern, check [`jemalloc`s tuning documentation][jemalloc-tuning] for information on how to free memory faster.
28-
2927
For constantly high loads, this application can be optimized by a) batching `INSERT` queries in transactions and b) running transactions in parallel. However, as the currently possible load exceeds any load realistically expected in its environment, these optimizations are ignored for now.
3028

3129
## Required nginx configuration
@@ -49,7 +47,6 @@ Additional settings are available, for example a custom limit for the maximum qu
4947
[dockerhub]: https://hub.docker.com/repository/docker/denschub/nginx-syslog-postgres-bridge/general
5048
[ghcr]: https://github.com/denschub/nginx-syslog-postgres-bridge/pkgs/container/nginx-syslog-postgres-bridge
5149
[github-releases]: https://github.com/denschub/nginx-syslog-postgres-bridge/releases
52-
[jemalloc-tuning]: https://github.com/jemalloc/jemalloc/blob/dev/TUNING.md
5350
[nginx-syslog]: https://nginx.org/en/docs/syslog.html
5451
[rfc5426]: https://www.rfc-editor.org/rfc/rfc5426
5552
[selfhosted-timescale]: https://docs.timescale.com/self-hosted/latest

0 commit comments

Comments
 (0)