From c2a6e00960c8a17313bcdbcd2640293c2995d9d2 Mon Sep 17 00:00:00 2001 From: Alejandro Drabenche Date: Tue, 3 May 2022 17:13:30 -0300 Subject: [PATCH] Build Docker image choosing oura version. --- testdrive/ourabyversion/Dockerfile | 21 ++++++++++++++++ testdrive/ourabyversion/README.md | 39 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 testdrive/ourabyversion/Dockerfile create mode 100644 testdrive/ourabyversion/README.md diff --git a/testdrive/ourabyversion/Dockerfile b/testdrive/ourabyversion/Dockerfile new file mode 100644 index 00000000..7f641b54 --- /dev/null +++ b/testdrive/ourabyversion/Dockerfile @@ -0,0 +1,21 @@ +FROM --platform=linux/amd64 rust:1-buster as builder + +ARG RELEASE_TAG + +RUN git config --global init.defaultBranch main && \ + git config --global advice.detachedHead false && \ + git init && \ + git remote add origin https://github.com/txpipe/oura.git && \ + git fetch && \ + test -z ${RELEASE_TAG} && GITREV=$(git describe --tags $(git rev-list --tags --max-count=1)) || GITREV=${RELEASE_TAG} && \ + git checkout "${GITREV}" + +RUN cargo build --release --target x86_64-unknown-linux-gnu --all-features && \ + cp /target/x86_64-unknown-linux-gnu/release/oura /oura + +# Run app +FROM debian:buster-slim + +COPY --from=builder /oura /usr/local/bin/oura + +ENTRYPOINT [ "oura" ] diff --git a/testdrive/ourabyversion/README.md b/testdrive/ourabyversion/README.md new file mode 100644 index 00000000..3b17acb9 --- /dev/null +++ b/testdrive/ourabyversion/README.md @@ -0,0 +1,39 @@ +# Build Oura by version + +## Introduction + +This is a reference implementation to show how an image of _Oura_ can be built on demand; but also, sending the git revision as an argument through the command line + +## Prerequisites + +- Docker + +## Variables and arguments + +|Build Argument|Type|Default|Required|What it is| +|---|---|---|---|---| +|`RELEASE_TAG`|ARG|Last workin version|no|Tag number of the oura release. Follow this [link](https://github.com/txpipe/oura/tags) for reference.| + + +### Build a Docker images with the latest Oura release +```bash +$ sudo docker build -t oura:latest . +``` +```bash +$ sudo docker run --rm oura:latest --version +``` +```bash +oura 1.3.2 +``` + +### Build a Docker image of Oura v1.0.0 +```bash +$ sudo docker build -t oura:v1.0.0 . \ +--build-arg RELEASE_TAG=v1.0.0 +``` +```bash +$ sudo docker run --rm oura:v1.0.0.0 --version +``` +```bash +oura 1.0.0 +``` \ No newline at end of file