Use release package instead to avoid conda permission issues

conda permission issue would arise only when deployed. Side stepped this
issue by using the release package instead.

Also cleaned up the docker file. Still need to remove duplication
between openscad and cadquery apis
This commit is contained in:
Kurt Hutten
2021-04-23 07:41:55 +10:00
parent 35d5c02f96
commit 9cf02980cc
4 changed files with 16 additions and 78 deletions

View File

@@ -2,15 +2,10 @@ FROM public.ecr.aws/lts/ubuntu:20.04_stable
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
## install things needed to run openscad (xvfb is an important one)
RUN apt-get update -qq RUN apt-get update -qq
# double check this below, I'm not sure we need inkscape etc RUN apt-get -y -qq install software-properties-common dirmngr apt-transport-https lsb-release ca-certificates xvfb
RUN apt-get -y -qq install software-properties-common dirmngr apt-transport-https lsb-release ca-certificates xvfb imagemagick unzip inkscape
RUN apt-get update -qq RUN apt-get update -qq
# RUN apt-get install -y -qq openscad
# RUN apt-get install -y curl
RUN apt-get install -y wget RUN apt-get install -y wget
RUN apt-get install -y git
# install node14, see comment at the to of node14source_setup.sh # install node14, see comment at the to of node14source_setup.sh
ADD node14source_setup.sh /nodesource_setup.sh ADD node14source_setup.sh /nodesource_setup.sh
@@ -20,13 +15,13 @@ RUN apt-get install -y nodejs
# Install aws-lambda-cpp build dependencies, this is for the post install script in aws-lambda-ric (in package.json) # Install aws-lambda-cpp build dependencies, this is for the post install script in aws-lambda-ric (in package.json)
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y \ apt-get install -y \
g++ \ g++ \
make \ make \
cmake \ cmake \
unzip \ unzip \
automake autoconf libtool \ automake autoconf libtool \
libcurl4-openssl-dev libcurl4-openssl-dev
# Add the lambda emulator for local dev, (see entrypoint.sh for where it's used), # 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), # I have the file locally (gitignored) to speed up build times (as it downloads everytime),
@@ -39,46 +34,15 @@ WORKDIR /var/task/
COPY package*.json /var/task/ COPY package*.json /var/task/
RUN npm install RUN npm install
# Install Miniconda and CadQuery
#RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
# RUN curl -sL "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" > "miniconda.sh"
# RUN bash miniconda.sh -b -p /var/task/miniconda
# # RUN . /var/task/miniconda/bin/activate && conda create -n cadquery && conda activate cadquery && conda install -c conda-forge -c cadquery cadquery=master python=3.8
# RUN . /var/task/miniconda/bin/activate
# # RUN export PATH="/var/task/miniconda/bin:$PATH"
# ENV PATH="/var/task/miniconda/bin:${PATH}" # Get the distribution copy of cq-cli
# ARG PATH="/var/task/miniconda/bin:${PATH}" RUN wget https://github.com/CadQuery/cq-cli/releases/download/v2.1.0/cq-cli-Linux-x86_64.zip
# RUN conda activate cadquery && conda install -c conda-forge -c cadquery cadquery=master python=3.8 RUN unzip cq-cli-Linux-x86_64.zip
ENV PATH="/root/miniconda3/bin:${PATH}" RUN chmod +x cq-cli/cq-cli
ARG PATH="/root/miniconda3/bin:${PATH}"
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir /root/.conda \
&& bash Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh \
&& echo "Running $(conda --version)" && \
conda init bash && \
. /root/.bashrc && \
conda update conda && \
conda create -n cadquery && \
conda activate cadquery && \
conda install -c conda-forge -c cadquery cadquery=master python=3.8 && \
# conda create -n python-app && \
# conda activate python-app && \
# conda install python=3.8 pip && \
git clone https://github.com/CadQuery/cq-cli.git
# Grab a copy of cq-cli to convert the provided script
# RUN git clone https://github.com/CadQuery/cq-cli.git
COPY *.js /var/task/ COPY *.js /var/task/
COPY entrypoint.sh /entrypoint.sh COPY entrypoint.sh /entrypoint.sh
RUN ["chmod", "+x", "/entrypoint.sh"] RUN ["chmod", "+x", "/entrypoint.sh"]
ENTRYPOINT ["sh", "/entrypoint.sh"] ENTRYPOINT ["sh", "/entrypoint.sh"]
COPY shaft_coupler.py /shaft_coupler.py
# RUN . $HOME/miniconda/bin/activate && conda activate cadquery && python cq-cli/cq-cli.py --codec svg --infile /shaft_coupler.py
CMD [ "openscad.render" ] CMD [ "openscad.render" ]

View File

@@ -3,26 +3,13 @@ const { promises } = require('fs')
const { writeFile } = promises const { writeFile } = promises
const { nanoid } = require('nanoid') const { nanoid } = require('nanoid')
module.exports.runCQ = async ({ module.exports.runCQ = async ({ file, settings = {} } = {}) => {
file,
settings: {
size: { x = 500, y = 500 } = {},
camera: {
position = { x: 40, y: 40, z: 40 },
rotation = { x: 55, y: 0, z: 25 },
dist = 200,
} = {},
} = {}, // TODO add view settings
} = {}) => {
const tempFile = await makeFile(file) const tempFile = await makeFile(file)
// this one worked const command = `cq-cli/cq-cli --codec stl --infile /tmp/${tempFile}/main.py --outfile /tmp/${tempFile}/output.stl`
// const command = `conda run -n cadquery python ./cq-cli/cq-cli.py --codec svg --infile /tmp/${tempFile}/main.py --outfile /tmp/${tempFile}/output.svg`
const command = `conda run -n cadquery python ./cq-cli/cq-cli.py --codec stl --infile /tmp/${tempFile}/main.py --outfile /tmp/${tempFile}/output.stl`
console.log('command', command) console.log('command', command)
try { try {
const result = await runCommand(command, 10000) const result = await runCommand(command, 30000)
return { result, tempFile } return { result, tempFile }
} catch (error) { } catch (error) {
return { error, tempFile } return { error, tempFile }

View File

@@ -1,13 +0,0 @@
import cadquery as cq
from cadquery import exporters
diam = 5.0
result = (cq.Workplane().circle(diam).extrude(20.0)
.faces(">Z").workplane(invert=True).circle(1.05).cutBlind(8.0)
.faces("<Z").workplane(invert=True).circle(0.8).cutBlind(12.0)
.edges("%CIRCLE").chamfer(0.15))
# exporters.export(coupler, "/home/jwright/Downloads/coupler.stl", exporters.ExportTypes.STL)
show_object(result)

View File

@@ -22,7 +22,7 @@ module.exports.runScad = async ({
console.log('command', command) console.log('command', command)
try { try {
const result = await runCommand(command, 10000) const result = await runCommand(command, 15000)
return { result, tempFile } return { result, tempFile }
} catch (error) { } catch (error) {
return { error, tempFile } return { error, tempFile }