Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create and deploy simple openscad api #228

Merged
merged 2 commits into from
Mar 9, 2021
Merged

Create and deploy simple openscad api #228

merged 2 commits into from
Mar 9, 2021

Conversation

Irev-Dev
Copy link
Owner

@Irev-Dev Irev-Dev commented Mar 7, 2021

A minimal frontend integration has been added to as a POC

resolves #219 and #222

Screen.Recording.2021-03-07.at.4.23.01.pm.mov

The local development setup is not great, so I've made #227 to come back and fix that later (probably fairly soon).
This api is completely seperate to the rest of the apps api (or whatever you call graphql), and I think that's fine!?

I'll add more comments inline.

A minimal frontend integration has been added to as a POC

resolves #219 and #222
Because of the way the docker containers to be deployed as lambdas on aws are somewhat specialised for the purpose we're using `docker-compose` to spin one up for each function/endpoint. But more work needs to be done to get this to work with the app locally.

```bash
docker-compose up --build
Copy link
Owner Author

@Irev-Dev Irev-Dev Mar 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the lambda functions needed are suposed to run in aws-land they can't be used directly, so I plan on making a dev only docker container that does a bit of aws emulation so that we can use them locally. I started doing this with with the docker-compose file, but I think it will make more sense to get this bit of work done when I start actually iterating on the openscad api (atm it's very simple).

It's not great to be writing dev only code (emulating aws), and the serverless framework I'm using does have a offline plugin that I've used before, but doesn't seem to like docker lambdas.

@@ -1,34 +1,50 @@
const openScadBaseURL =
'https://x2wvhihk56.execute-api.us-east-1.amazonaws.com/dev'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't sure if I should commit this.
I can make it an env var instead, but that makes it a pain for anyone new forking the repo, as they'ed need to get it off me before they can use openscad locally. This isn't a secret so I think it's fine.

Copy link
Owner Author

@Irev-Dev Irev-Dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple things I should fix up now.

RUN apt-get install -y curl

# install node 14, (maybe I should put the .sh file into version control?)
RUN curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should commit this bash script I think. TODO

@@ -0,0 +1,13 @@

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll delete this readme, made redundant by the better one in the api/src/docker. TODO

apiGateway:
metrics: true
binaryMediaTypes:
- '*/*'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bit of nuance here that I should capture in a comment. TODO

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This */* issue is a good future in-the-weeds task for someone really looking to learn lambdas!

# variable1: value1

functions:
preflightrender:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reference comment in openscad.js. TODO

@@ -0,0 +1,151 @@
service: cad-lambdas
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@franknoirot franknoirot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, I don't know how you waded through that shell script docker lambda inception so quickly.

}
}
const data = await response.blob()
return {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean! 🧼 I like how this is shaped on the frontend.

@Irev-Dev
Copy link
Owner Author

Irev-Dev commented Mar 9, 2021

Looks great, I don't know how you waded through that shell script docker lambda inception so quickly.

With great sadness 😂.

@Irev-Dev Irev-Dev merged commit d03c130 into main Mar 9, 2021
@Irev-Dev Irev-Dev deleted the kurt/219-222 branch March 9, 2021 07:40
@Irev-Dev Irev-Dev self-assigned this May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make OpenSCAD api
2 participants