From cc6ab99e060a5ebbdbe470a0d76cc0a79b4e30cf Mon Sep 17 00:00:00 2001 From: 10 <2408212-10@users.noreply.gitlab.com> Date: Tue, 26 Jan 2021 00:16:42 +0100 Subject: [PATCH 1/4] added pushrm --- .gitlab-ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bd8219d..1cf7a8e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,6 @@ stages: - build:docker + - push:readme variables: IMAGE_NAME_DOCKERHUB: "index.docker.io/bruceforce/bw_backup" @@ -62,3 +63,11 @@ build: except: - master +push_readme: + stage: push:readme + image: chko/docker-pushrm + variables: + - DOCKER_USER: $DOCKERHUB_USER + - DOCKER_PASS: $DOCKERHUB_PASSWORD + - PUSHRM_TARGET: $IMAGE_NAME_DOCKERHUB + From 3740275b2d6639fce0d36c9bcf296457b3094a52 Mon Sep 17 00:00:00 2001 From: 10 <2408212-10@users.noreply.gitlab.com> Date: Tue, 26 Jan 2021 02:15:31 +0100 Subject: [PATCH 2/4] Added pushrm to pipeline --- .gitlab-ci.yml | 70 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1cf7a8e..7b5c16c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,16 @@ stages: - - build:docker - push:readme + - build:docker + +workflow: + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' + - if: $CI_COMMIT_TAG variables: - IMAGE_NAME_DOCKERHUB: "index.docker.io/bruceforce/bw_backup" + DOCKERHUB_REGISTRY: index.docker.io + DOCKERHUB_REPO: bw_backup + IMAGE_NAME_DOCKERHUB: $DOCKERHUB_REGISTRY/$DOCKERHUB_USER/$DOCKERHUB_REPO" # see https://gitlab.com/gitlab-org/gitlab-runner/issues/4501 DOCKER_DRIVER: overlay2 DOCKER_TLS_CERTDIR: "/certs" @@ -35,39 +42,58 @@ variables: - docker buildx create --use my-context - docker info +push_readme: + stage: push:readme + image: docker:latest + services: + - docker:dind + tags: + - shared + script: + - docker run + -v $(pwd)/README.md:/data/README.md:ro + -e DOCKER_USER=$DOCKERHUB_USER + -e DOCKER_PASS=$DOCKERHUB_PASSWORD + -e PUSHRM_FILE=/data/README.md + -e PUSHRM_TARGET=docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO + chko/docker-pushrm + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + changes: + - README.md + build_master: <<: *docker_build script: - *docker_login - *dockerhub_login #- docker build --pull -t "$IMAGE_NAME" -t "$IMAGE_NAME_DOCKERHUB:${CI_COMMIT_TAG:-latest}" . - - docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t "$CI_REGISTRY_IMAGE:${CI_COMMIT_TAG:-latest}" -t "$IMAGE_NAME_DOCKERHUB:${CI_COMMIT_TAG:-latest}" . + - docker buildx build + --push + --platform linux/arm/v7,linux/arm64/v8,linux/amd64 + --tag "$CI_REGISTRY_IMAGE:${CI_COMMIT_TAG:-latest}" + --tag "$IMAGE_NAME_DOCKERHUB:${CI_COMMIT_TAG:-latest}" . #- docker push "$IMAGE_NAME" #- docker push "$IMAGE_NAME_DOCKERHUB:${CI_COMMIT_TAG:-latest}" - only: - refs: - - master - - tags - changes: - - Dockerfile - - backup.sh - - entrypoint.sh + rules: + - if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_TAG' + changes: + - Dockerfile + - backup.sh + - entrypoint.sh build: <<: *docker_build script: - *docker_login #- docker build --pull -t "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/bw_backup:${CI_COMMIT_TAG:-latest}" . - - docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" . + - docker buildx build + --push + --platform linux/arm/v7,linux/arm64/v8,linux/amd64 + --tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" . #- docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/bw_backup:${CI_COMMIT_TAG:-latest}" - except: - - master - -push_readme: - stage: push:readme - image: chko/docker-pushrm - variables: - - DOCKER_USER: $DOCKERHUB_USER - - DOCKER_PASS: $DOCKERHUB_PASSWORD - - PUSHRM_TARGET: $IMAGE_NAME_DOCKERHUB + rules: + - if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_TAG' + when: never + - when: on_success From 266224758b9e873a552ad47426c3b799c4150af0 Mon Sep 17 00:00:00 2001 From: 10 <2408212-10@users.noreply.gitlab.com> Date: Tue, 26 Jan 2021 02:55:33 +0100 Subject: [PATCH 3/4] Fixed typo in pipeline --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7b5c16c..a4125ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ workflow: variables: DOCKERHUB_REGISTRY: index.docker.io DOCKERHUB_REPO: bw_backup - IMAGE_NAME_DOCKERHUB: $DOCKERHUB_REGISTRY/$DOCKERHUB_USER/$DOCKERHUB_REPO" + IMAGE_NAME_DOCKERHUB: $DOCKERHUB_REGISTRY/$DOCKERHUB_USER/$DOCKERHUB_REPO # see https://gitlab.com/gitlab-org/gitlab-runner/issues/4501 DOCKER_DRIVER: overlay2 DOCKER_TLS_CERTDIR: "/certs" From 7154aafd2fdec45ac3c7d19623ead690d6e35467 Mon Sep 17 00:00:00 2001 From: 1O <2408212-1O@users.noreply.gitlab.com> Date: Mon, 15 Feb 2021 11:01:34 +0100 Subject: [PATCH 4/4] Added hint for ARM datetime problems --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7826832..4ba8763 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,9 @@ Note that sqlite3 creates a lock file in the source directory while running the So source *AND* destination have to be +rw for the user. You can set the user and group ID via the `UID` and `GID` environment variables like described above. -### Wrong timestamp +### Date Time issues / Wrong timestamp If you need timestamps in your local timezone you should mount `/etc/timezone:/etc/timezone:ro` and `/etc/localtime:/etc/localtime:ro` like it's done in the [docker-compose.yml](docker-compose.yml). An other possible solution is to set the environment variable accordingly (like `TZ=Europe/Berlin`) (see for more information). + +**Attention** if you are on an ARM based platform please note that [alpine](https://alpinelinux.org/) is used as base image for this project to keep things small. Since alpine 3.13 and above it's possible that you will end up with a container with broken time and date settings (i.e. year 1900). This is a known problem in the alpine project (see [Github issue](https://github.com/alpinelinux/docker-alpine/issues/141) and [solution](https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.13.0#time64_requirements)) and there is nothing I can do about it. However in the [alpine wiki](https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.13.0#time64_requirements) a solution is being proposed which I also tested tested on my raspberry pi. After following the described process it started working again as expected. If you still experience issues or could for some reason not apply the aforementioned fixes please feel free to open an issue. \ No newline at end of file