Skip to content

Instantly share code, notes, and snippets.

@psftw
Created March 1, 2017 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psftw/74e310e911d83518af37958912ca5090 to your computer and use it in GitHub Desktop.
Save psftw/74e310e911d83518af37958912ca5090 to your computer and use it in GitHub Desktop.
$ docker run -it --name stack-temp haskell:8.0.2 stack new example
Downloading template "new-template" to create project "example" in example/ ...
The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in /root/.stack/config.yaml, like this:
templates:
params:
author-email: value
author-name: value
category: value
copyright: value
github-username: value
Or you can pass each one as parameters like this:
stack new example new-template -p "author-email:value" -p "author-name:value" -p "category:value" -p "copyright:value" -p "github-username:value"
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- example/example.cabal
Selecting the best among 10 snapshots...
Downloaded lts-8.3 build plan.
Fetched package index.
Populated index cache.
* Matches lts-8.3
Selected resolver: lts-8.3
Initialising configuration using resolver: lts-8.3
Total number of user packages considered: 1
Writing configuration to file: example/stack.yaml
All done.
$ docker cp stack-temp:/example .
$ cd example
$ vi example.cabal # in this example, I added a dependency on parsec
$ vi Dockerfile && cat Dockerfile
FROM haskell:8.0.2
WORKDIR /opt/foo
# optionally cache the package index too
RUN stack update
COPY example.cabal /opt/foo
COPY stack.yaml /opt/foo
RUN stack install --only-dependencies
COPY . /opt/foo
RUN stack install
CMD ["/usr/local/bin/stack", "exec", "example-exe"]
$ docker build -t tmp .
Sending build context to Docker daemon 14.85 kB
Step 1/9 : FROM haskell:8.0.2
---> e542d78b78de
Step 2/9 : WORKDIR /opt/foo
---> Using cache
---> 577e1b6e63d2
Step 3/9 : RUN stack update
---> Running in 13ac8d4d3d19
Updating package index Hackage (mirrored at https://github.com/commercialhaskell/all-cabal-hashes.git) ...
Fetching package index ...
Fetched package index.
---> e36900c3fa3c
Removing intermediate container 13ac8d4d3d19
Step 4/9 : COPY example.cabal /opt/foo
---> 52cc8c27924e
Removing intermediate container b53410e15d94
Step 5/9 : COPY stack.yaml /opt/foo
---> 4e57fdbf26d8
Removing intermediate container 793303a03306
Step 6/9 : RUN stack install --only-dependencies
---> Running in 33e8ea1de521
Downloading lts-8.3 build plan ...
Downloaded lts-8.3 build plan.
Populating index cache ...
Populated index cache.
Warning: Directory listed in example.cabal file does not exist: src
Warning: Directory listed in example.cabal file does not exist: app
Warning: Directory listed in example.cabal file does not exist: test
Warning: File listed in example.cabal file does not exist: README.md
[1 of 2] Compiling Main ( /root/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /root/.stack/setup-exe-src/setup-mPHDZzAJ.o )
[2 of 2] Compiling StackSetupShim ( /root/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /root/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o )
Linking /root/.stack/setup-exe-cache/x86_64-linux/tmp-Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 ...
text-1.2.2.1: download
mtl-2.2.1: download
mtl-2.2.1: configure
mtl-2.2.1: build
text-1.2.2.1: configure
text-1.2.2.1: build
mtl-2.2.1: copy/register
text-1.2.2.1: copy/register
parsec-3.1.11: download
parsec-3.1.11: configure
parsec-3.1.11: build
parsec-3.1.11: copy/register
Completed 3 action(s).
---> 39e60e67181d
Removing intermediate container 33e8ea1de521
Step 7/9 : COPY . /opt/foo
---> 640d6861c181
Removing intermediate container f22049fbf81d
Step 8/9 : RUN stack install
---> Running in 6a8269442d84
Warning: File listed in example.cabal file does not exist: README.md
example-0.1.0.0: configure (lib + exe)
Configuring example-0.1.0.0...
example-0.1.0.0: build (lib + exe)
Preprocessing library example-0.1.0.0...
[1 of 1] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/Lib.o )
Preprocessing executable 'example-exe' for example-0.1.0.0...
[1 of 1] Compiling Main ( app/Main.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/example-exe/example-exe-tmp/Main.o )
Linking .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/example-exe/example-exe ...
Warning: File listed in example.cabal file does not exist: README.md
example-0.1.0.0: copy/register
Installing library in
/opt/foo/.stack-work/install/x86_64-linux/lts-8.3/8.0.2/lib/x86_64-linux-ghc-8.0.2/example-0.1.0.0-9VRLrgIGgPdLMEesTr4YpO
Installing executable(s) in
/opt/foo/.stack-work/install/x86_64-linux/lts-8.3/8.0.2/bin
Registering example-0.1.0.0...
Copying from /opt/foo/.stack-work/install/x86_64-linux/lts-8.3/8.0.2/bin/example-exe to /root/.local/bin/example-exe
Copied executables to /root/.local/bin:
- example-exe
---> cfdc2eaafeab
Removing intermediate container 6a8269442d84
Step 9/9 : CMD /usr/local/bin/stack exec example-exe
---> Running in f4648cd115f0
---> cec97ad4b14e
Removing intermediate container f4648cd115f0
Successfully built cec97ad4b14e
$ docker run -it --rm tmp
someFunc
$ vi src/Lib.hs # make changes :-)
$ docker build -t tmp .
Sending build context to Docker daemon 14.85 kB
Step 1/9 : FROM haskell:8.0.2
---> e542d78b78de
Step 2/9 : WORKDIR /opt/foo
---> Using cache
---> 577e1b6e63d2
Step 3/9 : RUN stack update
---> Using cache
---> e36900c3fa3c
Step 4/9 : COPY example.cabal /opt/foo
---> Using cache
---> 52cc8c27924e
Step 5/9 : COPY stack.yaml /opt/foo
---> Using cache
---> 4e57fdbf26d8
Step 6/9 : RUN stack install --only-dependencies
---> Using cache
---> 39e60e67181d
Step 7/9 : COPY . /opt/foo
---> b49b1a7d9eb3
Removing intermediate container 48d684de219f
Step 8/9 : RUN stack install
---> Running in c827b54bce5f
Warning: File listed in example.cabal file does not exist: README.md
example-0.1.0.0: configure (lib + exe)
Configuring example-0.1.0.0...
example-0.1.0.0: build (lib + exe)
Preprocessing library example-0.1.0.0...
[1 of 1] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/Lib.o )
Preprocessing executable 'example-exe' for example-0.1.0.0...
[1 of 1] Compiling Main ( app/Main.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/example-exe/example-exe-tmp/Main.o )
Linking .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/example-exe/example-exe ...
Warning: File listed in example.cabal file does not exist: README.md
example-0.1.0.0: copy/register
Installing library in
/opt/foo/.stack-work/install/x86_64-linux/lts-8.3/8.0.2/lib/x86_64-linux-ghc-8.0.2/example-0.1.0.0-9VRLrgIGgPdLMEesTr4YpO
Installing executable(s) in
/opt/foo/.stack-work/install/x86_64-linux/lts-8.3/8.0.2/bin
Registering example-0.1.0.0...
Copying from /opt/foo/.stack-work/install/x86_64-linux/lts-8.3/8.0.2/bin/example-exe to /root/.local/bin/example-exe
Copied executables to /root/.local/bin:
- example-exe
---> 4dd1838abe0e
Removing intermediate container c827b54bce5f
Step 9/9 : CMD /usr/local/bin/stack exec example-exe
---> Running in 02e59028e4e2
---> 95a307beeca0
Removing intermediate container 02e59028e4e2
Successfully built 95a307beeca0
$ docker run -it --rm tmp
someFunc2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment