diff --git a/Dockerfile b/Dockerfile index 53eb5a7..74b244d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM gcc:12.3 AS builder +FROM gcc:12.3 AS build RUN apt-get update && apt-get install -y \ catch2 \ cmake && \ @@ -11,7 +11,17 @@ RUN make build && \ make test && \ make package -FROM ubuntu:latest as tester -COPY --from=builder /usr/local/src/templateapp/build/ /usr/local/src/templateapp/build/ -WORKDIR /usr/local/src/templateapp/build +FROM scratch AS build-export +COPY --from=build /usr/local/src/templateapp/build/templateapp-Linux.deb / +WORKDIR / + +FROM ubuntu:latest AS test +COPY --from=build /usr/local/src/templateapp/build/tests/integration/templateapp.i.t /usr/local/bin +WORKDIR /usr/local/bin +ENTRYPOINT [ "/usr/local/bin/templateapp.i.t" ] + +FROM ubuntu:latest AS run +COPY --from=build /usr/local/src/templateapp/build/templateapp-Linux.deb /usr/local/bin +WORKDIR /usr/local/bin RUN dpkg -i templateapp-Linux.deb +ENTRYPOINT [ "/usr/bin/templateapp.sh" ] diff --git a/README.md b/README.md index 2998052..303bfc2 100644 --- a/README.md +++ b/README.md @@ -3,27 +3,24 @@ Template C/C++ application ## Build ``` -docker build [--target builder] -t templateappcpp . +docker build --target=build-export --output type=local,dest=./output . ``` ## Test ### Unit ``` -docker build [--target builder] -t templateappcpp . +docker build --target=build -t templateapp . ``` ### Integration ``` -docker build [--target tester] -t templateappcpp . -docker run -it --rm templateappcpp -> ./tests/integration/templateapp.i.t +docker build --target=test -t templateapp . +docker run -it --rm templateapp ``` ## Run ``` -docker run -it --rm templateappcpp -> cd /usr/bin -> ./templateapp.sh -> ./templateapp +docker build --target=run -t templateapp . +docker run -it --rm templateapp ```