Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Introduction to Stack's Docker
Integration
Yuji Yamamoto (山本悠滋)
2016-09-17 Haskell Day 2016
Nice to meet you! (^-^)
Yuji Yamamoto (@igrep) age 27.
NO RELATION WITH Emacs plugin "igrep.el"!
Nice to meet you! (^-^)
Software Engineer at GMO CLICK Holdings, Inc.
Writing online trading market of GMO CLICK Securitie...
Nice to meet you! (^-^)
( ̄^ ̄) Professional Haskeller.
(;^ω^) Used to be. Just for a month
(;_;) Using Haskell was given up...
Advertisement m(_ _)m 1
HaskellJP wiki:
http://wiki.haskell.jp “〆(゚_゚*)
Anyone can edit with a GitHub account!
The most he...
Advertisement m(_ _)m 2
Published a blog post 「JavaでMonadをはじめからていねい
に」 “〆(゚_゚*)
Monad in Java from the beggining
( ̄^ ̄) Tol...
I'm gonna talk about...
What is Stack's Docker integration
How it works
Tips on using it
Case study
(^w^) May help you to ...
I'm NOT gonna talk about...
Basic usage of Stack
Basic usage of Docker.
Programming language Haskell itself.
TL;DR
With Stack's Docker integration,
(^-^) You can always build production-ready application
as easily as you use stack ...
Background
How does GHC make Haskell code run?
Emit native executables!
Usually single, self-contained!
Just put the execu...
But...
You must build for your production server!
Linux!
Dependent system (C) libraries and their version.
... and so on!
...
With Stack's Docker integration,
Build directly for your production environment.
Just by stack build as usual.
Stack's Docker integration does:
Wrap docker command.
Make almost all operation of stack on the container.
Setup GHC.
Inst...
How to use
1. Append docker option to stack.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. Sh...
How it works (cont)
5. 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
三┏( ^o^)┛ Go over the proxy!
(x_x) DO...
ᕦ(ò_óˇ)ᕤ Build on your own
Docker image
Default: Stack's original image (based on Ubuntu)
How to use CentOS/Debian/Arch?
H...
ᕦ(ò_óˇ)ᕤ 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:
GHC must be installable (or already installed):
li...
ᕦ(ò_óˇ)ᕤ Build on your own
Docker image
Requirement for Orignal Images:
Or, install stack itself in the image in advance.
ᕦ(ò_óˇ)ᕤ 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
Stack uses ENTRYPOINT internally!
Case study
Tiny mock server to test with an external Web API.
Must run on the staging server.
CentOS 6
Case study
Never mind zlib/libgmp/etc's diff in version, installation path.
Production-ready executables are always built ...
Case study
Demo
igrep/stack-docker-sample
Case study
(o˘◡˘o) My impression
(*´∀`*)ノ Comfortable:
I did't have to install anything except the built app.
(´∪`*) The t...
(^-^) The Good News
Available on Docker for Mac OS X, not only Linux!
(x_x;) The Bad News
boot2docker is NOT recommended.
VirtualBox's shared folder is too slow!
Unavailable on Docker for Wind...
Current limitation
Use on Linux or Mac OS X!
(;^ω^) Sorry Windows users!
Use the other VMs to run Linux!
Conclusion
Stack's Docker integration enables:
To build production-ready executables
as easily as you use stack command as...
Upcoming SlideShare
Loading in …5
×

Introduction to stack's docker integration (1)

948 views

Published on

Presentation at Haskell Day 2016.
About Stack's Docker integration, which enables you to easily build Haskell apps for your production server environment.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Introduction to stack's docker integration (1)

  1. 1. Introduction to Stack's Docker Integration Yuji Yamamoto (山本悠滋) 2016-09-17 Haskell Day 2016
  2. 2. Nice to meet you! (^-^) Yuji Yamamoto (@igrep) age 27. NO RELATION WITH Emacs plugin "igrep.el"!
  3. 3. Nice to meet you! (^-^) Software Engineer at GMO CLICK Holdings, Inc. Writing online trading market of GMO CLICK Securities, Inc. in Java. Hobby Haskeller. Using Haskell for 4 years. Holding workshop of Haskell (almost) every month.
  4. 4. Nice to meet you! (^-^) ( ̄^ ̄) Professional Haskeller. (;^ω^) Used to be. Just for a month (;_;) Using Haskell was given up Due to difficulty of teaching my colleagues...
  5. 5. Advertisement m(_ _)m 1 HaskellJP wiki: http://wiki.haskell.jp “〆(゚_゚*) Anyone can edit with a GitHub account! The most helpful page: Haskellに関する日本語のリンク集 Haskell-related pages in Japanese Recently all edits are only by me... (;_;)
  6. 6. Advertisement m(_ _)m 2 Published a blog post 「JavaでMonadをはじめからていねい に」 “〆(゚_゚*) Monad in Java from the beggining ( ̄^ ̄) Told the relation between the do notation and the associative law most clearly!
  7. 7. I'm gonna talk about... What is Stack's Docker integration How it works Tips on using it Case study (^w^) May help you to convince your boss to adapt Haskell!
  8. 8. I'm NOT gonna talk about... Basic usage of Stack Basic usage of Docker. Programming language Haskell itself.
  9. 9. TL;DR With Stack's Docker integration, (^-^) You can always build production-ready application as easily as you use stack command as usual.
  10. 10. Background How does GHC make Haskell code run? Emit native executables! Usually single, self-contained! Just put the executables to deploy! Stack itself is actually single binary!
  11. 11. But... You must build for your production server! Linux! Dependent system (C) libraries and their version. ... and so on! Corss-compilation with GHC is hard...
  12. 12. With Stack's Docker integration, Build directly for your production environment. Just by stack build as usual.
  13. 13. Stack's Docker integration does: Wrap docker command. Make almost all operation of stack on the container. Setup GHC. Install dependencies. Then build your app! Run tests.
  14. 14. How to use 1. Append docker option to stack.yaml docker: enable: true 2. Run stack build/install/setup as usual.
  15. 15. 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.
  16. 16. How it works (cont) 5. Now you can upload the executable to your production, staging, or any target server!
  17. 17. ☆ Tips on using Stack's Docker integration ☆ ᕦ(ò_óˇ)ᕤ Build on your own Docker image 三┏( ^o^)┛ Go over the proxy! (x_x) DON'T overwrite ENTRYPOINT!
  18. 18. ᕦ(ò_óˇ)ᕤ Build on your own Docker image Default: Stack's original image (based on Ubuntu) How to use CentOS/Debian/Arch? How to install C libraries or any other non-Haskell dependencies?
  19. 19. ᕦ(ò_óˇ)ᕤ Build on your own Docker image Edit stack.yaml docker: repo: "centos:6"
  20. 20. ᕦ(ò_óˇ)ᕤ Build on your own Docker image Edit stack.yaml docker: repo: "https://your-docker-repo/image:latest"
  21. 21. ᕦ(ò_óˇ)ᕤ Build on your own Docker image Or... docker: image: "<some_image_id_or_tag>"
  22. 22. ᕦ(ò_óˇ)ᕤ Build on your own Docker image Requirement for Orignal Images: GHC must be installable (or already installed): libgmp Tools to build C sources. gcc, make etc.
  23. 23. ᕦ(ò_óˇ)ᕤ Build on your own Docker image Requirement for Orignal Images: Or, install stack itself in the image in advance.
  24. 24. ᕦ(ò_óˇ)ᕤ Build on your own Docker image Specify stack-exe docker: stack-exe: image
  25. 25. 三┏( ^o^)┛ Go over the proxy! docker: env: http_proxy: http://proxy.example.com
  26. 26. 三┏( ^o^)┛ Go over the proxy! May also need build-time-arguments... $ docker build --build-arg=http_proxy=...
  27. 27. (x_x) DON'T override ENTRYPOINT! ENTRYPOINT your-cool-entrypoint-command Stack uses ENTRYPOINT internally!
  28. 28. Case study Tiny mock server to test with an external Web API. Must run on the staging server. CentOS 6
  29. 29. Case study Never mind zlib/libgmp/etc's diff in version, installation path. Production-ready executables are always built on my development machine! Just by the familliar stack build/exec/... Then scp the executable to our server! stack install scp ~/.local/bin/executable server@example.com:/
  30. 30. Case study Demo igrep/stack-docker-sample
  31. 31. Case study (o˘◡˘o) My impression (*´∀`*)ノ Comfortable: I did't have to install anything except the built app. (´∪`*) The tiny application didn't need even CI! All was done on my development machine. (x_x;) Initial build takes a long time... (;^ω^) Haskell was not good for tiny apps!
  32. 32. (^-^) The Good News Available on Docker for Mac OS X, not only Linux!
  33. 33. (x_x;) The Bad News boot2docker is NOT recommended. VirtualBox's shared folder is too slow! Unavailable on Docker for Windows... See this issue
  34. 34. Current limitation Use on Linux or Mac OS X! (;^ω^) Sorry Windows users! Use the other VMs to run Linux!
  35. 35. Conclusion Stack's Docker integration enables: To build production-ready executables as easily as you use stack command as usual. (^-^) Only with your machine and scp! But Haskell is too slow to compile tiny apps... (゚◇゚;) Especially compiling dependencies!

×