git.iko.soy/heroku-buildpack-stack
on master help sign in
LICENSEnew file+8
since splitsnapshots
unifiedsplit
@@ -0,0 +1,8 @@
1+The MIT License (MIT)
2+Copyright (c) 2016 Mark Fine
3+
4+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Procfile.examplenew file+1
@@ -0,0 +1 @@
1+web: YOURAPPNAME-exe # $ cat *.cabal | grep executable
README.md+19
@@ -12,6 +12,14 @@ Set this buildpack on an existing app:
12
12
13 $ heroku buildpacks:set https://github.com/mfine/heroku-buildpack-stack
13 $ heroku buildpacks:set https://github.com/mfine/heroku-buildpack-stack
14
14
15+Binary executables are placed in `/app/.local/bin/` after compilation, a directory which Heroku includes in your `$PATH`, so assuming that your application is [binding to `$PORT`](https://devcenter.heroku.com/articles/dynos#web-dynos), you can serve your app by [creating a `Procfile`](https://devcenter.heroku.com/articles/procfile) at your project root that defines a `web` process type for the `executable` defined in your `.cabal` file:
16+
17+ $ cat *.cabal | grep executable
18+ executable YOURAPPNAME-exe
19+
20+ $ echo "web: YOURAPPNAME-exe" >> Procfile
21+
22+
15### Templating stack.yaml
23### Templating stack.yaml
16
24
17To avoid committing secrets into `stack.yaml` for access to private
25To avoid committing secrets into `stack.yaml` for access to private
@@ -35,6 +43,17 @@ before compilation, the `stack.yaml` will be substituted as follows:
35 -location:
43 -location:
36 git: https://mfine:abc123@github.com/mfine/heroku-buildpack-stack.git
44 git: https://mfine:abc123@github.com/mfine/heroku-buildpack-stack.git
37
45
46+
47+### Makefile Support
48+
49+This buildpack now supports an optional Makefile, in case you need to coordinate
50+other build steps with Stack. It assumes that the Makefile includes a `make
51+install` target that uses the Stack build command with the flag `--copy-bins`.
52+For example, a possible `install` target configuration in the Makefile could be:
53+
54+ install:
55+ stack build --copy-bins
56+
38[1]: https://github.com/mfine/heroku-buildpack-stack
57[1]: https://github.com/mfine/heroku-buildpack-stack
39[2]: http://devcenter.heroku.com/articles/buildpacks
58[2]: http://devcenter.heroku.com/articles/buildpacks
40[3]: https://github.com/commercialhaskell/stack
59[3]: https://github.com/commercialhaskell/stack
bin/compile+19−11
@@ -26,7 +26,7 @@ if [ -d "$ENV_DIR" ]; then
26fi
26fi
27
27
28WORK_DIR=/app
28WORK_DIR=/app
29−cp -R "$BUILD_DIR/." "$WORK_DIR"
29+cp -Rp "$BUILD_DIR/." "$WORK_DIR"
30mkdir -p "$WORK_DIR/vendor/bin"
30mkdir -p "$WORK_DIR/vendor/bin"
31mkdir -p "$WORK_DIR/vendor/ghc-libs"
31mkdir -p "$WORK_DIR/vendor/ghc-libs"
32
32
@@ -45,7 +45,7 @@ function set-default-env (){
45}
45}
46
46
47export LANG=en_US.UTF-8
47export LANG=en_US.UTF-8
48−export LIBRARY_PATH=$WORK_DIR/vendor/ghc-libs:/usr/lib:$LIBRARY_PATH
48+export LIBRARY_PATH=$WORK_DIR/vendor/ghc-libs:$WORK_DIR/vendor/lib:/usr/lib:$LIBRARY_PATH
49export LD_LIBRARY_PATH=$LIBRARY_PATH
49export LD_LIBRARY_PATH=$LIBRARY_PATH
50export PATH=$WORK_DIR/.local/bin:$WORK_DIR/vendor/bin:$PATH
50export PATH=$WORK_DIR/.local/bin:$WORK_DIR/vendor/bin:$PATH
51export STACK_ROOT=$CACHE_DIR/.stack
51export STACK_ROOT=$CACHE_DIR/.stack
@@ -60,10 +60,10 @@ if [ ! -e "$LIBGMP_DIR" ]; then
60 curl -# -L "$LIBGMP_URL" | tar xz -C "$LIBGMP_DIR"
60 curl -# -L "$LIBGMP_URL" | tar xz -C "$LIBGMP_DIR"
61fi
61fi
62speak "Restoring $LIBGMP_VER files from cache"
62speak "Restoring $LIBGMP_VER files from cache"
63−cp -R "$LIBGMP_DIR/ghc-libs/." "$WORK_DIR/vendor/ghc-libs"
63+cp -Rp "$LIBGMP_DIR/ghc-libs/." "$WORK_DIR/vendor/ghc-libs"
64
64
65########## stack exe ###############################################
65########## stack exe ###############################################
66−STACK_VER=${STACK_VER:-1.2.0}
66+STACK_VER=${STACK_VER:-2.1.3}
67STACK_URL=${STACK_URL:-https://github.com/commercialhaskell/stack/releases/download/v"$STACK_VER"/stack-"$STACK_VER"-linux-x86_64.tar.gz}
67STACK_URL=${STACK_URL:-https://github.com/commercialhaskell/stack/releases/download/v"$STACK_VER"/stack-"$STACK_VER"-linux-x86_64.tar.gz}
68STACK_DIR="$CACHE_DIR/stack-$STACK_VER"
68STACK_DIR="$CACHE_DIR/stack-$STACK_VER"
69STACK_EXE="$STACK_DIR/stack"
69STACK_EXE="$STACK_DIR/stack"
@@ -86,20 +86,28 @@ fi
86SANDBOX_DIR="$CACHE_DIR/.stack-work"
86SANDBOX_DIR="$CACHE_DIR/.stack-work"
87if [ -e "$SANDBOX_DIR" ]; then
87if [ -e "$SANDBOX_DIR" ]; then
88 speak "Restoring .stack-work"
88 speak "Restoring .stack-work"
89− cp -R "$SANDBOX_DIR" "$WORK_DIR"
89+ cp -Rp "$SANDBOX_DIR" "$WORK_DIR"
90else
90else
91 mkdir -p "$SANDBOX_DIR"
91 mkdir -p "$SANDBOX_DIR"
92fi
92fi
93
93
94speak "Running stack"
94speak "Running stack"
95cd "$WORK_DIR"
95cd "$WORK_DIR"
96+# Makefile support (if you need other build tools than Stack that you need to use in conjunction)
97+if [ -f "$BUILD_DIR/Makefile" ]; then
98+ speak "Makefile detected"
99+ make
100+ make install
101+else
96−stack setup
102+ stack setup
103+ stack clean
97−stack build --fast --copy-bins
104+ stack build --ghc-options='-O2' --copy-bins
105+fi
98
106
99# Set context environment variables.
107# Set context environment variables.
100−set-env PATH "$WORK_DIR/.local/bin:$PATH"
108+set-env PATH "$WORK_DIR/.local/bin:$WORK_DIR/vendor/bin:\$PATH"
101−set-default-env LIBRARY_PATH "$WORK_DIR/vendor/ghc-libs:/usr/lib"
109+set-default-env LIBRARY_PATH "$WORK_DIR/vendor/ghc-libs:$WORK_DIR/vendor/lib:/usr/lib"
102−set-default-env LD_LIBRARY_PATH "$WORK_DIR/vendor/ghc-libs:/usr/lib"
110+set-default-env LD_LIBRARY_PATH "$WORK_DIR/vendor/ghc-libs:$WORK_DIR/vendor/lib:/usr/lib"
103
111
104speak "Making stack binaries available"
112speak "Making stack binaries available"
105mkdir -p "$BUILD_DIR/vendor"
113mkdir -p "$BUILD_DIR/vendor"
@@ -109,6 +117,6 @@ mv "$WORK_DIR/.local/bin" "$BUILD_DIR/.local"
109
117
110speak "Caching .stack-work"
118speak "Caching .stack-work"
111rsync -avq "$WORK_DIR/.stack-work/" "$SANDBOX_DIR"
119rsync -avq "$WORK_DIR/.stack-work/" "$SANDBOX_DIR"
112−mv "$WORK_DIR/.stack-work" "$BUILD_DIR"
120+cp -Rp "$WORK_DIR/.stack-work" "$BUILD_DIR"
113
121
114speak "Finished!"
122speak "Finished!"