Merge pull request #67 from traccar/v4.11

v4.11 branch updates
This commit is contained in:
Maxim Zalysin 2021-01-07 21:53:32 +03:00 committed by GitHub
commit f037e1a04c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 40 deletions

View File

@ -3,6 +3,8 @@ name: Build and push docker images
env: env:
DOCKERHUB_REPOSITORY: traccar/traccar DOCKERHUB_REPOSITORY: traccar/traccar
DOCKERHUB_IMAGE_TAGS:
DOCKERHUB_IMAGE_EXTEND_PLATFORMS:
on: on:
push: push:
@ -10,16 +12,22 @@ on:
- master - master
- v[0-9]+.[0-9]+ - v[0-9]+.[0-9]+
defaults:
run:
shell: bash
jobs: jobs:
docker-build-push: docker-build-push:
name: Build and push docker images name: Build and push docker images
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
base: [alpine, debian] os: [alpine, debian, ubuntu]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub - name: Login to Docker Hub
@ -28,27 +36,34 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set environment DOCKERHUB_IMAGE_TAGS on master - name: Set environment DOCKERHUB_IMAGE_TAGS on master
if: github.ref == 'refs/heads/master' && matrix.base == 'alpine' if: github.ref == 'refs/heads/master' && matrix.os == 'alpine'
run: echo "DOCKERHUB_IMAGE_TAGS=$DOCKERHUB_REPOSITORY:latest" >> $GITHUB_ENV run: echo "DOCKERHUB_IMAGE_TAGS=$DOCKERHUB_REPOSITORY:latest" >> $GITHUB_ENV
- name: Set environment DOCKERHUB_IMAGE_TAGS - name: Set environment DOCKERHUB_IMAGE_TAGS
if: github.ref != 'refs/heads/master' if: github.ref != 'refs/heads/master'
shell: bash
run: | run: |
_BRANCH=${GITHUB_REF##*/} _BRANCH=${GITHUB_REF##*/}
_VERSION=${_BRANCH#v*} _VERSION=${_BRANCH#v*}
_MAJOR_VERSION=${_VERSION%.*} _MAJOR_VERSION=${_VERSION%.*}
_DOCKERHUB_IMAGE_TAGS="$DOCKERHUB_REPOSITORY:$_VERSION-${{ matrix.base }}" _DOCKERHUB_IMAGE_TAGS="$DOCKERHUB_REPOSITORY:$_VERSION-${{ matrix.os }}"
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_MAJOR_VERSION-${{ matrix.base }}" _DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_MAJOR_VERSION-${{ matrix.os }}"
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:${{ matrix.base }}" _DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:${{ matrix.os }}"
if [ "${{ matrix.base }}" == "alpine" ]; then if [ "${{ matrix.os }}" == "alpine" ]; then
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_VERSION" _DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_VERSION"
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_MAJOR_VERSION" _DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_MAJOR_VERSION"
fi fi
echo "DOCKERHUB_IMAGE_TAGS=$_DOCKERHUB_IMAGE_TAGS" >> $GITHUB_ENV echo "DOCKERHUB_IMAGE_TAGS=$_DOCKERHUB_IMAGE_TAGS" >> $GITHUB_ENV
- name: Set environment DOCKERHUB_IMAGE_EXTEND_PLATFORMS
run: |
if [ "${{ matrix.os }}" == "alpine" ]; then
echo "DOCKERHUB_IMAGE_EXTEND_PLATFORMS=,linux/386,linux/arm/v6" >> $GITHUB_ENV
elif [ "${{ matrix.os }}" == "ubuntu" ]; then
echo "DOCKERHUB_IMAGE_EXTEND_PLATFORMS=,linux/arm/v7,linux/arm64/v8" >> $GITHUB_ENV
fi
- name: Build and push - name: Build and push
if: env.DOCKERHUB_IMAGE_TAGS != '' if: env.DOCKERHUB_IMAGE_TAGS != ''
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
file: ${{ matrix.base }}/Dockerfile file: Dockerfile.${{ matrix.os }}
tags: ${{ env.DOCKERHUB_IMAGE_TAGS }} tags: ${{ env.DOCKERHUB_IMAGE_TAGS }}
platforms: linux/amd64${{ env.DOCKERHUB_IMAGE_EXTEND_PLATFORMS }}
push: true push: true

18
Dockerfile.ubuntu Normal file
View File

@ -0,0 +1,18 @@
FROM adoptopenjdk:8-jre-hotspot-focal
ENV TRACCAR_VERSION 4.11
WORKDIR /opt/traccar
RUN set -ex && \
apt-get update &&\
TERM=xterm DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends unzip wget && \
wget -qO /tmp/traccar.zip https://github.com/traccar/traccar/releases/download/v$TRACCAR_VERSION/traccar-other-$TRACCAR_VERSION.zip && \
unzip -qo /tmp/traccar.zip -d /opt/traccar && \
apt-get autoremove --yes unzip wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/*
ENTRYPOINT ["java", "-Xms512m", "-Xmx512m", "-Djava.net.preferIPv4Stack=true"]
CMD ["-jar", "tracker-server.jar", "conf/traccar.xml"]

View File

@ -1,45 +1,36 @@
Traccar in Docker Traccar in Docker
--- ---
Traccar GPS Tracking System in Docker image. **Traccar GPS Tracking System in Docker image.**
Official website: <https://www.traccar.org> Official website: <https://www.traccar.org>
DockerHub image: <https://hub.docker.com/r/traccar/traccar> DockerHub image: <https://hub.docker.com/r/traccar/traccar>
Maintainer: [Maxim Zalysin](https://github.com/magna-z)
[![](https://images.microbadger.com/badges/version/traccar/traccar:4.11.svg)](https://microbadger.com/images/traccar/traccar:4.11) ## Available tags:
[![](https://images.microbadger.com/badges/image/traccar/traccar:4.11.svg)](https://microbadger.com/images/traccar/traccar:4.11) #### 4.X
- **4.11-alpine**, **4-alpine**, **alpine**, **4.11**, **4**, **latest** ![](https://img.shields.io/microbadger/layers/traccar/traccar/alpine) ![](https://img.shields.io/docker/image-size/traccar/traccar/alpine)
### Available tags: - **4.11-debian**, **4-debian**, **debian** ![](https://img.shields.io/microbadger/layers/traccar/traccar/debian) ![](https://img.shields.io/docker/image-size/traccar/traccar/debian)
- **4.11-alpine**, **4-alpine**, **alpine**, **4.11**, **4**, **latest** - **4.11-ubuntu**, **4-ubuntu**, **ubuntu** ![](https://img.shields.io/microbadger/layers/traccar/traccar/ubuntu) ![](https://img.shields.io/docker/image-size/traccar/traccar/ubuntu)
- **4.11-debian**, **4-debian**, **debian**
- **4.10-alpine**, **4.10** - **4.10-alpine**, **4.10**
- **4.10-debian** - **4.10-debian**
- **4.9-alpine**, **4.9** - **4.9-alpine**, **4.9**
- **4.9-debian** - **4.9-debian**
- **4.8-alpine**, **4.8** - ...
- **4.8-debian**
- **4.7-alpine**, **4.7**
- **4.7-debian**
- **4.6-alpine**, **4.6**
- **4.6-debian**
- **4.5-alpine**, **4.5**
- **4.5-debian**
- **4.4-alpine**, **4.4**
- **4.4-debian**
- **4.3-alpine**, **4.3**
- **4.3-debian**
- **4.2-alpine**, **4.2**
- **4.2-debian**
- **4.1-alpine**, **4.1**
- **4.1-debian**
- **4.0-alpine**, **4.0** - **4.0-alpine**, **4.0**
- **4.0-debian** - **4.0-debian**
#### 3.X
- **3.17-alpine**, **3.17** - **3.17-alpine**, **3.17**
- **3.17-debian** - **3.17-debian**
- **3.16-alpine**, **3.16** - **3.16-alpine**, **3.16**
- **3.16-debian** - **3.16-debian**
### Container create example: ## Available multi-platform images:
**Alpine based**: linux/amd64, linux/386, linux/arm/v6
**Debian based**: linux/amd64
**Ubuntu based**: linux/amd64, linux/arm/v7, linux/arm64/v8
## Container create example:
1. **Create work directories:** 1. **Create work directories:**
```bash ```bash
mkdir -p /var/docker/traccar/logs mkdir -p /var/docker/traccar/logs
@ -70,14 +61,12 @@ DockerHub image: <https://hub.docker.com/r/traccar/traccar>
traccar/traccar:latest traccar/traccar:latest
``` ```
### Database ## Database
The default when executing the above `docker run` command is an internal H2 database but this should only be for basic use. The default when executing the above `docker run` command is an internal H2 database but this should only be for basic use.
The `docker run` command also doesn't create a mount point on the host for the data folder which will cause the database to be lost when the container is recreated. This point can be mitigated by adding the line `-v /var/docker/traccar/data:/opt/traccar/data:rw \` after `-v /var/docker/traccar/traccar.xml:/opt/traccar/conf/traccar.xml:ro \` but it will still be using the H2 database. The `docker run` command also doesn't create a mount point on the host for the data folder which will cause the database to be lost when the container is recreated. This point can be mitigated by adding the line `-v /var/docker/traccar/data:/opt/traccar/data:rw \` after `-v /var/docker/traccar/traccar.xml:/opt/traccar/conf/traccar.xml:ro \` but it will still be using the H2 database.
The **recommended solution** for production use is to link to an external MySQL database and update the configuration `.xml`-file according to the [Traccar MySQL documentation](https://www.traccar.org/mysql/) and using the `docker run` command as-is.
The **recommended solution** for production use is to link to an external MySQL database and update the configuration .xml file according to the [Traccar MySQL documentation](https://www.traccar.org/mysql/) and using the `docker run` command as-is. ## Default JVM options:
### Default JVM options:
- -Xms512m - -Xms512m
- -Xmx512m - -Xmx512m
- -Djava.net.preferIPv4Stack=true - -Djava.net.preferIPv4Stack=true