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

Shell Script #91

Open
chrisdonlan opened this issue Aug 23, 2024 · 1 comment
Open

Shell Script #91

chrisdonlan opened this issue Aug 23, 2024 · 1 comment

Comments

@chrisdonlan
Copy link

chrisdonlan commented Aug 23, 2024

Is your feature request related to a problem? Please describe.

I am finding it difficult to demo a container running with the container command as configured, first.

Second, I am finding it difficult running a container command with a shell script.

Third, I am finding it difficult to run a generic container with a command line entrypoint.

Describe the solution you'd like

Ideally I would submit a container with a CLI command or entrypoint to Fission, and invoke it via fission fn test, and then via http GET with a body that is passed to the command line command on STDIN, as a start.

This will be an enormous help for two reasons:

  1. I am not standing up an API to service any kind of optimization
  2. I may be sending data to a command line tool for processing via either CLI (dev), or API (prod), but I don't want to have devs standing up APIs for the sole purpose of fitting into a tool. All things are actually leveraged on the command line during dev and in operation.

If I can simply have an example that works, that would be a major help. I don't see any way to do it with the binary-env. While it does exist and is supported, there are no available examples.

Once I can prove I can:

  1. run a shell script
  2. provide my own image

Then I know anything is possible with, more or less, minimal extra work.

@chrisdonlan
Copy link
Author

chrisdonlan commented Aug 23, 2024

To supplement this, I've figured out how to deploy a shell script, which I am happy to stick somewhere:

CODE?=hello.sh
IMAGE?=fission/binary-env
ENV?=$(notdir $(IMAGE))
FN=$(shell basename -s .sh $(CODE))-$(ENV)

hello.sh:
  echo "#!/bin/bash" >> $@
  echo "echo 'hello, from BASH'" >> $@

create: $(CODE)
  fission env create --name $(ENV) --image $(IMAGE) || echo "env '$(ENV):$(IMAGE)' already exists"
  fission function create --name $(FN) --env $(ENV) --code $<
  fission route create --function $(FN) --url /$(FN) --name $(FN) --method GET

delete:
  fission function list  | awk '{print $$1}' | tail -n +2 | grep -w '$(FN)' | xargs -n1 fission function delete --name
  fission route list | awk '{print $$1}' | tail -n +2 | grep -w '$(FN)' | xargs -n1 fission route delete --name
  fission env list | awk '{print $$1}' | tail -n +2 | grep -w '$(ENV)' | xargs -n1 fission env delete --name

test:
  fission function test --name $(FN)

get:
  curl -G http://127.0.0.1:8080/$(FN)

full-test: test get

The problem is it'll be running on a bare alpine container. So now I am working on getting a custom image running. I have tried using the "container function" method, but that looks like it requires some kind of REST api. I've also duplicated the binary-env image definition I see in Fission's source but I've had no luck,

# FROM golang:1.23.0-bookworm AS server-builder
FROM golang:1.16-alpine AS server-builder

ARG FISSION_SERVER_URL="https://raw.githubusercontent.com/fission/environments/master/binary/server.go"
ARG FISSION_SERVER_ENV_URL="https://raw.githubusercontent.com/fission/environments/master/binary/env.go"

WORKDIR /binary

RUN apk add curl

RUN curl -L $FISSION_SERVER_URL -o /binary/server.go
RUN curl -L $FISSION_SERVER_ENV_URL -o /binary/env.go

RUN go mod init github.com/fission/environments/binary
RUN go mod tidy

RUN go build -o server .

FROM alpine:3.14
# FROM python:3.12-alpine3.19
# FROM python:3.11-slim-bookworm

WORKDIR /mlapp

# RUN apt-get update
# RUN apt-get install -y --no-install-recommends coreutils binutils findutils grep
RUN apk add --no-cache coreutils binutils findutils grep

COPY --from=server-builder /binary/server /mlapp/server

EXPOSE 8888/tcp
ENTRYPOINT [ "./server" ]

How do I construct a python container with the binary server in place for CLI interfacing? Is that an example you could add?

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

No branches or pull requests

1 participant