]> git.immae.eu Git - github/fretlink/purescript-docker.git/blame - README.md
Added 0.12.0
[github/fretlink/purescript-docker.git] / README.md
CommitLineData
649ea3a7 1# purescript-docker
fb6a7a8a
RS
2
3[![Docker Stars](https://img.shields.io/docker/stars/gyeh/purescript.svg?maxAge=2592000)](https://hub.docker.com/r/gyeh/purescript/)
4[![Docker Pulls](https://img.shields.io/docker/pulls/gyeh/purescript.svg?maxAge=2592000)](https://hub.docker.com/r/gyeh/purescript/)
5
6Purescript build for docker
79c6723c
RS
7
8![Purescript](https://raw.githubusercontent.com/Risto-Stevcev/purescript-docker/master/logo.png)
99956601 9
105cd287
DG
10# Build Locally
11
12You can build the image locally by cloning the repo and running `docker build .` in the project root.
13
14# Usage
99956601
RS
15
16Note: You may need to run docker comands as a superuser (sudo) depending on how it's configured on your system.
17
18Pull the version you want to use:
19
20```
fb6a7a8a 21$ docker pull gyeh/purescript:0.9.1
99956601
RS
22```
23
105cd287 24Check to see that your image was created:
99956601
RS
25
26```
27$ docker images
28REPOSITORY TAG IMAGE ID CREATED SIZE
fb6a7a8a 29gyeh/purescript 0.9.1 b09608732ec8 0 minutes ago 831.9 MB
99956601
RS
30```
31
32Try the Purescript REPL (you need to run it in interactive mode with a pseudo-teletype):
33
34```
35$ docker run --rm -it b09608732ec8
36 ____ ____ _ _
105cd287 37| _ \ _ _ _ __ ___/ ___| ___ _ __(_)_ __ | |_
99956601 38| |_) | | | | '__/ _ \___ \ / __| '__| | '_ \| __|
105cd287 39| __/| |_| | | | __/___) | (__| | | | |_) | |_
99956601
RS
40|_| \__,_|_| \___|____/ \___|_| |_| .__/ \__|
41 |_|
42
43:? shows help
44> import Prelude
45> 2 + 2
464
47
48> :t "Foo"
49String
50
105cd287 51>
99956601
RS
52See ya!
53```
54
105cd287 55To start doing real work with it, you need to mount a volume to your docker container when you run it.
99956601
RS
56Clone the [Purescript By Example](https://leanpub.com/purescript/read) code as an initial example:
57
58```
59$ git clone https://github.com/paf31/purescript-book
60Cloning into 'purescript-book'...
61Checking connectivity... done.
62```
63
64Then mount the volume using the absolute path of the cloned repo to the `/home/pureuser/src` folder in the container:
65
66```
67$ docker run --rm -itv ~/git/purescript/tmp/purescript-book/:/home/pureuser/src b09608732ec8 bash
68pureuser@1ddb0b0ed568:~$ ls
69src tmp
70pureuser@1ddb0b0ed568:~$ cd src/
71pureuser@1ddb0b0ed568:~/src$ ls
72CONTRIBUTING.md README.md chapter11 chapter13 chapter2 chapter4 chapter6 chapter8
73LICENSE.md chapter10 chapter12 chapter14 chapter3 chapter5 chapter7 chapter9
74pureuser@1ddb0b0ed568:~/src$ cd chapter3/
75pureuser@1ddb0b0ed568:~/src/chapter3$ bower install
76pureuser@1ddb0b0ed568:~/src/chapter3$ pulp build
77```
78
fb6a7a8a 79It should have built successfully. You can also run the tests:
99956601
RS
80
81```
82pureuser@1ddb0b0ed568:~/src/chapter3$ pulp test
83* Build successful.
84* Running tests...
85Nothing
86Just ("Smith, John: 123 Fake St., Faketown, CA")
87* Tests OK.
88```
89
90Since you mounted the volume, you can actually edit the code outside of the running docker instance and it will update inside the container!
91
105cd287 92Open up `chapter3/test/Main.purs` using your favorite editor, and update `example.address.street` in the `example` record to `"123 Foobar St."`. Now rerun the tests, and you'll see that it updated!
99956601
RS
93
94```
95pureuser@1ddb0b0ed568:~/src/chapter3$ pulp test
96* Build successful.
97* Running tests...
98Nothing
99Just ("Smith, John: 123 Foobar St., Faketown, CA")
100* Tests OK.
101```
102
103This docker image creates a user called `pureuser` that it logs in as so that `bower` and `pulp` don't yell at you. If you want to add more stuff as you go along, switch to the superuser (`su`), or add pureuser to sudoers.