Skip to content

Commit

Permalink
Containerize the pict tool (#114)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrej Podhradsky <apodhrad@redhat.com>
  • Loading branch information
apodhrad authored Nov 6, 2023
1 parent b062e26 commit a3d373b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ____ _ _ _
# | __ ) _ _(_) | __| | ___ _ __
# | _ \| | | | | |/ _` |/ _ \ '__|
# | |_) | |_| | | | (_| | __/ |
# |____/ \__,_|_|_|\__,_|\___|_|
#
FROM registry.access.redhat.com/ubi9/toolbox:9.2 as builder

# This will be used in ubi-micro
RUN dnf --installroot=/tmp/ubi-micro \
--nodocs --setopt=install_weak_deps=False \
install -y \
g++ shadow-utils && \
dnf --installroot=/tmp/ubi-micro \
clean all

# This is needed to build pict
RUN dnf install -y cmake g++ && \
mkdir /tmp/pict

# Copy repo resources
COPY ./ /tmp/pict/

# Build the pict
RUN cd /tmp/pict/ && \
rm -rf build && \
cmake -DCMAKE_BUILD_TYPE=Release -S . -B build && \
cmake --build build && \
cp build/cli/pict /tmp/ubi-micro/usr/local/bin/

# __ __ _
# | \/ | __ _(_)_ __
# | |\/| |/ _` | | '_ \
# | | | | (_| | | | | |
# |_| |_|\__,_|_|_| |_|
#
FROM registry.access.redhat.com/ubi9/ubi-micro:9.2

COPY --from=builder /tmp/ubi-micro/ /

VOLUME /var/pict

WORKDIR /var/pict

RUN useradd -M pict

USER pict

ENTRYPOINT ["pict"]
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ OBJS_CLI = cli/ccommon.o cli/cmdline.o
OBJS_CLI += cli/common.o cli/cparser.o cli/ctokenizer.o cli/gcd.o
OBJS_CLI += cli/gcdexcl.o cli/gcdmodel.o cli/model.o cli/mparser.o
OBJS_CLI += cli/pict.o cli/strings.o
IMAGE := pict:latest

pict: $(OBJS)
$(CXX) $(OBJS) -o $(TARGET)
Expand All @@ -35,3 +36,9 @@ source: clean
git archive --prefix="pict-$(COMMIT)/" -o "pict-$(SHORT_COMMIT).tar.gz" $(COMMIT)

.PHONY: all test clean source

image-build:
@podman build --layers=true -t $(IMAGE) .

image-run:
@podman run -it --rm -v ./doc/sample-models:/var/pict:Z $(IMAGE) create_volume.txt
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,18 @@ Assuming installation of CMake and C++ toolchain, following set of commands will
## Debugging

Most commonly, you will want to debug the command-line tool. Start in the **pictcli** project, **cli/pict.cpp** file. You'll find **wmain** routine there which would be a convenient place to put the very first breakpoint.

## PICT as a container

To build a container image with PICT, just execute

make image-build

Once built, you can run it with a sample model as follows

make image-run

To use your own models, please execute

podman run -it --rm -v ./<local-dir>:/var/pict:Z pict:latest <your-model-file> [<pict-options>]

0 comments on commit a3d373b

Please sign in to comment.