From 263eb293b7d27ea1afde6796b8775d6109ed3f31 Mon Sep 17 00:00:00 2001 From: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> Date: Fri, 28 Feb 2020 15:51:10 -0600 Subject: [PATCH] Move Dockerfile to conformance directory In order to prevent confusion about the purpose of the Dockerfile, move it into conformance directory where it is more appropriate. Also remove dependency on Makefile, and instead using build args to pass along the test version that is visible in report.html. Resolves #99. Signed-off-by: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> --- action.yml | 2 +- Dockerfile => conformance/Dockerfile | 11 +++++------ conformance/README.md | 9 +++++---- 3 files changed, 11 insertions(+), 11 deletions(-) rename Dockerfile => conformance/Dockerfile (55%) diff --git a/action.yml b/action.yml index 36abbeae..8ca9c3cc 100644 --- a/action.yml +++ b/action.yml @@ -8,4 +8,4 @@ inputs: {} outputs: {} runs: using: docker - image: Dockerfile + image: conformance/Dockerfile diff --git a/Dockerfile b/conformance/Dockerfile similarity index 55% rename from Dockerfile rename to conformance/Dockerfile index 89e2932b..74656f98 100644 --- a/Dockerfile +++ b/conformance/Dockerfile @@ -1,14 +1,13 @@ -# Note: this Dockerfile is used for running conformance tests - # --- # Stage 1: Install certs and build conformance binary # --- FROM docker.io/golang:1.13.6-alpine3.11 AS builder -RUN apk --update add git make ca-certificates && \ - mkdir -p /go/src/github.com/opencontainers/distribution-spec -WORKDIR /go/src/github.com/opencontainers/distribution-spec +ARG VERSION=unknown +ARG GO_PKG=github.com/opencontainers/distribution-spec/conformance +RUN apk --update add git make ca-certificates && mkdir -p /go/src/${GO_PKG} +WORKDIR /go/src/${GO_PKG} ADD . . -RUN make conformance-binary && mv output/conformance.test /conformance.test +RUN CGO_ENABLED=0 go test -c -o /conformance.test --ldflags="-X ${GO_PKG}.Version=${VERSION}" # --- # Stage 2: Final image with nothing but certs & binary diff --git a/conformance/README.md b/conformance/README.md index 4fa2c22b..58946eeb 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -33,13 +33,14 @@ Note: for some registries, you may need to create `OCI_NAMESPACE` ahead of time. #### Container Image -You may use [Dockerfile](./../Dockerfile) located at the -root of this repo to build a container image that contains the test binary. +You may use the [Dockerfile](./Dockerfile) located in this directory +to build a container image that contains the test binary. Example (using `docker`): ``` -# build the image -(cd ../ && docker build -t conformance:latest -f Dockerfile .) +# build the image, using git SHA as the version +docker build -t conformance:latest \ + --build-arg VERSION=$(git log --format="%H" -n 1) . # run the image docker run --rm \