Giter Club home page Giter Club logo

haskell-docker-builder's Introduction

haskell-docker-builder

Package Haskell binaries into docker images.

Use case:

If you can build statically linked binaries, you are better off using busybox directly. This approach is helpful when your executable is dependent on dynamically linked libraries.

Quick start:

You can drop this Makefile into your project directory. This is assuming that your project uses stack. It can be easily modified to work with cabal. Replace project and registry with your own values.

project  := myproject
registry := myregistry

project_dir := $(shell pwd)
build_dir   := $(project_dir)/$(shell stack path --dist-dir)/build
version     := $(shell grep -oP '^version:\s*\K.*' $(project).cabal)

image: $(project).cabal
	stack build
	docker run --rm -v $(build_dir)/$(project)-exe/$(project)-exe:/root/$(project)-exe hasura/haskell-docker-packager:1.0 /build.sh $(project)-exe | docker import - $(registry)/$(project):$(version)

push: $(project).cabal
	docker push $(registry)/$(project):$(version)

You can now use make image to create the docker image.

How does this work

The make image rule builds a bare minimal root filesystem with the haskell binary and all necessary libraries. This filesystem is imported as an image into docker.

The compiled binary is mounted into a debian builder image. A script inside the image processes the binary and copies all dynamically linked libraries into the root filesystem.

Customising the builder image

You'll need to customise the builder image to add the libraries needed for the executable. For example, if the dependency is libpq, you can do this:

FROM hasura/haskell-docker-packager:1.0
RUN <apt install the library>

Update the Makefile to use this new image instead of haskell-docker-packager.

haskell-docker-builder's People

Contributors

0x777 avatar coco98 avatar lexi-lambda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.