Update Dockerfile used in tests as well

This ensures the Dockerfile used for testing is making use of the
same scratch image to compile `libgit2` as the actual application
image.

In a future iteration we should restructure our GitHub Action
workflows to re-use the application image, saving us an additional
Dockerfile and a duplicate build. Inspiration for this (which makes
use of a local registry for the duration of the build) can be found
at: https://github.com/fluxcd/golang-with-libgit2/blob/main/.github/workflows/build.yaml

Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit is contained in:
Hidde Beydals 2021-10-07 17:53:03 +02:00 committed by pa250194
parent d04c532461
commit 610131956e
1 changed files with 23 additions and 1 deletions

View File

@ -1,4 +1,26 @@
FROM ghcr.io/fluxcd/golang-with-libgit2:1.16.8-bullseye-libgit2-1.1.1-1 as build
ARG BASE_VARIANT=bullseye
ARG GO_VERSION=1.16.8
ARG XX_VERSION=1.0.0-rc.2
ARG LIBGIT2_IMG=ghcr.io/fluxcd/golang-with-libgit2
ARG LIBGIT2_TAG=libgit2-1.1.1
FROM tonistiigi/xx:${XX_VERSION} AS xx
FROM ${LIBGIT2_IMG}:${LIBGIT2_TAG} as libgit2
FROM golang:${GO_VERSION}-${BASE_VARIANT} as gostable
# Copy the build utiltiies
COPY --from=xx / /
COPY --from=libgit2 /Makefile /libgit2/
# Install the libgit2 build dependencies
RUN make -C /libgit2 cmake
RUN make -C /libgit2 dependencies
# Compile and install libgit2
RUN FLAGS=$(xx-clang --print-cmake-defines) make -C /libgit2 libgit2
# Use the GitHub Actions uid:gid combination for proper fs permissions
RUN groupadd -g 116 test && \