Introduction to Stack’s Docker Integration

Yuji Yamamoto (山本悠滋)

2016-09-17 Haskell Day 2016

Nice to meet you! (^-^)

Yuji Yamamoto (@igrep) age 27.

Nice to meet you! (^-^)

Nice to meet you! (^-^)

( ̄^ ̄) Professional Haskeller.

I’m gonna talk about…

I’m NOT gonna talk about…

TL;DR

With Stack’s Docker integration,

Background

How does GHC make Haskell code run?

But…

With Stack’s Docker integration,

Stack’s Docker integration does:

How to use

  1. Append docker option to stack.yaml yaml docker: enable: true
  2. Run stack build/install/setup as usual.

How it works

※Changes by the configurations.

  1. Create a temporary container just for executing stack’s subcommands.
  2. Share the project directory and ~/.stack by mounting.
    • Where dependencies and build artifacts are saved.
  3. stack command runs in the container.
  4. Delete the temporary container
    • Build dependencies and artifacts are still persisted.

How it works (cont)

  1. Now you can upload the executable to your production, staging, or any target server!

☆ Tips on using Stack’s Docker integration ☆

ᕦ(ò_óˇ)ᕤ Build on your own Docker image

ᕦ(ò_óˇ)ᕤ Build on your own Docker image

Edit stack.yaml

docker:
  repo: "centos:6"

ᕦ(ò_óˇ)ᕤ Build on your own Docker image

Edit stack.yaml

docker:
  repo: "https://your-docker-repo/image:latest"

ᕦ(ò_óˇ)ᕤ Build on your own Docker image

Or…

docker:
  image: "<some_image_id_or_tag>"

ᕦ(ò_óˇ)ᕤ Build on your own Docker image

Requirement for Orignal Images:

ᕦ(ò_óˇ)ᕤ Build on your own Docker image

Requirement for Orignal Images:

ᕦ(ò_óˇ)ᕤ Build on your own Docker image

Specify stack-exe

docker:
  stack-exe: image

三┏( ^o^)┛ Go over the proxy!

docker:
  env:
    http_proxy: http://proxy.example.com

三┏( ^o^)┛ Go over the proxy!

May also need build-time-arguments…

$ docker build --build-arg=http_proxy=...

(x_x) DON’T override ENTRYPOINT!

ENTRYPOINT your-cool-entrypoint-command

Case study

Case study

Case study

Demo

igrep/stack-docker-sample

Case study

(o˘◡˘o) My impression

(^-^) The Good News

(x_x;) The Bad News

Current limitation

Conclusion

Stack’s Docker integration enables: