Skip to content

Commit

Permalink
Fixes for dependabot and automated builds
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome committed Jun 28, 2024
1 parent cc980c9 commit 66144d0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Output Variables
id: var
run: |
echo "nginx_version=$(grep -m1 'ARG BUILD_NGINX_VERSION=' <Dockerfile | awk -F'[= ]' '{print $3}')" >> $GITHUB_OUTPUT
echo "nginx_version=$(grep -m1 'FROM nginx:' <Dockerfile | awk -F'[: ]' '{print $3}')" >> $GITHUB_OUTPUT
- name: Nginx version
run: echo "${{ steps.var.outputs.nginx_version }}"
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/system-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ jobs:
- name: Get vars
id: vars
run: |
# replace with version from Dockerfile when fixed
echo "NGINX_VERSION=1.27.0" >> $GITHUB_OUTPUT
echo "nginx_version=$(grep -m1 'FROM nginx:' <Dockerfile | awk -F'[: ]' '{print $3}')" >> $GITHUB_OUTPUT
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version-file: '.python-version'
cache: 'pip'
python-version-file: ".python-version"
cache: "pip"

- name: Install Dependencies
run: pip install -r test/requirements.ci.txt
Expand All @@ -54,7 +53,7 @@ jobs:
cache-from: type=gha,scope=system-nginx
cache-to: type=gha,scope=system-nginx,mode=max
build-args: |
NGINX_VERSION=${{ steps.vars.outputs.NGINX_VERSION }}
NGINX_VERSION=${{ steps.vars.outputs.nginx_version }}
- name: Build backend
uses: docker/build-push-action@v6
Expand Down
20 changes: 8 additions & 12 deletions .github/workflows/update-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@ name: Update Docker Images

on:
schedule:
- cron: '0 1 * * *'
- cron: "0 1 * * *"
workflow_dispatch:

defaults:
run:
shell: bash

jobs:

variables:
name: Get version of base image
runs-on: ubuntu-20.04
outputs:
versions: ${{ steps.version.outputs.matrix }}
git_tag: ${{ steps.tag.outputs.git_tag }}
docker_platforms: ${{ steps.vars.outputs.docker_platforms }}
sha_long: ${{ steps.vars.outputs.sha_long }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -28,7 +26,7 @@ jobs:
id: tag
run: |
tag=$(git tag --sort=-version:refname | head -n1)
echo "::set-output name=git_tag::${tag//v}"
echo "git_tag=${tag//v}" >> $GITHUB_OUTPUT
- name: Checkout Repository at ${{ steps.tag.outputs.git_tag }}
uses: actions/checkout@v4
with:
Expand All @@ -38,12 +36,11 @@ jobs:
run: |
nginx_alpine=library/nginx:$(grep -m1 "FROM.*nginx.*alpine" <Dockerfile | awk -F"[ :]" '{print $3}')
nginx=library/$(grep -m1 "FROM nginx:" < Dockerfile | awk -F" " '{print $2}')
echo "::set-output name=matrix::[{\"version\": \"${nginx}\", \"distro\": \"debian\"}, {\"version\": \"${nginx_alpine}\", \"distro\": \"alpine\"}]"
echo "matrix=[{\"version\": \"${nginx}\", \"distro\": \"debian\"}, {\"version\": \"${nginx_alpine}\", \"distro\": \"alpine\"}]" >> $GITHUB_OUTPUT
- name: Set other variables
id: vars
run: |
echo "::set-output name=docker_platforms::$(grep "PLATFORMS:" .github/workflows/docker.yml | awk -F" " '{print $2}')"
echo "::set-output name=sha_long::$(git rev-parse HEAD)"
echo "docker_platforms=$(grep "PLATFORMS:" .github/workflows/docker.yml | awk -F" " '{print $2}')" >> $GITHUB_OUTPUT
check:
name: Check if updates are needed
Expand All @@ -60,7 +57,7 @@ jobs:
id: dist
run: |
if [ ${{ matrix.base_image.distro }} == "debian" ]; then dist=""; else dist="-${{ matrix.base_image.distro }}"; fi
echo "::set-output name=tag::${{ needs.variables.outputs.git_tag }}${dist}"
echo "tag=${{ needs.variables.outputs.git_tag }}${dist}" >> $GITHUB_OUTPUT
- name: Check if update available ${{ matrix.base_image.version }}
id: update
uses: lucacome/docker-image-update-checker@v1
Expand All @@ -69,7 +66,7 @@ jobs:
image: opentracing/nginx-opentracing:${{ steps.dist.outputs.tag }}
- id: var
run: |
echo "::set-output name=${{ matrix.base_image.distro }}::${{ steps.update.outputs.needs-updating }}"
echo "${{ matrix.base_image.distro }}=${{ steps.update.outputs.needs-updating }}" >> $GITHUB_OUTPUT
build-docker:
if: ${{ needs.check.outputs.needs-updating-debian == 'true' || needs.check.outputs.needs-updating-alpine == 'true' }}
Expand All @@ -93,7 +90,7 @@ jobs:
- name: Output Variables
id: var
run: |
echo "::set-output name=nginx_version::$(grep -m1 'FROM nginx:' <Dockerfile | awk -F'[: ]' '{print $3}')"
echo "nginx_version=$(grep -m1 'FROM nginx:' <Dockerfile | awk -F'[: ]' '{print $3}')" >> $GITHUB_OUTPUT
if: ${{ matrix.needs-updating == 'true' }}

- name: Setup QEMU
Expand Down Expand Up @@ -123,6 +120,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
context: git
images: |
opentracing/nginx-opentracing
ghcr.io/opentracing-contrib/nginx-opentracing
Expand All @@ -132,8 +130,6 @@ jobs:
tags: |
type=raw,value=${{ needs.variables.outputs.git_tag }}
type=raw,value=nginx-${{ steps.var.outputs.nginx_version }}
labels: |
org.opencontainers.image.revision=${{ needs.variables.outputs.sha_long }}
if: ${{ matrix.needs-updating == 'true' }}

- name: Build and push
Expand Down
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# syntax=docker/dockerfile:1.3
# syntax=docker/dockerfile:1.8
ARG BUILD_OS=debian
ARG BUILD_NGINX_VERSION=1.27.0
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.4.0 AS xx

### Build base image for debian
FROM --platform=$BUILDPLATFORM debian:bullseye as build-base-debian
FROM --platform=$BUILDPLATFORM debian:12 as build-base-debian

RUN apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
Expand Down Expand Up @@ -202,9 +201,10 @@ RUN xx-info env && git clone --depth 1 -b $DATADOG_VERSION https://github.com/Da


### Base build image for debian
FROM nginx:${BUILD_NGINX_VERSION}-bookworm as build-nginx-debian
FROM nginx:1.27.0 as build-nginx-debian

RUN echo "deb-src [signed-by=/etc/apt/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/mainline/debian/ bookworm nginx" >> /etc/apt/sources.list.d/nginx.list \
RUN DEBIAN_VERSION=$(awk -F '=' '/^VERSION_CODENAME=/ {print $2}' /etc/os-release) \
&& echo "deb-src [signed-by=/etc/apt/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/mainline/debian/ ${DEBIAN_VERSION} nginx" >> /etc/apt/sources.list.d/nginx.list \
&& apt-get update \
&& apt-get build-dep -y nginx

Expand Down Expand Up @@ -237,12 +237,12 @@ RUN curl -fsSL -O https://github.com/nginx/nginx/archive/release-${NGINX_VERSION


### Base image for alpine
FROM nginx:${BUILD_NGINX_VERSION}-alpine as nginx-alpine
FROM nginx:1.27.0-alpine as nginx-alpine
RUN apk add --no-cache libstdc++


### Base image for debian
FROM nginx:${BUILD_NGINX_VERSION}-bookworm as nginx-debian
FROM nginx:1.27.0 as nginx-debian


### Build final image
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NGINX_VERSION=1.27.0
NGINX_VERSION=$(shell grep -m1 'FROM nginx:' <Dockerfile | awk -F'[: ]' '{print $$3}')

.PHONY: docker-image
docker-image:
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:stable as base
FROM debian:12 AS base

RUN apt-get update && \
apt-get install --no-install-recommends --no-install-suggests -y \
Expand Down

0 comments on commit 66144d0

Please sign in to comment.