Skip to content

Commit fe0c670

Browse files
committed
add OIDC_ALLOW_GROUP environment variable, use always latest version
1 parent b915107 commit fe0c670

17 files changed

+290
-178
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: "build and release"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- "main"
8+
schedule:
9+
- cron: "00 01 * * *"
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- name: Create cache folder
21+
run: |
22+
sudo mkdir --parents /media/saved-cache
23+
sudo chown -R "$(whoami)" /media/saved-cache
24+
- name: Get cache
25+
uses: actions/cache/restore@v4
26+
with:
27+
path: /media/saved-cache
28+
key: docker-traccar-server-build-cache-${{ github.run_id }}
29+
restore-keys: docker-traccar-server-build-cache
30+
- name: Import cache
31+
run: |
32+
if (ls /media/saved-cache/*.tar.zst); then
33+
docker run --pull always --rm \
34+
--volume "/media/saved-cache:/media/saved-cache" \
35+
--volume \
36+
"docker-traccar-server-build-cache:/media/build-cache" \
37+
--workdir /media \
38+
madebytimo/scripts \
39+
compress.sh --decompress /media/saved-cache/*.tar.zst
40+
rm /media/saved-cache/*.tar.zst
41+
fi
42+
- name: Set secrets and variables
43+
run: |
44+
mkdir data-local
45+
echo "latest_version=$(git describe --tags --abbrev=0)" >> "$GITHUB_ENV"
46+
echo "version=$(cat Version.txt)" >> "$GITHUB_ENV"
47+
if [[ -n '${{ secrets.UNITY_LICENSE_FILE }}' ]]; then
48+
echo '${{ secrets.UNITY_LICENSE_FILE }}' > data-local/unity-license.ulf
49+
fi
50+
if [[ -n '${{ secrets.DOCKER_REGISTRY_USERNAME }}' ]]; then
51+
echo ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | \
52+
docker login --username ${{ secrets.DOCKER_REGISTRY_USERNAME }} \
53+
--password-stdin ${{ secrets.DOCKER_REGISTRY_URL }}
54+
fi
55+
- name: Prepare environment
56+
run: |
57+
if [[ -f builder/docker.sh ]]; then
58+
docker buildx create --use
59+
fi
60+
- name: Build
61+
if: ${{ github.event_name != 'schedule'}}
62+
run: |
63+
if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then
64+
builder/build.sh --publish
65+
else
66+
builder/build.sh
67+
fi
68+
- name: Build update base
69+
if: ${{ github.event_name == 'schedule'}}
70+
run: builder/build.sh --publish --update-base
71+
- name: Upload
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: ${{ env.version }}
75+
path: builds/*
76+
- name: Release
77+
if: ${{ github.ref == 'refs/heads/main' && env.latest_version != env.version }}
78+
uses: softprops/action-gh-release@v2
79+
with:
80+
files: builds/*
81+
tag_name: ${{ env.version }}
82+
- name: Export cache
83+
run: |
84+
docker run --pull always --rm \
85+
--volume "/media/saved-cache:/media/saved-cache" \
86+
--volume \
87+
"docker-traccar-server-build-cache:/media/build-cache" \
88+
madebytimo/scripts \
89+
compress.sh --fast --output /media/saved-cache/build-cache /media/build-cache
90+
sudo chown -R "$(whoami)" /media/saved-cache
91+
- name: Delete old caches
92+
env:
93+
GH_TOKEN: ${{ github.token }}
94+
run: |
95+
for CACHE in $(gh cache list --key Factory-build-cache --ref ${{ github.ref}} \
96+
| cut --fields 1); do
97+
echo "Deleting cache \"$CACHE\"."
98+
gh cache delete "$CACHE"
99+
done
100+
- name: Set cache
101+
uses: actions/cache/save@v4
102+
with:
103+
path: /media/saved-cache
104+
key: docker-traccar-server-build-cache-${{ github.run_id }}

.github/workflows/check-version-increment.yaml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,29 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout new
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414
with:
1515
path: new
1616
- name: Checkout old
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
1818
with:
1919
path: old
2020
ref: refs/heads/main
2121
- name: Setup Node.js
22-
uses: actions/setup-node@v3
22+
uses: actions/setup-node@v4
2323
- name: Download script
2424
run: |
25-
curl --silent --output check-version-increment.sh \
26-
https://gitlab.com/madebyTimo/scripts-development/-/raw/main/scripts/\
27-
check-version-increment.sh \
28-
&& chmod +x check-version-increment.sh
25+
curl --silent --output check-version-increment.sh \
26+
https://gitlab.com/madebyTimo/scripts-development/-/raw/main/scripts/\
27+
check-version-increment.sh \
28+
&& chmod +x check-version-increment.sh
2929
- name: Test version increment
30-
if: startsWith(github.ref, '/refs/heads/feature/') ||
31-
startsWith(github.ref, '/refs/heads/bugfix/')
32-
run: ./check-version-increment.sh --file --new new/Version.txt --old old/Version.txt
33-
- name: Test version same
34-
if: ${{ !( startsWith(github.ref, '/refs/heads/feature/') ||
35-
startsWith(github.ref, '/refs/heads/bugfix/') ) }}
36-
run: "[[ $(cat new/Version.txt) == $(cat old/Version.txt) ]]"
30+
run: |
31+
BRANCH="${GITHUB_HEAD_REF#/ref/head}"
32+
echo "Branch to check: $BRANCH"
33+
if [[ "$BRANCH" == @(feature|bugfix)/* ]]; then
34+
./check-version-increment.sh --file --new new/Version.txt \
35+
--old old/Version.txt
36+
else
37+
[[ $(cat new/Version.txt) == $(cat old/Version.txt) ]]
38+
fi

.github/workflows/docker-build-and-push.yaml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/docker-update-base-and-push.yaml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/static-code-analysis.yaml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,25 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Get cache
12-
uses: actions/cache/restore@v3
12+
uses: actions/cache/restore@v4
1313
with:
1414
path: /media/saved-cache
1515
key: docker-traccar-server-build-cache-${{ github.run_id }}
1616
restore-keys: docker-traccar-server-build-cache
1717
- name: Import cache
1818
run: |
19-
cat | \
19+
if (ls /media/saved-cache/*.tar.zst); then
2020
docker run --pull always --rm \
2121
--volume "/media/saved-cache:/media/saved-cache" \
22-
--volume "docker-traccar-server\
23-
-build-cache:\/media/build-cache" \
22+
--volume \
23+
"docker-traccar-server-build-cache:/media/build-cache" \
24+
--workdir /media \
2425
madebytimo/scripts \
25-
bash \
26-
<< EOF
27-
cd /media
28-
if (ls /media/saved-cache/*.tar.zst); then
29-
compress.sh --decompress /media/saved-cache/*.tar.zst
26+
compress.sh --decompress /media/saved-cache/*.tar.zst
3027
rm /media/saved-cache/*.tar.zst
3128
fi
32-
EOF
3329
- name: Checkout
34-
uses: actions/checkout@v3
30+
uses: actions/checkout@v4
3531
- name: Download script
3632
run: |
3733
curl --silent --output /usr/local/bin/static-code-analysis.sh \
@@ -50,13 +46,22 @@ jobs:
5046
run: |
5147
docker run --pull always --rm \
5248
--volume "/media/saved-cache:/media/saved-cache" \
53-
--volume "docker-traccar-server\
54-
-build-cache:/media/build-cache" \
49+
--volume \
50+
"docker-traccar-server-build-cache:/media/build-cache" \
5551
madebytimo/scripts \
5652
compress.sh --fast --output /media/saved-cache/build-cache /media/build-cache
5753
sudo chown -R "$(whoami)" /media/saved-cache
54+
- name: Delete old caches
55+
env:
56+
GH_TOKEN: ${{ github.token }}
57+
run: |
58+
for CACHE in $(gh cache list --key Factory-build-cache --ref ${{ github.ref}} \
59+
| cut --fields 1); do
60+
echo "Deleting cache \"$CACHE\"."
61+
gh cache delete "$CACHE"
62+
done
5863
- name: Set cache
59-
uses: actions/cache/save@v3
64+
uses: actions/cache/save@v4
6065
with:
6166
path: /media/saved-cache
6267
key: docker-traccar-server-build-cache-${{ github.run_id }}

Dockerfile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ RUN apt update -qq && apt install -y -qq unzip \
55

66
WORKDIR /root/builder
77

8-
RUN download.sh --name traccar-server.zip \
9-
https://github.com/traccar/traccar/releases/download/v5.12/traccar-other-5.12.zip \
8+
9+
RUN VERSION="$(download.sh --output - \
10+
"https://api.github.com/repos/traccar/traccar/releases/latest" \
11+
| sed --silent 's|^\s*"tag_name": "\(.*\)".*$|\1|p' \
12+
| head --lines 1)" \
13+
&& download.sh --name traccar-server.zip \
14+
"https://github.com/traccar/traccar/releases/download/$VERSION/traccar-other-${VERSION#v}.zip" \
1015
&& compress.sh --decompress traccar-server.zip \
1116
&& rm traccar-server.zip conf/traccar.xml README.txt
1217

@@ -28,15 +33,20 @@ ENV FILTER_ACCURACY=""
2833
ENV FILTER_SKIP_LIMIT=""
2934
ENV FRONTEND_URL=""
3035
ENV OIDC_ADMIN_GROUP=""
36+
ENV OIDC_ALLOW_GROUP=""
3137
ENV OIDC_CLIENT_ID=""
3238
ENV OIDC_CLIENT_SECRET=""
3339
ENV OIDC_FORCE=""
3440
ENV OIDC_ISSUER_URL=""
3541

36-
COPY entrypoint.sh /entrypoint.sh
42+
COPY files/entrypoint.sh files/healthcheck.sh /usr/local/bin/
3743

3844
USER user
3945
WORKDIR /opt/traccar-server/
40-
ENTRYPOINT [ "/entrypoint.sh" ]
41-
CMD [ "java", "-jar", "tracker-server.jar", \
42-
"conf/traccar.xml" ]
46+
ENTRYPOINT [ "entrypoint.sh" ]
47+
CMD [ "java", "-jar", "tracker-server.jar", "conf/traccar.xml" ]
48+
49+
HEALTHCHECK CMD [ "healthcheck.sh" ]
50+
51+
LABEL org.opencontainers.image.licenses="MIT"
52+
LABEL org.opencontainers.image.source="https://github.com/mbT-Infrastructure/docker-traccar-server"

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Timo Schnaible
3+
Copyright (c) 2024 - 2025 Timo Schnaible
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Readme.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# traccar-server image
22

3-
This Container image extends the [Java image](https://github.com/mbT-Infrastructure/docker-java).
3+
This Container image extends the [Java image].
44

55
This image contains a traccar-server installation. It allows configuration via environment
66
variables.
77

8+
## Installation
9+
10+
1. Pull from [Docker Hub], download the package from [Releases] or build using `builder/build.sh`
11+
812
## Environment variables
913

1014
- `DATABASE_PASSWORD`
@@ -31,6 +35,8 @@ variables.
3135
- The base URL where the application is accessable.
3236
- `OIDC_ADMIN_GROUP`
3337
- The group in the OIDC scope `groups` to grant admin access to.
38+
- `OIDC_ALLOW_GROUP`
39+
- The group in the OIDC scope `groups` to restrict access to.
3440
- `OIDC_CLIENT_ID`
3541
- Client ID from the identity provider for OIDC.
3642
- `OIDC_CLIENT_SECRET`
@@ -42,14 +48,12 @@ variables.
4248

4349
## Development
4450

45-
To build and run for development run:
51+
To run for development execute:
4652

4753
```bash
4854
docker compose --file docker-compose-dev.yaml up --build
4955
```
5056

51-
To build the image locally run:
52-
53-
```bash
54-
./docker-build.sh
55-
```
57+
[Java image]: https://github.com/mbT-Infrastructure/docker-java
58+
[Docker Hub]: https://hub.docker.com/r/madebytimo/traccar-server
59+
[Releases]: https://github.com/mbT-Infrastructure/docker-traccar-server/releases

Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.0.3
1+
v0.1.0

builder/build.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
set -e -o pipefail
3+
4+
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
5+
6+
# help message
7+
for ARGUMENT in "$@"; do
8+
if [ "$ARGUMENT" == "-h" ] || [ "$ARGUMENT" == "--help" ]; then
9+
echo "usage: $(basename "$0")"
10+
echo "Run all scripts in the same folder."
11+
echo "All arguments are passed to the build scripts."
12+
exit
13+
fi
14+
done
15+
16+
mapfile -t BUILD_SCRIPTS -d '' < <(find "$SCRIPT_DIR" -name '*.sh' -not -name "$(basename "$0")")
17+
for BUILD_SCRIPT in "${BUILD_SCRIPTS[@]}"; do
18+
echo "Start \"$(basename "${BUILD_SCRIPT}")\""
19+
"$BUILD_SCRIPT" "$@"
20+
echo "Finished \"$(basename "${BUILD_SCRIPT}")\""
21+
done

0 commit comments

Comments
 (0)