diff --git a/dockerfiles/ubuntu/Dockerfile b/Dockerfile similarity index 81% rename from dockerfiles/ubuntu/Dockerfile rename to Dockerfile index 1592083..69687ef 100644 --- a/dockerfiles/ubuntu/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ ARG base_image=ubuntu:latest ARG builder_image=concourse/golang-builder +FROM busybox:uclibc as busybox + FROM ${builder_image} AS builder WORKDIR /concourse/time-resource COPY go.mod . @@ -16,10 +18,10 @@ RUN set -e; for pkg in $(go list ./...); do \ done FROM ${base_image} AS resource -RUN apt update && apt upgrade -y -o Dpkg::Options::="--force-confdef" -RUN apt update && apt install -y --no-install-recommends tzdata \ - && rm -rf /var/lib/apt/lists/* +USER root COPY --from=builder /assets /opt/resource +COPY --from=busybox /bin/sh /bin/sh +COPY --from=busybox /bin/cp /bin/cp FROM resource AS tests COPY --from=builder /tests /tests diff --git a/README.md b/README.md index bc60d8f..cc13008 100644 --- a/README.md +++ b/README.md @@ -203,11 +203,10 @@ environment is consistent across any `docker` enabled platform. When the docker image builds, the test are run inside the docker container, on failure they will stop the build. -Run the tests with the following commands for both `alpine` and `ubuntu` images: +Run the tests with the following command: ```sh -docker build -t time-resource --target tests -f dockerfiles/alpine/Dockerfile . -docker build -t time-resource --target tests -f dockerfiles/ubuntu/Dockerfile . +docker build -t time-resource --target tests --build-arg base_image=paketobuildpacks/run-jammy-static:latest . ``` ### Contributing diff --git a/dockerfiles/alpine/Dockerfile b/dockerfiles/alpine/Dockerfile deleted file mode 100644 index 4f30967..0000000 --- a/dockerfiles/alpine/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -ARG base_image=alpine:latest -ARG builder_image=concourse/golang-builder - -FROM ${builder_image} as builder -WORKDIR /concourse/time-resource -COPY go.mod . -COPY go.sum . -RUN go mod download -COPY . /concourse/time-resource -ENV CGO_ENABLED 0 -RUN go build -o /assets/out github.com/concourse/time-resource/out -RUN go build -o /assets/in github.com/concourse/time-resource/in -RUN go build -o /assets/check github.com/concourse/time-resource/check -RUN set -e; for pkg in $(go list ./...); do \ - go test -o "/tests/$(basename $pkg).test" -c $pkg; \ - done - -FROM ${base_image} AS resource -RUN apk update && apk upgrade -RUN apk add --update bash tzdata -COPY --from=builder /assets /opt/resource - -FROM resource AS tests -COPY --from=builder /tests /tests -RUN set -e; for test in /tests/*.test; do \ - $test; \ - done - -FROM resource