Compare commits

..

2 Commits

Author SHA1 Message Date
46ff8fc584 Express runtime working 2024-07-06 21:21:02 -03:00
125870d0a8 Unify stderr/stdout of faaso_run 2024-07-06 21:20:20 -03:00
6 changed files with 57 additions and 8 deletions

13
TODO.md
View File

@ -8,22 +8,23 @@
* Polish frontend UI **A LOT**
* Version checks for consistency between client/server
* Have 3 runtimes:
* Crystal + Kemal
* Python + Flask [WIP]
* Nodejs + Express
* Crystal + Kemal
* Python + Flask
* Nodejs + Express
* Document
* How to create a runtime
* How to create a funko
* How to setup the proxy
* APIs
* Sanitize all inputs
* Streaming responses in slow operations like scaling down
* Streaming responses in slow operations like scaling down
or building
* Make more things configurable / remove hardcoded stuff
* CD for binaries and images for at least arm64/x86
* Multi-container docker logs [faaso logs -f FUNKO]
* Direct error and above to stderr, others to stdout, while keeping
logging level configurable
* Direct error and above to stderr, others to stdout, while
keeping logging level configurable
* Fix proxy reload / Make it reload on file changes
# Things to do but not before release

View File

@ -0,0 +1,20 @@
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as build
RUN apk update && apk upgrade && apk add nodejs npm {{ ship_packages | join(" ") }} {{ devel_packages | join(" ") }} && apk cache clean
WORKDIR /home/app
COPY ./ ./
RUN npm i
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship
RUN apk update && apk upgrade && apk add nodejs curl {{ ship_packages | join " " }} && apk cache clean
RUN addgroup -S app && adduser app -S -G app
WORKDIR /home/app
USER app
COPY --from=build /home/app/ .
CMD ["node", "funko.js"]
HEALTHCHECK {{ healthcheck_options }} CMD {{ healthcheck_command }}

View File

@ -0,0 +1,15 @@
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.get('/ping', (req, res) => {
res.send('OK')
})
app.listen(port, () => {
console.log(`Example funko listening on port ${port}`)
})

View File

@ -0,0 +1,2 @@
name: {{ name }}
runtime: {{ runtime }}

View File

@ -0,0 +1,11 @@
{
"name": "{{name}}",
"version": "1.0.0",
"main": "funko.js",
"author": "",
"license": "MIT",
"description": "Example Funko",
"dependencies": {
"express": "^4.19.2"
}
}

View File

@ -130,7 +130,8 @@ module Funko
Log.info { "Running faaso [#{args.join(", ")}, -l]" }
Process.run(
command: "faaso",
args: args + ["-l"], # Always local in the server
args: args + ["-l", "2>&1"], # Always local in the server
shell: true,
) do |process|
loop do
env.response.print process.output.gets(chomp: false)
@ -138,7 +139,6 @@ module Funko
Fiber.yield
break if process.terminated?
end
p! process.error.peek
true
end
# FIXME: find a way to raise an exception on failure