From 6e03c95f530b2de2811d893d4bd7bd9fe583c951 Mon Sep 17 00:00:00 2001 From: JacekZubielik <119136520+JacekZubielik@users.noreply.github.com> Date: Mon, 6 May 2024 15:41:21 +0200 Subject: [PATCH 01/11] requirements --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 29a22a2..6f2abb0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,8 +32,7 @@ RUN apt get update \ # Install dependencies COPY --chown=oleduser:oleduser requirements.txt /app/ USER oleduser -RUN pip install --user --no-cache-dir numpy \ - && pip install --user --no-cache-dir -r requirements.txt +RUN install --user --no-cache-dir -r requirements.txt COPY ./app /app From 673e3557713dc85bb4e3de851af4d496ea25d647 Mon Sep 17 00:00:00 2001 From: JacekZubielik <119136520+JacekZubielik@users.noreply.github.com> Date: Mon, 6 May 2024 15:47:55 +0200 Subject: [PATCH 02/11] remove VALIDATE_DOCKERFILE_HADOLINT --- .github/workflows/lint.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2622e2a..8a2d5c7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,5 +32,4 @@ jobs: uses: github/super-linter@v6 env: VALIDATE_PYTHON: true - VALIDATE_DOCKERFILE_HADOLINT: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 3096d03add18e334c3e5e0ed4d09e95eee60549b Mon Sep 17 00:00:00 2001 From: JacekZubielik <119136520+JacekZubielik@users.noreply.github.com> Date: Mon, 6 May 2024 15:48:16 +0200 Subject: [PATCH 03/11] pip install --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6f2abb0..5c20747 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,14 +29,12 @@ RUN apt get update \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ && pip install --upgrade pip wheel -# Install dependencies COPY --chown=oleduser:oleduser requirements.txt /app/ USER oleduser -RUN install --user --no-cache-dir -r requirements.txt +RUN pip install --user --no-cache-dir -r requirements.txt COPY ./app /app -# RUN pip install -r requirements.txt --no-cache-dir CMD ["sh", "-c", "python3 -u oled4docker.py MAC=$MAC OLED=$OLED LOGFILE=$LOGFILE LOCATION=$LOCATION LMSIP=$LMSIP"] HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1 \ No newline at end of file From fe0c6e454ccb8eb118938b8c1c74306d8b0d22ae Mon Sep 17 00:00:00 2001 From: JacekZubielik <119136520+JacekZubielik@users.noreply.github.com> Date: Mon, 6 May 2024 15:59:51 +0200 Subject: [PATCH 04/11] errors when linting PYTHON_BLACK --- app/oled4docker.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/oled4docker.py b/app/oled4docker.py index 2e60fbc..43fd68d 100644 --- a/app/oled4docker.py +++ b/app/oled4docker.py @@ -47,21 +47,21 @@ from dotenv import load_dotenv load_dotenv() -print('TZ: {}'.format(environ['TZ'])) -print('PUID: {}'.format(environ['PUID'])) -print('PGID: {}'.format(environ['PGID'])) -print('OLED: {}'.format(environ['OLED'])) -print('LMSIP: {}'.format(environ['LMSIP'])) -print('MAC: {}'.format(environ['MAC'])) -print('LOGFILE: {}'.format(environ['LOGFILE'])) -print('LOCATION: {}'.format(environ['LOCATION'])) +print('TZ: {}'.format(environ["TZ"])) +print('PUID: {}'.format(environ["PUID"])) +print('PGID: {}'.format(environ["PGID"])) +print('OLED: {}'.format(environ["OLED"])) +print('LMSIP: {}'.format(environ["LMSIP"])) +print('MAC: {}'.format(environ["MAC"])) +print('LOGFILE: {}'.format(environ["LOGFILE"])) +print('LOCATION: {}'.format(environ["LOCATION"])) #==================== # Ensure all required environment variables are set try: - os.environ['LOGFILE'] + os.environ["LOGFILE"] except KeyError: - print('[error]: `$LOGFILE` environment variable required') + print('[error]: "$LOGFILE" environment variable required') sys.exit(1) File_Log_Format = "%(levelname)s %(asctime)s - %(message)s" From 30d9076f947adc5c4ca75be9138c17a465bc87a2 Mon Sep 17 00:00:00 2001 From: JacekZubielik <119136520+JacekZubielik@users.noreply.github.com> Date: Mon, 6 May 2024 16:19:29 +0200 Subject: [PATCH 05/11] Path to the requirements.txt file --- Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5c20747..ace8843 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,9 @@ LABEL org.opencontainers.image.source="https://github.com/jacekzubielik/docker-o # Prepare environment RUN mkdir /app \ - && apt get update \ - && apt get -y install curl telnet \ - && apt get clean \ + && apt-get update \ + && apt-get -y install curl telnet \ + && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ && useradd -u 1000 -G sudo -U -m -s /bin/bash oleduser \ && chown oleduser:oleduser /app \ @@ -23,13 +23,13 @@ WORKDIR /app # Install dependencies FROM base as python-deps -RUN apt get update \ - && apt get -y install build-essential \ - && apt get clean \ +RUN apt-get update \ + && apt-get -y install build-essential \ + && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ && pip install --upgrade pip wheel -COPY --chown=oleduser:oleduser requirements.txt /app/ +COPY --chown=oleduser:oleduser ./app/requirements.txt /app/ USER oleduser RUN pip install --user --no-cache-dir -r requirements.txt From ae9151768902249e0ae8eacdd919c75159c2459f Mon Sep 17 00:00:00 2001 From: JacekZubielik <119136520+JacekZubielik@users.noreply.github.com> Date: Mon, 6 May 2024 18:46:34 +0200 Subject: [PATCH 06/11] buildx-cache --- .github/workflows/release.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3fdc568..bfb5809 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -123,19 +123,19 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Docker meta + - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 with: images: | - gorabbit/docker-oled-evo-sabre - ghcr.io/jacekzubielik/docker-oled-evo-sabre + gorabbit/${{ env.IMAGE_NAME }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=schedule type=ref,event=branch type=ref,event=pr + type=ref,event=tag type=semver,pattern={{version}} -# type=sha + type=match,pattern=\d.\d.\d - name: Login to DockerHub # if: github.event_name != 'pull_request' @@ -147,7 +147,7 @@ jobs: - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ghcr.io + registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -159,9 +159,11 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - # - name: Move cache - # run: | - # rm -rf /tmp/.buildx-cache - # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache From f8438f30c7b10e55576c4823cdd12f3ab5c1b813 Mon Sep 17 00:00:00 2001 From: JacekZubielik <119136520+JacekZubielik@users.noreply.github.com> Date: Mon, 6 May 2024 19:01:29 +0200 Subject: [PATCH 07/11] Login to registry: ghcr.io --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfb5809..ddf8bd1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -147,7 +147,7 @@ jobs: - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} From 3f05addf6c2a0e967bc2d0b99e027d130d80ddc2 Mon Sep 17 00:00:00 2001 From: JacekZubielik <119136520+JacekZubielik@users.noreply.github.com> Date: Mon, 6 May 2024 19:40:31 +0200 Subject: [PATCH 08/11] Docker metadata update --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ddf8bd1..5a5c63b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -129,13 +129,13 @@ jobs: with: images: | gorabbit/${{ env.IMAGE_NAME }} - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + ghcr.io/${{ env.IMAGE_NAME }} tags: | type=ref,event=branch type=ref,event=pr type=ref,event=tag type=semver,pattern={{version}} - type=match,pattern=\d.\d.\d + # type=match,pattern=\d.\d.\d - name: Login to DockerHub # if: github.event_name != 'pull_request' From 9eae9484da306240c869d0e05a8231dcb3e8c5ec Mon Sep 17 00:00:00 2001 From: JacekZubielik <119136520+JacekZubielik@users.noreply.github.com> Date: Tue, 7 May 2024 01:29:21 +0200 Subject: [PATCH 09/11] buildx failed with: ERROR: invalid tag "***/:0.0.5": invalid reference format --- .github/workflows/release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5a5c63b..c54d968 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -90,11 +90,11 @@ jobs: run: cat Release.txt - name: Generate Changelog - run: echo "# What's Changed" > ${{ github.workspace }}-CHANGELOG.txt + run: echo "# Changelog" > ${{ github.workspace }}-CHANGELOG.txt - name: Generate release notes uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/v') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_REPOSITORY: jacekzubielik/docker-oled-evo-sabre @@ -105,7 +105,7 @@ jobs: files: | release_${{ matrix.release_suffix }} LICENCE - draft: true + draft: false prerelease: true generate_release_notes: true body_path: ${{ github.workspace }}-CHANGELOG.txt @@ -128,8 +128,8 @@ jobs: uses: docker/metadata-action@v5 with: images: | - gorabbit/${{ env.IMAGE_NAME }} - ghcr.io/${{ env.IMAGE_NAME }} + gorabbit/docker-oled-evo-sabre + ghcr.io/docker-oled-evo-sabre tags: | type=ref,event=branch type=ref,event=pr From 9ddd3e1574cb12d0f3ae2969777ded19b1ea9728 Mon Sep 17 00:00:00 2001 From: JacekZubielik <119136520+JacekZubielik@users.noreply.github.com> Date: Tue, 7 May 2024 01:38:20 +0200 Subject: [PATCH 10/11] disable buildx-cache --- .github/workflows/release.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c54d968..f053b33 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -106,7 +106,7 @@ jobs: release_${{ matrix.release_suffix }} LICENCE draft: false - prerelease: true + prerelease: false generate_release_notes: true body_path: ${{ github.workspace }}-CHANGELOG.txt @@ -159,11 +159,11 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + # - name: Move cache + # run: | + # rm -rf /tmp/.buildx-cache + # mv /tmp/.buildx-cache-new /tmp/.buildx-cache From 286b532a15142f0e8367c5faece01927ab2d4681 Mon Sep 17 00:00:00 2001 From: JacekZubielik <119136520+JacekZubielik@users.noreply.github.com> Date: Tue, 7 May 2024 02:21:18 +0200 Subject: [PATCH 11/11] Docker metadata extractor: tags --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f053b33..6f1cf8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -133,9 +133,9 @@ jobs: tags: | type=ref,event=branch type=ref,event=pr - type=ref,event=tag type=semver,pattern={{version}} # type=match,pattern=\d.\d.\d + # type=ref,event=tag - name: Login to DockerHub # if: github.event_name != 'pull_request' @@ -158,7 +158,7 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 #,linux/arm64 # cache-from: type=local,src=/tmp/.buildx-cache # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max