From 3cb770274c3c3f5c1928b13584f540b3d91a4626 Mon Sep 17 00:00:00 2001 From: Roger Sikorski Date: Tue, 22 Aug 2023 17:35:00 +0200 Subject: [PATCH 1/4] hadolint, k3s and kaniko build added --- .gitea/workflows/dev.yaml | 37 ++++++++++++++++++++----------------- .gitea/workflows/main.yaml | 37 ++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/.gitea/workflows/dev.yaml b/.gitea/workflows/dev.yaml index 0f15f72..8136603 100644 --- a/.gitea/workflows/dev.yaml +++ b/.gitea/workflows/dev.yaml @@ -6,22 +6,25 @@ on: - main jobs: - build: - runs-on: docker + Dockerfile lint: + runs-on: k3s steps: - uses: actions/checkout@v3 - - name: docker login - run: docker login -u $REGISTRY_USER -p $REGISTRY_PASSWORD gitea.sikorski.cloud - env: - REGISTRY_USER: ${{ secrets.REGISTRY_USER }} - REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} - - name: Pull Docker Image for caching - run: docker pull gitea.sikorski.cloud/rogersik/devops-helper:development || exit 0 - - name: Build docker image - run: | - docker build . \ - --cache-from gitea.sikorski.cloud/rogersik/devops-helper:development \ - --file Dockerfile \ - --tag gitea.sikorski.cloud/rogersik/devops-helper:development - - name: Push docker image - run: docker push gitea.sikorski.cloud/rogersik/devops-helper --all-tags + - uses: hadolint/hadolint-action@v3.1.0 + with: + dockerfile: Dockerfile + + build: + runs-on: k3s + needs: Dockerfile lint + steps: + - uses: actions/checkout@v3 + - name: Kaniko build + uses: aevea/action-kaniko@master + with: + image: rogersik/devops-helper + registry: gitea.sikorski.cloud + tag: development + cache: true + username: rogersik + password: ${{ secrets.REGISTRY_PASSWORD }} diff --git a/.gitea/workflows/main.yaml b/.gitea/workflows/main.yaml index 3d388c1..e8ca6f3 100644 --- a/.gitea/workflows/main.yaml +++ b/.gitea/workflows/main.yaml @@ -7,22 +7,25 @@ on: - cron: "0 6 * * SUN" jobs: - build: - runs-on: docker + Dockerfile lint: + runs-on: k3s steps: - uses: actions/checkout@v3 - - name: docker login - run: docker login -u $REGISTRY_USER -p $REGISTRY_PASSWORD gitea.sikorski.cloud - env: - REGISTRY_USER: ${{ secrets.REGISTRY_USER }} - REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} - - name: Pull Docker Image for caching - run: docker pull gitea.sikorski.cloud/rogersik/devops-helper:development || exit 0 - - name: Build docker image - run: | - docker build . \ - --cache-from gitea.sikorski.cloud/rogersik/devops-helper:development \ - --file Dockerfile \ - --tag gitea.sikorski.cloud/rogersik/devops-helper:latest - - name: Push docker image - run: docker push gitea.sikorski.cloud/rogersik/devops-helper --all-tags + - uses: hadolint/hadolint-action@v3.1.0 + with: + dockerfile: Dockerfile + + build: + runs-on: k3s + needs: Dockerfile lint + steps: + - uses: actions/checkout@v3 + - name: Kaniko build + uses: aevea/action-kaniko@master + with: + image: rogersik/devops-helper + registry: gitea.sikorski.cloud + tag: latest + cache: true + username: rogersik + password: ${{ secrets.REGISTRY_PASSWORD }} -- 2.45.2 From 64e5258626f468ba6f29ab512cb862fa9e27e205 Mon Sep 17 00:00:00 2001 From: Roger Sikorski Date: Tue, 22 Aug 2023 17:35:45 +0200 Subject: [PATCH 2/4] .hadolint.yaml rules added --- .hadolint.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .hadolint.yaml diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 0000000..2cecf68 --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,3 @@ +ignored: + - DL3013 # https://github.com/hadolint/hadolint/wiki/DL3013 allow install latest package + - DL3018 # https://github.com/hadolint/hadolint/wiki/DL3018 no need to pin specific version -- 2.45.2 From c24bbbc6b97c250fad773e32c3d23d4febeb7180 Mon Sep 17 00:00:00 2001 From: Roger Sikorski Date: Tue, 22 Aug 2023 17:35:58 +0200 Subject: [PATCH 3/4] Dockerfile use COPY instead ADD --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c26cac5..b433128 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,4 @@ FROM alpine:latest RUN apk update && \ apk add --no-cache nano mc micro rsync ncdu git curl -ADD ./bin/ /usr/local/bin +COPY ./bin/ /usr/local/bin -- 2.45.2 From 4f1c64d87cf12c1aaa3f15a62b2688e9a7dc38e9 Mon Sep 17 00:00:00 2001 From: Roger Sikorski Date: Tue, 22 Aug 2023 17:36:41 +0200 Subject: [PATCH 4/4] Dokerfile: use alpine 3.18 instead latest --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b433128..7d31d4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # https://hub.docker.com/_/alpine -FROM alpine:latest +FROM alpine:3.18 RUN apk update && \ apk add --no-cache nano mc micro rsync ncdu git curl -- 2.45.2