Giter Site home page Giter Site logo

carp-docker's Introduction

carp-docker

Dockerfiles for Carp development, and trying out Carp without installing!

The following Dockerfiles are provided:

Try it!

If you have Docker installed, playing around with Carp is as easy as running:

docker run -it --rm carplang/carp

This will give you a shell in which you can play around with Carp. To verify Carp works as intended, you can try typing:

(defn main [] (IO.println "hi"))

in the REPL. Nothing will happen, but if you build it by typing :bx, hi should be printed to your screen! Amazing, right?

Use it!

As a base image:

You can also use this image as a base image for your Carp-related Docker projects. This is as simple as starting your Dockerfile with:

FROM carplang/carp:latest

Or package only your app:

FROM carplang/carp:latest as builder

COPY example/hello_world.carp /mnt/app/

RUN carp -b hello_world.carp

FROM scratch

COPY --from=builder /mnt/app/out/HelloWorld /usr/local/bin/

ENTRYPOINT ["/usr/local/bin/HelloWorld"]

You can then build your program using docker build -t hello_carp -f <DOCKERFILE_NAME> . and run it using docker run --rm hello_carp!

As a build host

To build .c files and compile them to a native executable, first run the following from the repository root:

docker run -v $(pwd)/example:/mnt/app \
           --user 1000:1000 \
           --rm \
           carplang/carp:latest \
           carp -b hello_world.carp

Then you can run the resulting executable from the host, if it's x64 Linux with glibc:

./example/out/HelloWorld

As a WASM/ASM.js build host

To generate the web files, run the following after executing the build step that produces the .c files from above:

docker run -v $(pwd)/example/out/:/mnt/app \
            --rm \
            -ti \
            carplang/carp:emcc \
            emcc main.c \
                 -s WASM=1 \
                 -I/opt/carp/core \
                 -o hello.html \
                 --emrun

You can serve the website directly from Docker afterwards!

docker run -v $(pwd)/example/out/:/mnt/app \
           --rm \
           -ti \
           --net=host \
           carplang/carp:emcc \
           emrun --no_browser \
                 --port 8080 \
                 hello.html

The above will open port 8080 and serve the produced files there. This means that you should be able to go to http://localhost:8080/hello.html and see your app if your browser supports WASM!


Have fun!

carp-docker's People

Contributors

dleslie avatar hellerve avatar jaremko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

carp-docker's Issues

Set up autobuild

We need to investigate why Dockerhub won’t let me set up autobuilds. The repository isn’t elligible for autobuilds via Github, despite me being allowed to do basically everything with the repository and @eriksvedang (the owner of the organization) having accepted my OAuth request.

What is happening here? Any input is welcome!

For now working without autobuilds is fine, but I’d love if that weren’t necessary.

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.