Last active
August 6, 2019 22:30
-
-
Save sapk/ce1c246dd39a5f434554b31d0ca8ecdb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM gitea/gitea | |
RUN apk --no-cache add git qt5-qtbase qt5-qtmultimedia libstdc++ build-base bison cmake libx11-dev mesa-dev libxmu-dev libxi-dev glew-dev freeglut-dev glib-dev glib glu glu-dev gettext gettext-dev gettext-libs | |
WORKDIR / | |
RUN git clone --depth=5 git://github.com/openscad/openscad.git | |
WORKDIR /openscad | |
RUN git submodule update --init | |
RUN ls -lah /usr/bin/cc | |
RUN source ./scripts/setenv-unibuild.sh \ | |
&& ./scripts/uni-build-dependencies.sh \ | |
&& ./scripts/check-dependencies.sh | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Parsing inputs | |
file_name=$(basename "$GITEA_PREFIX_RAW") | |
input_file="$1" | |
#Defining temp files | |
tmpfile=$(mktemp /tmp/generate_scad.XXXXXX.png) | |
tmpfile_scad=$(mktemp /tmp/generate_scad.XXXXXX.scad) | |
#Detect filetype | |
if [ ${GITEA_PREFIX_RAW: -4} == ".stl" ]; then | |
# Generate a scad file containing | |
echo "import(\"$1\", convexity=30);" >> "$tmpfile_scad" | |
input_file="$tmpfile_scad" | |
fi | |
#Rendering PNG | |
openscad -q -o "$tmpfile" --autocenter --imgsize 512,512 --viewall --view wireframe --colorscheme Nature "$input_file" | |
#Rendering HTML | |
echo "<img src='data:image/png;base64,$(base64 -w 0 $tmpfile)' alt='$file_name'/>" | |
#Cleaning | |
rm "$tmpfile" "$tmpfile_scad" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment