diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index af9e9a7..edf9bc3 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -3,6 +3,8 @@ name: Build and push docker images env: DOCKERHUB_REPOSITORY: traccar/traccar + DOCKERHUB_IMAGE_TAGS: + DOCKERHUB_IMAGE_EXTEND_PLATFORMS: on: push: @@ -10,16 +12,22 @@ on: - master - v[0-9]+.[0-9]+ +defaults: + run: + shell: bash + jobs: docker-build-push: name: Build and push docker images runs-on: ubuntu-20.04 strategy: matrix: - base: [alpine, debian] + os: [alpine, debian, ubuntu] steps: - name: Checkout uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Login to Docker Hub @@ -28,27 +36,34 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - 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 - name: Set environment DOCKERHUB_IMAGE_TAGS if: github.ref != 'refs/heads/master' - shell: bash run: | _BRANCH=${GITHUB_REF##*/} _VERSION=${_BRANCH#v*} _MAJOR_VERSION=${_VERSION%.*} - _DOCKERHUB_IMAGE_TAGS="$DOCKERHUB_REPOSITORY:$_VERSION-${{ matrix.base }}" - _DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_MAJOR_VERSION-${{ matrix.base }}" - _DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:${{ matrix.base }}" - if [ "${{ matrix.base }}" == "alpine" ]; then + _DOCKERHUB_IMAGE_TAGS="$DOCKERHUB_REPOSITORY:$_VERSION-${{ matrix.os }}" + _DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_MAJOR_VERSION-${{ matrix.os }}" + _DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:${{ matrix.os }}" + if [ "${{ matrix.os }}" == "alpine" ]; then _DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_VERSION" _DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_MAJOR_VERSION" fi 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 if: env.DOCKERHUB_IMAGE_TAGS != '' uses: docker/build-push-action@v2 with: - file: ${{ matrix.base }}/Dockerfile + file: Dockerfile.${{ matrix.os }} tags: ${{ env.DOCKERHUB_IMAGE_TAGS }} + platforms: linux/amd64${{ env.DOCKERHUB_IMAGE_EXTEND_PLATFORMS }} push: true diff --git a/alpine/Dockerfile b/Dockerfile.alpine similarity index 100% rename from alpine/Dockerfile rename to Dockerfile.alpine diff --git a/debian/Dockerfile b/Dockerfile.debian similarity index 100% rename from debian/Dockerfile rename to Dockerfile.debian diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu new file mode 100644 index 0000000..9e85f7b --- /dev/null +++ b/Dockerfile.ubuntu @@ -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"] diff --git a/README.md b/README.md index f83da9f..8688044 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,36 @@ Traccar in Docker --- -Traccar GPS Tracking System in Docker image. +**Traccar GPS Tracking System in Docker image.** Official website: -DockerHub image: +DockerHub image: +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) -[![](https://images.microbadger.com/badges/image/traccar/traccar:4.11.svg)](https://microbadger.com/images/traccar/traccar:4.11) - -### Available tags: -- **4.11-alpine**, **4-alpine**, **alpine**, **4.11**, **4**, **latest** -- **4.11-debian**, **4-debian**, **debian** +## Available tags: +#### 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) +- **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-ubuntu**, **4-ubuntu**, **ubuntu** ![](https://img.shields.io/microbadger/layers/traccar/traccar/ubuntu) ![](https://img.shields.io/docker/image-size/traccar/traccar/ubuntu) - **4.10-alpine**, **4.10** - **4.10-debian** - **4.9-alpine**, **4.9** - **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-debian** +#### 3.X - **3.17-alpine**, **3.17** - **3.17-debian** - **3.16-alpine**, **3.16** - **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:** ```bash mkdir -p /var/docker/traccar/logs @@ -70,14 +61,12 @@ DockerHub image: traccar/traccar:latest ``` -### Database -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 **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. +## Database +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 **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 - -Xmx512m - -Djava.net.preferIPv4Stack=true