From 3aafcfc3ef68c6b4dcdc1242f98b80ee13f5c278 Mon Sep 17 00:00:00 2001 From: Jeremy Wright Date: Fri, 8 Oct 2021 22:50:48 -0400 Subject: [PATCH] Switched to Anaconda --- app/api/src/docker/cadquery/Dockerfile | 46 +++++++++++++++++++++++--- app/api/src/docker/cadquery/runCQ.ts | 30 ++++++++--------- 2 files changed, 56 insertions(+), 20 deletions(-) diff --git a/app/api/src/docker/cadquery/Dockerfile b/app/api/src/docker/cadquery/Dockerfile index de41ca7..3ecbab2 100644 --- a/app/api/src/docker/cadquery/Dockerfile +++ b/app/api/src/docker/cadquery/Dockerfile @@ -1,5 +1,6 @@ FROM public.ecr.aws/lts/ubuntu:20.04_stable - +ENV PATH="/root/miniconda3/bin:${PATH}" +ARG PATH="/root/miniconda3/bin:${PATH}" ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update --fix-missing -qq @@ -21,7 +22,9 @@ RUN apt-get update && \ cmake \ unzip \ automake autoconf libtool \ - libcurl4-openssl-dev + libcurl4-openssl-dev \ + curl \ + git # Add the lambda emulator for local dev, (see entrypoint.sh for where it's used), # I have the file locally (gitignored) to speed up build times (as it downloads everytime), @@ -35,15 +38,48 @@ COPY package*.json /var/task/ RUN npm install RUN npm install aws-lambda-ric@1.0.0 +# Install Miniconda and install CadQuery +# RUN curl -sL https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > miniconda.sh +# RUN bash miniconda.sh -b -p $HOME/miniconda; +# RUN export PATH="$HOME/miniconda/bin:$HOME/miniconda/lib:$PATH"; +# RUN . $HOME/miniconda/bin/activate;\ +# conda activate base;\ +# conda config --set always_yes yes --set changeps1 no;\ +# conda update -q conda;\ +# conda install -c cadquery -c conda-forge cadquery=master ocp=7.5.2 python=3.8;\ +# conda info + +RUN wget \ + https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \ + && bash Miniconda3-latest-Linux-x86_64.sh -b \ + && rm -f Miniconda3-latest-Linux-x86_64.sh +RUN conda --version + +# RUN curl -sL https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > miniconda.sh +# RUN bash miniconda.sh -b && \ +# echo "export PATH="/root/miniconda3/bin:$PATH"" >> ~/.bashrc && \ +# /bin/bash -c "source ~/.bashrc" +# RUN ls /root/ +# ENV PATH /root/miniconda3/bin:$PATH +# RUN conda update --all +# RUN conda info + +# Install CadQuery +# RUN conda activate base +RUN conda install -c cadquery -c conda-forge cadquery=master ocp=7.5.2 python=3.8 +RUN conda info + +# Get a copy of cq-cli from GitHub +RUN git clone https://github.com/CadQuery/cq-cli.git # Get the distribution copy of cq-cli RUN apt-get install -y libglew2.1 # RUN wget https://github.com/CadQuery/cq-cli/releases/download/v2.2-beta.2/cq-cli-Linux-x86_64.zip # More cutting edge release -RUN wget http://7bindustries.com/static/downloads/cq-cli-Linux-x86_64.zip -RUN unzip cq-cli-Linux-x86_64.zip +# RUN wget http://7bindustries.com/static/downloads/cq-cli-Linux-x86_64.zip +# RUN unzip cq-cli-Linux-x86_64.zip -RUN chmod +x cq-cli/cq-cli +#RUN chmod +x cq-cli/cq-cli RUN echo "cadhub-concat-split" > /var/task/cadhub-concat-split # using built javascript from dist diff --git a/app/api/src/docker/cadquery/runCQ.ts b/app/api/src/docker/cadquery/runCQ.ts index f3ad84a..99e9af2 100644 --- a/app/api/src/docker/cadquery/runCQ.ts +++ b/app/api/src/docker/cadquery/runCQ.ts @@ -12,35 +12,35 @@ export const runCQ = async ({ ) const fullPath = `/tmp/${tempFile}/output.gz` const stlPath = `/tmp/${tempFile}/output.stl` - // const customizerPath = `/tmp/${tempFile}/customizer.param` + const customizerPath = `/tmp/${tempFile}/customizer.param` const command = [ - `cq-cli/cq-cli`, + `./cq-cli/cq-cli.py`, `--codec stl`, `--infile /tmp/${tempFile}/main.py`, `--outfile ${stlPath}`, `--outputopts "deflection:${deflection};angularDeflection:${deflection};"`, - // `--params ${customizerPath}`, + `--params ${customizerPath}`, ].join(' ') - // const command2 = [ - // `cq-cli/cq-cli`, - // `--getparams true`, - // `--infile /tmp/${tempFile}/main.py`, - // `--outfile ${customizerPath}`, - // ] + const command2 = [ + `cq-cli/cq-cli`, + `--getparams true`, + `--infile /tmp/${tempFile}/main.py`, + `--outfile ${customizerPath}`, + ] console.log('command', command) let consoleMessage = '' try { consoleMessage = await runCommand(command, 30000) - // const consoleMessage2 = await runCommand(command2, 30000) - // const params = JSON.parse( - // await readFile(customizerPath, { encoding: 'ascii'}) - // ) - // console.log('params', params) + const consoleMessage2 = await runCommand(command2, 30000) + const params = JSON.parse( + await readFile(customizerPath, { encoding: 'ascii'}) + ) + console.log('params', params) await writeFiles( [ { file: JSON.stringify({ - // customizerParams: params, + customizerParams: params, consoleMessage, type: 'stl', }),