Add multi-platform build and ubuntu based image

pull/67/head
Maxim Zalysin 3 years ago
parent b12f5efe03
commit f3cb24540d

@ -16,10 +16,18 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
base: [alpine, debian]
platform:
- os: alpine
arch: linux/amd64,linux/386,linux/arm/v6
- os: debian
arch: linux/amd64
- os: ubuntu
arch: linux/amd64,linux/arm/v7,linux/arm64/v8
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,7 +36,7 @@ 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.platform.os == 'alpine'
run: echo "DOCKERHUB_IMAGE_TAGS=$DOCKERHUB_REPOSITORY:latest" >> $GITHUB_ENV
- name: Set environment DOCKERHUB_IMAGE_TAGS
if: github.ref != 'refs/heads/master'
@ -37,10 +45,10 @@ jobs:
_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.platform.os }}"
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_MAJOR_VERSION-${{ matrix.platform.os }}"
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:${{ matrix.platform.os }}"
if [ "${{ matrix.platform.os }}" == "alpine" ]; then
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_VERSION"
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_MAJOR_VERSION"
fi
@ -49,6 +57,7 @@ jobs:
if: env.DOCKERHUB_IMAGE_TAGS != ''
uses: docker/build-push-action@v2
with:
file: ${{ matrix.base }}/Dockerfile
file: Dockerfile.${{ matrix.platform.os }}
tags: ${{ env.DOCKERHUB_IMAGE_TAGS }}
platforms: matrix.platform.arch
push: true

@ -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"]

@ -1,45 +1,36 @@
Traccar in Docker
---
Traccar GPS Tracking System in Docker image.
**Traccar GPS Tracking System in Docker image.**
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)
[![](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: <https://hub.docker.com/r/traccar/traccar>
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

Loading…
Cancel
Save