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

Running a standalone binary from package sources only in docker multistage build #311

Closed
mar1n3r0 opened this issue Jan 27, 2020 · 4 comments

Comments

@mar1n3r0
Copy link

mar1n3r0 commented Jan 27, 2020

Hello and thanks for creating this very neat framework.

I am trying to build a minimal multistage docker build running from binary without the goapp CLI.

I have seen that a binary for mac was accomplished in older threads. Is that doable on Linux as well ?

I am not sure what's the exact flow behind goapp run -v -b default but looking at the code it's running the server only.

Example Dockerfile:

FROM golang:1.13 as buildenv

RUN export GOROOT=/usr/lib/go

RUN export GOPATH=$HOME/go

RUN export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

ENV CGO_ENABLED=0

WORKDIR $GOPATH/src/demo

RUN go get -u -v github.com/maxence-charriere/app/cmd/goapp

COPY cmd cmd

RUN goapp build -v

FROM scratch

COPY --from=buildenv /go/src/demo/cmd/demo-server/demo-server /go/bin/app 

ENTRYPOINT ["/go/bin/app"]

Example output:

Uncaught ReferenceError: Go is not defined
    at (index):351

ReferenceError: Go is not defined error

Based on this similar topic it seems that the issue is somewhere in

app/internal/http/page.js

// -----------------------------------------------------------------------------
// Init Web Assembly
// -----------------------------------------------------------------------------
if (!WebAssembly.instantiateStreaming) {
  WebAssembly.instantiateStreaming = async (resp, importObject) => {
    const source = await (await resp).arrayBuffer()
    return await WebAssembly.instantiate(source, importObject)
  }
}
@mar1n3r0 mar1n3r0 changed the title Running a standalone binary from package sources only Running a standalone binary from package sources only in docker multistage build Jan 27, 2020
@maxence-charriere
Copy link
Owner

Hi there, just giving some news about this issue.

I had been working for a while on the next version of this package and I'm currently finishing up things for a near to come release.

While there will be breaking changes, a Docker example that shows how to run an app created with this package will be added to the demo directory.

You can take a peek here.

@mar1n3r0
Copy link
Author

Great stuff, I had a chance to briefly go through the changes. I can see that the direction the app is heading to is more or less a full-blown framework with its own bindings for all html interfaces and js events. That is quite a departure from the previous versions where it was a mere wrapper of raw markup. Would it still support raw markup as well as bindings or the focus will be towards enclosing the ecosystem in its own objects ?

@maxence-charriere
Copy link
Owner

The focus will be on its own objects. There will still be a raw element:

raw := app.Raw(`<h1>Hello world</h1>`)

It takes raw HTML string argument but it will be limited compared to the current version (no event handler).

@maxence-charriere
Copy link
Owner

Hi there,

here is a docker example on how to use the package with docker:
https://github.com/maxence-charriere/go-app-demo/tree/v6/hello-docker

Gonna close this issue.
Feel free to reopen if it does not fit the need.

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

2 participants